On Mon, 11 Feb 2019, Martin Townsend wrote: > I can confirm that do_start_stop is called and the code where it > closes the LUN captures the EJECT (tested using Linux and Windows > host). > > up_read(&common->filesem); > down_write(&common->filesem); > printk(KERN_ERR "do_start_stop -> fsg_lun_close (EJECT)\n"); > fsg_lun_close(curlun); > up_write(&common->filesem); > down_read(&common->filesem); > > Thank you very much for this as we were about to abandon MSG :) > > I have one more problem, if I specify removable=y I can't re-insert > the device and after reading the documentation it looks like I have to > reset the backing file attribute in sysfs but I can't seem to write to > the file attribute: > root@beeker:/sys/module/g_mass_storage/parameters# ls -la > total 0 > drwxr-xr-x 2 root root 0 Feb 4 19:16 . > drwxr-xr-x 6 root root 0 Feb 4 19:15 .. > -r--r--r-- 1 root root 4096 Feb 4 19:16 bcdDevice > -r--r--r-- 1 root root 4096 Feb 4 19:16 cdrom > -r--r--r-- 1 root root 4096 Feb 4 19:16 file > -r--r--r-- 1 root root 4096 Feb 4 19:16 iManufacturer > -r--r--r-- 1 root root 4096 Feb 4 19:16 iProduct > -r--r--r-- 1 root root 4096 Feb 4 19:16 iSerialNumber > -r--r--r-- 1 root root 4096 Feb 4 19:16 idProduct > -r--r--r-- 1 root root 4096 Feb 4 19:16 idVendor > -r--r--r-- 1 root root 4096 Feb 4 19:16 luns > -r--r--r-- 1 root root 4096 Feb 4 19:16 nofua > -r--r--r-- 1 root root 4096 Feb 4 19:16 removable > -r--r--r-- 1 root root 4096 Feb 4 19:16 ro > -r--r--r-- 1 root root 4096 Feb 4 19:16 stall > > Even if I set the file to writable I just get an IO error. > root@beeker:/sys/module/g_mass_storage/parameters# chmod 666 file > root@beeker:/sys/module/g_mass_storage/parameters# echo > /data/mass_storage/msg.bin > file > -sh: echo: write error: Input/output error > > Any ideas as to why I'm seeing this? If I remove and reinsert the > g_mass_storage gadget kernel module I can re-insert the device. I > would like to build the gadget driver into the kernel as mass storage > is the only gadget function we have and I believe it can be built into > the kernel if this is the case. You're trying to write to the wrong sysfs file. /sys/module/g_mass_storage/parameters contains the parameters that you specified when g_mass_storage was loaded; you can't change them. The file you want is /sys/class/udc/XXX/device/gadget/lun0/file (fill in the XXX with the appropriate name for your UDC). Alan Stern