Issues with removable media

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Linux Kernel Govers,

I have read through the LDD3 & LWN and got a fair understanding about
implementing Linux removable block driver. I made an attempt to
simulate the Removable media in a Simple block driver module.

I am doing the following when trying to simulate the Removable media:

/******* Simple block Driver request ********/

 static void sbd_request(request_queue_t *q)
 {
    struct request *req;
    int status;

    while ((req = elv_next_request(q)) != NULL) {
      if (! blk_fs_request(req)) {
          printk (KERN_NOTICE "Skip non-CMD request\n");
          end_request(req, 0);
          continue;
      }

      /* Simple memcpy based on the request ; Returns success or
        failure which is passed to end_that_request_first() */
      status = sbd_transfer(&Device, req->sector, req->current_nr_sectors,
                 req->buffer, rq_data_dir(req));

      if(!end_that_request_first(req, status, req->current_nr_sectors)) {
                  blkdev_dequeue_request(req);
                  end_that_request_last(req);
            }
  }

Then, I prepared an IOCTL to simulate the removable media to the kernel.

When the applications issues IOCTL, it performs the following to
notify the kernel of removed disk.

/* Simulate the Removal Media Disk */
Case REMOVE_MOUNTED_DISK:

            if(Device.bdev)
                  invalidate_bdev(Device.bdev,1);
            del_gendisk(Device.gd);
            put_disk(Device.gd);
            blk_cleanup_queue(Queue);
            vfree(Device.data);
            return 0;

when I issue #ls /mnt (mount point) ( i.e. after the application
issues the IOCTL)
the Kernel crashes,
	OR
it crashes when tried to unload the module.

I have been trying hard to understand the real problem with this
module a long time from now.

What wrong am I doing in this module?
I will provide you with source code if you need it any time.
Please let me know what additional things should I handle when writing
code for removable media?

Regards,
Mukund Jampala
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux