sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget$/translations/zh_CN/usb/mass-storagemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/zh_TW/usb/mass-storagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/it_IT/usb/mass-storagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ja_JP/usb/mass-storagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ko_KR/usb/mass-storagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/sp_SP/usb/mass-storagemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hMass Storage Gadget (MSG)h]hMass Storage Gadget (MSG)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh>/var/lib/git/docbuild/linux/Documentation/usb/mass-storage.rsthKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh block_quote)}(hXMass Storage Gadget (or MSG) acts as a USB Mass Storage device, appearing to the host as a disk or a CD-ROM drive. It supports multiple logical units (LUNs). Backing storage for each LUN is provided by a regular file or a block device, access can be limited to read-only, and gadget can indicate that it is removable and/or CD-ROM (the latter implies read-only access). Its requirements are modest; only a bulk-in and a bulk-out endpoint are needed. The memory requirement amounts to two 16K buffers. Support is included for full-speed, high-speed and SuperSpeed operation. Note that the driver is slightly non-portable in that it assumes a single memory/DMA buffer will be usable for bulk-in and bulk-out endpoints. With most device controllers this is not an issue, but there may be some with hardware restrictions that prevent a buffer from being used by more than one endpoint. This document describes how to use the gadget from user space, its relation to mass storage function (or MSF) and different gadgets using it, and how it differs from File Storage Gadget (or FSG) (which is no longer included in Linux). It will talk only briefly about how to use MSF within composite gadgets. h](h paragraph)}(hXsMass Storage Gadget (or MSG) acts as a USB Mass Storage device, appearing to the host as a disk or a CD-ROM drive. It supports multiple logical units (LUNs). Backing storage for each LUN is provided by a regular file or a block device, access can be limited to read-only, and gadget can indicate that it is removable and/or CD-ROM (the latter implies read-only access).h]hXsMass Storage Gadget (or MSG) acts as a USB Mass Storage device, appearing to the host as a disk or a CD-ROM drive. It supports multiple logical units (LUNs). Backing storage for each LUN is provided by a regular file or a block device, access can be limited to read-only, and gadget can indicate that it is removable and/or CD-ROM (the latter implies read-only access).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh)}(hIts requirements are modest; only a bulk-in and a bulk-out endpoint are needed. The memory requirement amounts to two 16K buffers. Support is included for full-speed, high-speed and SuperSpeed operation.h]hIts requirements are modest; only a bulk-in and a bulk-out endpoint are needed. The memory requirement amounts to two 16K buffers. Support is included for full-speed, high-speed and SuperSpeed operation.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh)}(hX4Note that the driver is slightly non-portable in that it assumes a single memory/DMA buffer will be usable for bulk-in and bulk-out endpoints. With most device controllers this is not an issue, but there may be some with hardware restrictions that prevent a buffer from being used by more than one endpoint.h]hX4Note that the driver is slightly non-portable in that it assumes a single memory/DMA buffer will be usable for bulk-in and bulk-out endpoints. With most device controllers this is not an issue, but there may be some with hardware restrictions that prevent a buffer from being used by more than one endpoint.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubh)}(hX4This document describes how to use the gadget from user space, its relation to mass storage function (or MSF) and different gadgets using it, and how it differs from File Storage Gadget (or FSG) (which is no longer included in Linux). It will talk only briefly about how to use MSF within composite gadgets.h]hX4This document describes how to use the gadget from user space, its relation to mass storage function (or MSF) and different gadgets using it, and how it differs from File Storage Gadget (or FSG) (which is no longer included in Linux). It will talk only briefly about how to use MSF within composite gadgets.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hModule parametersh]hModule parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK!ubh)}(hXThe mass storage gadget accepts the following mass storage specific module parameters: - file=filename[,filename...] This parameter lists paths to files or block devices used for backing storage for each logical unit. There may be at most FSG_MAX_LUNS (8) LUNs set. If more files are specified, they will be silently ignored. See also “luns” parameter. *BEWARE* that if a file is used as a backing storage, it may not be modified by any other process. This is because the host assumes the data does not change without its knowledge. It may be read, but (if the logical unit is writable) due to buffering on the host side, the contents are not well defined. The size of the logical unit will be rounded down to a full logical block. The logical block size is 2048 bytes for LUNs simulating CD-ROM, block size of the device if the backing file is a block device, or 512 bytes otherwise. - removable=b[,b...] This parameter specifies whether each logical unit should be removable. “b” here is either “y”, “Y” or “1” for true or “n”, “N” or “0” for false. If this option is set for a logical unit, gadget will accept an “eject” SCSI request (Start/Stop Unit). When it is sent, the backing file will be closed to simulate ejection and the logical unit will not be mountable by the host until a new backing file is specified by userspace on the device (see “sysfs entries” section). If a logical unit is not removable (the default), a backing file must be specified for it with the “file” parameter as the module is loaded. The same applies if the module is built in, no exceptions. The default value of the flag is false, *HOWEVER* it used to be true. This has been changed to better match File Storage Gadget and because it seems like a saner default after all. Thus to maintain compatibility with older kernels, it's best to specify the default values. Also, if one relied on old default, explicit “n” needs to be specified now. Note that “removable” means the logical unit's media can be ejected or removed (as is true for a CD-ROM drive or a card reader). It does *not* mean that the entire gadget can be unplugged from the host; the proper term for that is “hot-unpluggable”. - cdrom=b[,b...] This parameter specifies whether each logical unit should simulate CD-ROM. The default is false. - ro=b[,b...] This parameter specifies whether each logical unit should be reported as read only. This will prevent host from modifying the backing files. Note that if this flag for given logical unit is false but the backing file could not be opened in read/write mode, the gadget will fall back to read only mode anyway. The default value for non-CD-ROM logical units is false; for logical units simulating CD-ROM it is forced to true. - nofua=b[,b...] This parameter specifies whether FUA flag should be ignored in SCSI Write10 and Write12 commands sent to given logical units. MS Windows mounts removable storage in “Removal optimised mode” by default. All the writes to the media are synchronous, which is achieved by setting the FUA (Force Unit Access) bit in SCSI Write(10,12) commands. This forces each write to wait until the data has actually been written out and prevents I/O requests aggregation in block layer dramatically decreasing performance. Note that this may mean that if the device is powered from USB and the user unplugs the device without unmounting it first (which at least some Windows users do), the data may be lost. The default value is false. - luns=N This parameter specifies number of logical units the gadget will have. It is limited by FSG_MAX_LUNS (8) and higher value will be capped. If this parameter is provided, and the number of files specified in “file” argument is greater then the value of “luns”, all excess files will be ignored. If this parameter is not present, the number of logical units will be deduced from the number of files specified in the “file” parameter. If the file parameter is missing as well, one is assumed. - stall=b Specifies whether the gadget is allowed to halt bulk endpoints. The default is determined according to the type of USB device controller, but usually true. In addition to the above, the gadget also accepts the following parameters defined by the composite framework (they are common to all composite gadgets so just a quick listing): - idVendor -- USB Vendor ID (16 bit integer) - idProduct -- USB Product ID (16 bit integer) - bcdDevice -- USB Device version (BCD) (16 bit integer) - iManufacturer -- USB Manufacturer string (string) - iProduct -- USB Product string (string) - iSerialNumber -- SerialNumber string (string) h](h)}(hVThe mass storage gadget accepts the following mass storage specific module parameters:h]hVThe mass storage gadget accepts the following mass storage specific module parameters:}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK#hj'ubh bullet_list)}(hhh](h list_item)}(hX)file=filename[,filename...] This parameter lists paths to files or block devices used for backing storage for each logical unit. There may be at most FSG_MAX_LUNS (8) LUNs set. If more files are specified, they will be silently ignored. See also “luns” parameter. *BEWARE* that if a file is used as a backing storage, it may not be modified by any other process. This is because the host assumes the data does not change without its knowledge. It may be read, but (if the logical unit is writable) due to buffering on the host side, the contents are not well defined. The size of the logical unit will be rounded down to a full logical block. The logical block size is 2048 bytes for LUNs simulating CD-ROM, block size of the device if the backing file is a block device, or 512 bytes otherwise. h](h)}(hfile=filename[,filename...]h]hfile=filename[,filename...]}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hj@ubh)}(hThis parameter lists paths to files or block devices used for backing storage for each logical unit. There may be at most FSG_MAX_LUNS (8) LUNs set. If more files are specified, they will be silently ignored. See also “luns” parameter.h]hThis parameter lists paths to files or block devices used for backing storage for each logical unit. There may be at most FSG_MAX_LUNS (8) LUNs set. If more files are specified, they will be silently ignored. See also “luns” parameter.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hj@ubh)}(hX1*BEWARE* that if a file is used as a backing storage, it may not be modified by any other process. This is because the host assumes the data does not change without its knowledge. It may be read, but (if the logical unit is writable) due to buffering on the host side, the contents are not well defined.h](hemphasis)}(h*BEWARE*h]hBEWARE}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1jdhj`ubhX) that if a file is used as a backing storage, it may not be modified by any other process. This is because the host assumes the data does not change without its knowledge. It may be read, but (if the logical unit is writable) due to buffering on the host side, the contents are not well defined.}(hj`hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK-hj@ubh)}(hThe size of the logical unit will be rounded down to a full logical block. The logical block size is 2048 bytes for LUNs simulating CD-ROM, block size of the device if the backing file is a block device, or 512 bytes otherwise.h]hThe size of the logical unit will be rounded down to a full logical block. The logical block size is 2048 bytes for LUNs simulating CD-ROM, block size of the device if the backing file is a block device, or 512 bytes otherwise.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK3hj@ubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hXIremovable=b[,b...] This parameter specifies whether each logical unit should be removable. “b” here is either “y”, “Y” or “1” for true or “n”, “N” or “0” for false. If this option is set for a logical unit, gadget will accept an “eject” SCSI request (Start/Stop Unit). When it is sent, the backing file will be closed to simulate ejection and the logical unit will not be mountable by the host until a new backing file is specified by userspace on the device (see “sysfs entries” section). If a logical unit is not removable (the default), a backing file must be specified for it with the “file” parameter as the module is loaded. The same applies if the module is built in, no exceptions. The default value of the flag is false, *HOWEVER* it used to be true. This has been changed to better match File Storage Gadget and because it seems like a saner default after all. Thus to maintain compatibility with older kernels, it's best to specify the default values. Also, if one relied on old default, explicit “n” needs to be specified now. Note that “removable” means the logical unit's media can be ejected or removed (as is true for a CD-ROM drive or a card reader). It does *not* mean that the entire gadget can be unplugged from the host; the proper term for that is “hot-unpluggable”. h](h)}(hremovable=b[,b...]h]hremovable=b[,b...]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjubh)}(hThis parameter specifies whether each logical unit should be removable. “b” here is either “y”, “Y” or “1” for true or “n”, “N” or “0” for false.h]hThis parameter specifies whether each logical unit should be removable. “b” here is either “y”, “Y” or “1” for true or “n”, “N” or “0” for false.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hjubh)}(hXMIf this option is set for a logical unit, gadget will accept an “eject” SCSI request (Start/Stop Unit). When it is sent, the backing file will be closed to simulate ejection and the logical unit will not be mountable by the host until a new backing file is specified by userspace on the device (see “sysfs entries” section).h]hXMIf this option is set for a logical unit, gadget will accept an “eject” SCSI request (Start/Stop Unit). When it is sent, the backing file will be closed to simulate ejection and the logical unit will not be mountable by the host until a new backing file is specified by userspace on the device (see “sysfs entries” section).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjubh)}(hIf a logical unit is not removable (the default), a backing file must be specified for it with the “file” parameter as the module is loaded. The same applies if the module is built in, no exceptions.h]hIf a logical unit is not removable (the default), a backing file must be specified for it with the “file” parameter as the module is loaded. The same applies if the module is built in, no exceptions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKEhjubh)}(hXcThe default value of the flag is false, *HOWEVER* it used to be true. This has been changed to better match File Storage Gadget and because it seems like a saner default after all. Thus to maintain compatibility with older kernels, it's best to specify the default values. Also, if one relied on old default, explicit “n” needs to be specified now.h](h(The default value of the flag is false, }(hjhhhNhNubje)}(h *HOWEVER*h]hHOWEVER}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jdhjubhX4 it used to be true. This has been changed to better match File Storage Gadget and because it seems like a saner default after all. Thus to maintain compatibility with older kernels, it’s best to specify the default values. Also, if one relied on old default, explicit “n” needs to be specified now.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKJhjubh)}(hXNote that “removable” means the logical unit's media can be ejected or removed (as is true for a CD-ROM drive or a card reader). It does *not* mean that the entire gadget can be unplugged from the host; the proper term for that is “hot-unpluggable”.h](hNote that “removable” means the logical unit’s media can be ejected or removed (as is true for a CD-ROM drive or a card reader). It does }(hjhhhNhNubje)}(h*not*h]hnot}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jdhjubho mean that the entire gadget can be unplugged from the host; the proper term for that is “hot-unpluggable”.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKQhjubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hrcdrom=b[,b...] This parameter specifies whether each logical unit should simulate CD-ROM. The default is false. h](h)}(hcdrom=b[,b...]h]hcdrom=b[,b...]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKWhjubh)}(haThis parameter specifies whether each logical unit should simulate CD-ROM. The default is false.h]haThis parameter specifies whether each logical unit should simulate CD-ROM. The default is false.}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hXro=b[,b...] This parameter specifies whether each logical unit should be reported as read only. This will prevent host from modifying the backing files. Note that if this flag for given logical unit is false but the backing file could not be opened in read/write mode, the gadget will fall back to read only mode anyway. The default value for non-CD-ROM logical units is false; for logical units simulating CD-ROM it is forced to true. h](h)}(h ro=b[,b...]h]h ro=b[,b...]}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hj:ubh)}(hThis parameter specifies whether each logical unit should be reported as read only. This will prevent host from modifying the backing files.h]hThis parameter specifies whether each logical unit should be reported as read only. This will prevent host from modifying the backing files.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hj:ubh)}(hNote that if this flag for given logical unit is false but the backing file could not be opened in read/write mode, the gadget will fall back to read only mode anyway.h]hNote that if this flag for given logical unit is false but the backing file could not be opened in read/write mode, the gadget will fall back to read only mode anyway.}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhj:ubh)}(hrThe default value for non-CD-ROM logical units is false; for logical units simulating CD-ROM it is forced to true.h]hrThe default value for non-CD-ROM logical units is false; for logical units simulating CD-ROM it is forced to true.}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhj:ubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hXnofua=b[,b...] This parameter specifies whether FUA flag should be ignored in SCSI Write10 and Write12 commands sent to given logical units. MS Windows mounts removable storage in “Removal optimised mode” by default. All the writes to the media are synchronous, which is achieved by setting the FUA (Force Unit Access) bit in SCSI Write(10,12) commands. This forces each write to wait until the data has actually been written out and prevents I/O requests aggregation in block layer dramatically decreasing performance. Note that this may mean that if the device is powered from USB and the user unplugs the device without unmounting it first (which at least some Windows users do), the data may be lost. The default value is false. h](h)}(hnofua=b[,b...]h]hnofua=b[,b...]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihj|ubh)}(h}This parameter specifies whether FUA flag should be ignored in SCSI Write10 and Write12 commands sent to given logical units.h]h}This parameter specifies whether FUA flag should be ignored in SCSI Write10 and Write12 commands sent to given logical units.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhj|ubh)}(hXMS Windows mounts removable storage in “Removal optimised mode” by default. All the writes to the media are synchronous, which is achieved by setting the FUA (Force Unit Access) bit in SCSI Write(10,12) commands. This forces each write to wait until the data has actually been written out and prevents I/O requests aggregation in block layer dramatically decreasing performance.h]hXMS Windows mounts removable storage in “Removal optimised mode” by default. All the writes to the media are synchronous, which is achieved by setting the FUA (Force Unit Access) bit in SCSI Write(10,12) commands. This forces each write to wait until the data has actually been written out and prevents I/O requests aggregation in block layer dramatically decreasing performance.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhj|ubh)}(hNote that this may mean that if the device is powered from USB and the user unplugs the device without unmounting it first (which at least some Windows users do), the data may be lost.h]hNote that this may mean that if the device is powered from USB and the user unplugs the device without unmounting it first (which at least some Windows users do), the data may be lost.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhj|ubh)}(hThe default value is false.h]hThe default value is false.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhj|ubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hXluns=N This parameter specifies number of logical units the gadget will have. It is limited by FSG_MAX_LUNS (8) and higher value will be capped. If this parameter is provided, and the number of files specified in “file” argument is greater then the value of “luns”, all excess files will be ignored. If this parameter is not present, the number of logical units will be deduced from the number of files specified in the “file” parameter. If the file parameter is missing as well, one is assumed. h](h)}(hluns=Nh]hluns=N}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hjubh)}(hThis parameter specifies number of logical units the gadget will have. It is limited by FSG_MAX_LUNS (8) and higher value will be capped.h]hThis parameter specifies number of logical units the gadget will have. It is limited by FSG_MAX_LUNS (8) and higher value will be capped.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK}hjubh)}(hIf this parameter is provided, and the number of files specified in “file” argument is greater then the value of “luns”, all excess files will be ignored.h]hIf this parameter is provided, and the number of files specified in “file” argument is greater then the value of “luns”, all excess files will be ignored.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hIf this parameter is not present, the number of logical units will be deduced from the number of files specified in the “file” parameter. If the file parameter is missing as well, one is assumed.h]hIf this parameter is not present, the number of logical units will be deduced from the number of files specified in the “file” parameter. If the file parameter is missing as well, one is assumed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j>hj;ubj?)}(hstall=b Specifies whether the gadget is allowed to halt bulk endpoints. The default is determined according to the type of USB device controller, but usually true. h](h)}(hstall=bh]hstall=b}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hSpecifies whether the gadget is allowed to halt bulk endpoints. The default is determined according to the type of USB device controller, but usually true.h]hSpecifies whether the gadget is allowed to halt bulk endpoints. The default is determined according to the type of USB device controller, but usually true.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j>hj;ubeh}(h]h ]h"]h$]h&]bullet-uh1j9hhhK&hj'ubh)}(hIn addition to the above, the gadget also accepts the following parameters defined by the composite framework (they are common to all composite gadgets so just a quick listing):h]hIn addition to the above, the gadget also accepts the following parameters defined by the composite framework (they are common to all composite gadgets so just a quick listing):}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj'ubj:)}(hhh](j?)}(h/idVendor -- USB Vendor ID (16 bit integer)h]h)}(hjOh]h/idVendor -- USB Vendor ID (16 bit integer)}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubah}(h]h ]h"]h$]h&]uh1j>hjJubj?)}(h0idProduct -- USB Product ID (16 bit integer)h]h)}(hjfh]h0idProduct -- USB Product ID (16 bit integer)}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjdubah}(h]h ]h"]h$]h&]uh1j>hjJubj?)}(h:bcdDevice -- USB Device version (BCD) (16 bit integer)h]h)}(hj}h]h:bcdDevice -- USB Device version (BCD) (16 bit integer)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubah}(h]h ]h"]h$]h&]uh1j>hjJubj?)}(h1iManufacturer -- USB Manufacturer string (string)h]h)}(hjh]h1iManufacturer -- USB Manufacturer string (string)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j>hjJubj?)}(h,iProduct -- USB Product string (string)h]h)}(hjh]h,iProduct -- USB Product string (string)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j>hjJubj?)}(h.iSerialNumber -- SerialNumber string (string) h]h)}(h-iSerialNumber -- SerialNumber string (string)h]h-iSerialNumber -- SerialNumber string (string)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j>hjJubeh}(h]h ]h"]h$]h&]j:j;uh1j9hhhKhj'ubeh}(h]h ]h"]h$]h&]uh1hhhhK#hjhhubeh}(h]module-parametersah ]h"]module parametersah$]h&]uh1hhhhhhhhK!ubh)}(hhh](h)}(h sysfs entriesh]h sysfs entries}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXFor each logical unit, the gadget creates a directory in the sysfs hierarchy. Inside of it the following three files are created: - file When read it returns the path to the backing file for the given logical unit. If there is no backing file (possible only if the logical unit is removable), the content is empty. When written into, it changes the backing file for given logical unit. This change can be performed even if given logical unit is not specified as removable (but that may look strange to the host). It may fail, however, if host disallowed medium removal with the Prevent-Allow Medium Removal SCSI command. - ro Reflects the state of ro flag for the given logical unit. It can be read any time, and written to when there is no backing file open for given logical unit. - nofua Reflects the state of nofua flag for given logical unit. It can be read and written. - forced_eject When written into, it causes the backing file to be forcibly detached from the LUN, regardless of whether the host has allowed it. The content doesn't matter, any non-zero number of bytes written will result in ejection. Can not be read. Other then those, as usual, the values of module parameters can be read from /sys/module/g_mass_storage/parameters/* files. h](h)}(hFor each logical unit, the gadget creates a directory in the sysfs hierarchy. Inside of it the following three files are created:h]hFor each logical unit, the gadget creates a directory in the sysfs hierarchy. Inside of it the following three files are created:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj:)}(hhh](j?)}(hXfile When read it returns the path to the backing file for the given logical unit. If there is no backing file (possible only if the logical unit is removable), the content is empty. When written into, it changes the backing file for given logical unit. This change can be performed even if given logical unit is not specified as removable (but that may look strange to the host). It may fail, however, if host disallowed medium removal with the Prevent-Allow Medium Removal SCSI command. h](h)}(hfileh]hfile}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hWhen read it returns the path to the backing file for the given logical unit. If there is no backing file (possible only if the logical unit is removable), the content is empty.h]hWhen read it returns the path to the backing file for the given logical unit. If there is no backing file (possible only if the logical unit is removable), the content is empty.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hX3When written into, it changes the backing file for given logical unit. This change can be performed even if given logical unit is not specified as removable (but that may look strange to the host). It may fail, however, if host disallowed medium removal with the Prevent-Allow Medium Removal SCSI command.h]hX3When written into, it changes the backing file for given logical unit. This change can be performed even if given logical unit is not specified as removable (but that may look strange to the host). It may fail, however, if host disallowed medium removal with the Prevent-Allow Medium Removal SCSI command.}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j>hjubj?)}(hro Reflects the state of ro flag for the given logical unit. It can be read any time, and written to when there is no backing file open for given logical unit. h](h)}(hroh]hro}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjFubh)}(hReflects the state of ro flag for the given logical unit. It can be read any time, and written to when there is no backing file open for given logical unit.h]hReflects the state of ro flag for the given logical unit. It can be read any time, and written to when there is no backing file open for given logical unit.}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjFubeh}(h]h ]h"]h$]h&]uh1j>hjubj?)}(h]nofua Reflects the state of nofua flag for given logical unit. It can be read and written. h](h)}(hnofuah]hnofua}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlubh)}(hUReflects the state of nofua flag for given logical unit. It can be read and written.h]hUReflects the state of nofua flag for given logical unit. It can be read and written.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlubeh}(h]h ]h"]h$]h&]uh1j>hjubj?)}(hforced_eject When written into, it causes the backing file to be forcibly detached from the LUN, regardless of whether the host has allowed it. The content doesn't matter, any non-zero number of bytes written will result in ejection. Can not be read. h](h)}(h forced_ejecth]h forced_eject}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hWhen written into, it causes the backing file to be forcibly detached from the LUN, regardless of whether the host has allowed it. The content doesn't matter, any non-zero number of bytes written will result in ejection.h]hWhen written into, it causes the backing file to be forcibly detached from the LUN, regardless of whether the host has allowed it. The content doesn’t matter, any non-zero number of bytes written will result in ejection.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hCan not be read.h]hCan not be read.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j>hjubeh}(h]h ]h"]h$]h&]j:j;uh1j9hhhKhjubh)}(h{Other then those, as usual, the values of module parameters can be read from /sys/module/g_mass_storage/parameters/* files.h]h{Other then those, as usual, the values of module parameters can be read from /sys/module/g_mass_storage/parameters/* files.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h] sysfs-entriesah ]h"] sysfs entriesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h)Other gadgets using mass storage functionh]h)Other gadgets using mass storage function}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXThe Mass Storage Gadget uses the Mass Storage Function to handle mass storage protocol. As a composite function, MSF may be used by other gadgets as well (eg. g_multi and acm_ms). All of the information in previous sections are valid for other gadgets using MSF, except that support for mass storage related module parameters may be missing, or the parameters may have a prefix. To figure out whether any of this is true one needs to consult the gadget's documentation or its source code. For examples of how to include mass storage function in gadgets, one may take a look at mass_storage.c, acm_ms.c and multi.c (sorted by complexity). h](h)}(hThe Mass Storage Gadget uses the Mass Storage Function to handle mass storage protocol. As a composite function, MSF may be used by other gadgets as well (eg. g_multi and acm_ms).h]hThe Mass Storage Gadget uses the Mass Storage Function to handle mass storage protocol. As a composite function, MSF may be used by other gadgets as well (eg. g_multi and acm_ms).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hX5All of the information in previous sections are valid for other gadgets using MSF, except that support for mass storage related module parameters may be missing, or the parameters may have a prefix. To figure out whether any of this is true one needs to consult the gadget's documentation or its source code.h]hX7All of the information in previous sections are valid for other gadgets using MSF, except that support for mass storage related module parameters may be missing, or the parameters may have a prefix. To figure out whether any of this is true one needs to consult the gadget’s documentation or its source code.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hFor examples of how to include mass storage function in gadgets, one may take a look at mass_storage.c, acm_ms.c and multi.c (sorted by complexity).h]hFor examples of how to include mass storage function in gadgets, one may take a look at mass_storage.c, acm_ms.c and multi.c (sorted by complexity).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h])other-gadgets-using-mass-storage-functionah ]h"])other gadgets using mass storage functionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hRelation to file storage gadgeth]hRelation to file storage gadget}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj5hhhhhKubh)}(hXThe Mass Storage Function and thus the Mass Storage Gadget has been based on the File Storage Gadget. The difference between the two is that MSG is a composite gadget (ie. uses the composite framework) while file storage gadget was a traditional gadget. From userspace point of view this distinction does not really matter, but from kernel hacker's point of view, this means that (i) MSG does not duplicate code needed for handling basic USB protocol commands and (ii) MSF can be used in any other composite gadget. Because of that, File Storage Gadget has been removed in Linux 3.8. All users need to transition to the Mass Storage Gadget. The two gadgets behave mostly the same from the outside except: 1. In FSG the “removable” and “cdrom” module parameters set the flag for all logical units whereas in MSG they accept a list of y/n values for each logical unit. If one uses only a single logical unit this does not matter, but if there are more, the y/n value needs to be repeated for each logical unit. 2. FSG's “serial”, “vendor”, “product” and “release” module parameters are handled in MSG by the composite layer's parameters named respectively: “iSerialnumber”, “idVendor”, “idProduct” and “bcdDevice”. 3. MSG does not support FSG's test mode, thus “transport”, “protocol” and “buflen” FSG's module parameters are not supported. MSG always uses SCSI protocol with bulk only transport mode and 16 KiB buffers.h](h)}(hXThe Mass Storage Function and thus the Mass Storage Gadget has been based on the File Storage Gadget. The difference between the two is that MSG is a composite gadget (ie. uses the composite framework) while file storage gadget was a traditional gadget. From userspace point of view this distinction does not really matter, but from kernel hacker's point of view, this means that (i) MSG does not duplicate code needed for handling basic USB protocol commands and (ii) MSF can be used in any other composite gadget.h]hXThe Mass Storage Function and thus the Mass Storage Gadget has been based on the File Storage Gadget. The difference between the two is that MSG is a composite gadget (ie. uses the composite framework) while file storage gadget was a traditional gadget. From userspace point of view this distinction does not really matter, but from kernel hacker’s point of view, this means that (i) MSG does not duplicate code needed for handling basic USB protocol commands and (ii) MSF can be used in any other composite gadget.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjFubh)}(hBecause of that, File Storage Gadget has been removed in Linux 3.8. All users need to transition to the Mass Storage Gadget. The two gadgets behave mostly the same from the outside except:h]hBecause of that, File Storage Gadget has been removed in Linux 3.8. All users need to transition to the Mass Storage Gadget. The two gadgets behave mostly the same from the outside except:}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjFubhenumerated_list)}(hhh](j?)}(hX6In FSG the “removable” and “cdrom” module parameters set the flag for all logical units whereas in MSG they accept a list of y/n values for each logical unit. If one uses only a single logical unit this does not matter, but if there are more, the y/n value needs to be repeated for each logical unit. h]h)}(hX5In FSG the “removable” and “cdrom” module parameters set the flag for all logical units whereas in MSG they accept a list of y/n values for each logical unit. If one uses only a single logical unit this does not matter, but if there are more, the y/n value needs to be repeated for each logical unit.h]hX5In FSG the “removable” and “cdrom” module parameters set the flag for all logical units whereas in MSG they accept a list of y/n values for each logical unit. If one uses only a single logical unit this does not matter, but if there are more, the y/n value needs to be repeated for each logical unit.}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjkubah}(h]h ]h"]h$]h&]uh1j>hjhubj?)}(hFSG's “serial”, “vendor”, “product” and “release” module parameters are handled in MSG by the composite layer's parameters named respectively: “iSerialnumber”, “idVendor”, “idProduct” and “bcdDevice”. h]h)}(hFSG's “serial”, “vendor”, “product” and “release” module parameters are handled in MSG by the composite layer's parameters named respectively: “iSerialnumber”, “idVendor”, “idProduct” and “bcdDevice”.h]hFSG’s “serial”, “vendor”, “product” and “release” module parameters are handled in MSG by the composite layer’s parameters named respectively: “iSerialnumber”, “idVendor”, “idProduct” and “bcdDevice”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j>hjhubj?)}(hMSG does not support FSG's test mode, thus “transport”, “protocol” and “buflen” FSG's module parameters are not supported. MSG always uses SCSI protocol with bulk only transport mode and 16 KiB buffers.h]h)}(hMSG does not support FSG's test mode, thus “transport”, “protocol” and “buflen” FSG's module parameters are not supported. MSG always uses SCSI protocol with bulk only transport mode and 16 KiB buffers.h]hMSG does not support FSG’s test mode, thus “transport”, “protocol” and “buflen” FSG’s module parameters are not supported. MSG always uses SCSI protocol with bulk only transport mode and 16 KiB buffers.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j>hjhubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jfhjFubeh}(h]h ]h"]h$]h&]uh1hhhhKhj5hhubeh}(h]relation-to-file-storage-gadgetah ]h"]relation to file storage gadgetah$]h&]uh1hhhhhhhhKubeh}(h]mass-storage-gadget-msgah ]h"]mass storage gadget (msg)ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjjjjj2j/jju nametypes}(jjjjj2juh}(jhjhjjjjj/jjj5u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.