usb-ctrl: adds to configure the usb interface type

Implementation of adjust interface type of inserting usb-gadget:

```usb-ctrl insert <name> <file> [<type=usb|usb-ro|hdd|cdrom>]```

* usb     - RW, Removable USB-flash
* usb-ro  - RO, USB-flash
* hdd     - RW, USB-HDD
* cdrom   - RO, Removable USB-CDROM

If type not specified or illegal then using 'usb-ro' as default

Tested: calling `usb-ctrl insert` with each posible value
(usb|usb-ro|hdd|cdrom); additionally been call with empty value and
with invalid value 'err_type':

* ```
root@:~# usb-ctrl insert usb0 /dev/nbd0 usb

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
1

root@:~# usb-ctrl insert usb0 /dev/nbd0 usb-ro

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
1
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
1

root@:~# usb-ctrl insert usb0 /dev/nbd0 hdd

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
0

root@:~# usb-ctrl insert usb0 /dev/nbd0 cdrom

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
1
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
1
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
1

root@:~# usb-ctrl insert usb0 /dev/nbd0
No mass-storage interface type specified or illegal
Configuring interface type to 'usb-ro'

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
1
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
1

root@:~# usb-ctrl insert usb0 /dev/nbd0 err_type
No mass-storage interface type specified or illegal
Configuring interface type to 'usb-ro'

root@:~# cat /sys/.../mass-storage/....usb0/lun.0/cdrom
0
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/ro
1
root@:~# cat /sys/.../mass-storage/....usb0/lun.0/removable
1
```

Signed-off-by: Igor Kononenko <i.kononenko@yadro.com>
Change-Id: I46155e28ec7a441863ce86f425a46ac1297444ed
1 file changed
tree: 9623d639036fb9d9cc02d72cf2f2517eaf0c941c
  1. firstboot/
  2. http-redirect/
  3. usb-ctrl/
  4. .gitignore
  5. LICENSE
  6. meson.build
  7. meson_options.txt
  8. README.md
README.md

phosphor-misc

phosphor-misc is a collection of miscellaneous OpenBMC functions that doesn't really fit anywhere else.

Contributing

If you have a new function in mind to be hosted in phosphor-misc, it is usually a good idea to mention it on the OpenBMC mailing list before writing any code. There might already be an implementation of the desired function or the community may suggest alternatives.

phosphor-misc patches are reviewed using the Gerrit instance at https://gerrit.openbmc-project.xyz.

Please submit patches to Gerrit. More information on using Gerrit can be found here. https://github.com/openbmc/phosphor-misc is a hosting mirror only and GitHub pull requests are not monitored and will not be accepted.

Patch checklist. Please ensure patches adhere to the following guidelines:

For questions or help please come join us on the mailing list or in IRC.