mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
usb: gadget: f_mass_storage: forced_eject attribute
It allows to reset prevent_medium_removal flag and "eject" the image. This can be useful to free the drive from a hunging host or if the host continues to use the drive even after unmounting (Linux does this). It's also a bit like using an unfolded paperclip on an optical drive. Previously, the undocumented method of sending SIGUSR1 to a special "file-storage" kernel thread could be used for these purposes, but when using multiple storages there was no way to distinguish one from the other, so we had to send a signal to everyone. Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Maxim Devaev <mdevaev@gmail.com> Link: https://lore.kernel.org/r/20220711102956.19642-1-mdevaev@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8097cf2fb3
commit
421c8d9a20
@@ -519,4 +519,19 @@ ssize_t fsg_store_inquiry_string(struct fsg_lun *curlun, const char *buf,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fsg_store_inquiry_string);
|
||||
|
||||
ssize_t fsg_store_forced_eject(struct fsg_lun *curlun, struct rw_semaphore *filesem,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Forcibly detach the backing file from the LUN
|
||||
* regardless of whether the host has allowed it.
|
||||
*/
|
||||
curlun->prevent_medium_removal = 0;
|
||||
ret = fsg_store_file(curlun, filesem, "", 0);
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fsg_store_forced_eject);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
Reference in New Issue
Block a user