Use configfs first if available, else try sysfs

This commit is contained in:
Marcel Alexandru Nitan
2023-09-02 11:51:05 +03:00
parent 82c4588e63
commit b9f64576cc
2 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -13,17 +13,17 @@
* `sudo make install` (optional) * `sudo make install` (optional)
## Usage ## Usage
```bash ```bash
Usage:
isodrive [FILE]... [OPTION]... isodrive [FILE]... [OPTION]...
Mounts the given FILE as a bootable device using configfs. Mounts the given FILE as a bootable device using configfs.
Run without any arguments to unmount any mounted files and display this help message. Run without any arguments to unmount any mounted files and display this help message.
Optional arguments: Optional arguments:
-rw Mounts the file in read write mode. -rw Mounts the file in read write mode.
-cdrom Mounts the file as a cdrom. -cdrom Mounts the file as a cdrom.
-configfs Forces the app to use configfs. -configfs Forces the app to use configfs.
-usbgadget Forces the app to use usb_gadget. -usbgadget Forces the app to use sysfs.
``` ```
### Examples ### Examples
+4 -4
View File
@@ -15,7 +15,7 @@ int print_help() {
printf("-rw\t\t Mounts the file in read write mode.\n"); printf("-rw\t\t Mounts the file in read write mode.\n");
printf("-cdrom\t\t Mounts the file as a cdrom.\n"); printf("-cdrom\t\t Mounts the file as a cdrom.\n");
printf("-configfs\t Forces the app to use configfs.\n"); printf("-configfs\t Forces the app to use configfs.\n");
printf("-usbgadget\t Forces the app to use usb_gadget.\n\n"); printf("-usbgadget\t Forces the app to use sysfs.\n\n");
return 1; return 1;
} }
@@ -44,7 +44,7 @@ void configs(char *iso_target, char *cdrom, char *ro) {
} }
void usb(char *iso_target, char *cdrom, char *ro) { void usb(char *iso_target, char *cdrom, char *ro) {
printf("Using usb_gadget!\n"); printf("Using sysfs!\n");
if (!usb_supported()) if (!usb_supported())
{ {
printf("usb_gadget is not supported!\n"); printf("usb_gadget is not supported!\n");
@@ -101,10 +101,10 @@ int main(int argc, char *argv[]) {
{ {
usb(iso_target, cdrom, ro); usb(iso_target, cdrom, ro);
} }
else if (usb_supported())
usb(iso_target, cdrom, ro);
else if (supported()) else if (supported())
configs(iso_target, cdrom, ro); configs(iso_target, cdrom, ro);
else if (usb_supported())
usb(iso_target, cdrom, ro);
else else
printf("Device does not support isodrive\n"); printf("Device does not support isodrive\n");
return 0; return 0;