Problem Simulating REMOVAL Media

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

 



Dear Linux Kernel Govers,

Here I am making an attempt to simulate the Removable media in a Simple
block driver module.
It results in a segmentation fault raising the kernel module count to 1
which makes me to reboot it.

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));

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

I issue an IOCTL from the application after the module is loaded and
memory device is mounted.
The IOCTL code executed is as follows:

/* 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;

After this, I get a segmentation fault either when I issue a 
#ls /mnt
	OR
When I try to unload the driver module?

Result is module cannot be unloaded, and some times it hangs the console
terminal.

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