Hi, I am encountering problem while using copy_to_user in my program pasted below.
Can you tell me where I am going wrong? My objective here is to pass the values of page_address(bvec->bv_page),
bvec->bv_len, bvec->bv_offset, bio_sectors(bio) to the user application
above. Right now I am just trying it with simple char *buffer. Once this is
successful , I have encapsulated the page_address etc in a structure and will
be using to pass onto the user application. Need your help asap. TIA. My user –space application is char *message = “How r u?” char buffer[100]; int fd = open("/dev/sga",O_RDWR); if (fd < 0) { printf("open failed\n"); exit(1); } memset(buffer,0,100); write(fd, message, strlen(message) +1 ); bytes = read(fd,buffer,100); write(1,buffer,100); My kernel level function is :- static int block_dev_random_transfer(struct block_dev *dev,
struct bio *bio) { int segno; struct bio_vec *bvec; sector_t sector = bio->bi_sector; bio_for_each_segment(bvec,bio,segno) { char *buffer =
__bio_kmap_atomic(bio,segno,KM_USER0); printk(KERN_ALERT " virtual address =
%x ,bvec->bv_len = %u , bvec->bv_offset = %d , data transferred in
sectors = %u and segno = %d\n", page_address(bvec->bv_page), bvec->bv_len,
bvec->bv_offset, bio_sectors(bio), segno);
block_transfer(dev,sector,bio_cur_sectors(bio),buffer,bio_data_dir(bio) ==
WRITE); sector += bio_cur_sectors(bio); __bio_kunmap_atomic(bio,KM_USER0); bio->bi_private = vmalloc(strlen(buffer)
+1); if (copy_to_user((unsigned char
*)bio->bi_private, (unsigned char *)buffer, strlen(buffer)+1)) { printk(KERN_ALERT "copy_to_user
failed\n"); return -EFAULT; } } return 0; } http://www.patni.com World-Wide Partnerships. World-Class Solutions. _____________________________________________________________________ This e-mail message may contain proprietary, confidential or legally privileged information for the sole use of the person or entity to whom this message was originally addressed. Any review, e-transmission dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error kindly delete this e-mail from your records. If it appears that this mail has been forwarded to you without proper authority, please notify us immediately at netadmin@xxxxxxxxx and delete this mail. _____________________________________________________________________ |