usb: f_mass_storage: set removable flag in do_inquiry based on LUN
authorEric Nelson <eric.nelson@boundarydevices.com>
Sat, 20 Sep 2014 00:06:46 +0000 (17:06 -0700)
committerChanho Park <chanho61.park@samsung.com>
Fri, 24 Jul 2015 07:30:03 +0000 (16:30 +0900)
Without this flag, tools like Alex Page's USB Image Tool
won't see drives exposed over USB Gadget as removable,
and won't allow access to them.
http://www.alexpage.de/usb-image-tool/

The code was pulled from the main-line kernel:
drivers/usb/gadget/function/f_mass_storage.c

Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
drivers/usb/gadget/f_mass_storage.c

index 6c8e35fe006206aaa4fa07ee26dcee93a02381dc..f7223c52d45d372424c66cfd15449d9d65a7a439 100644 (file)
@@ -1141,6 +1141,7 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
 
        memset(buf, 0, 8);
        buf[0] = TYPE_DISK;
+       buf[1] = curlun->removable ? 0x80 : 0;
        buf[2] = 2;             /* ANSI SCSI level 2 */
        buf[3] = 2;             /* SCSI-2 INQUIRY data format */
        buf[4] = 31;            /* Additional length */