mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
Add simple argument parser
This commit is contained in:
37
README.md
37
README.md
@@ -1,5 +1,7 @@
|
||||
# isodrive (configfs)
|
||||
|
||||
## Building
|
||||
|
||||
* `sudo apt install build-essential`
|
||||
|
||||
* `git clone https://github.com/nitanmarcel/isodrive`
|
||||
@@ -10,36 +12,29 @@
|
||||
|
||||
* `sudo make install` (optional)
|
||||
|
||||
usage:
|
||||
## Usage
|
||||
|
||||
* `isodrive {iso} {cdrom[0/1]} {readonly[1/0]}`
|
||||
```
|
||||
cdrom [FILE]... [OPTION]...
|
||||
Mounts the given FILE as a bootable device using configfs.
|
||||
Run without any arguments to unmount any mounted files and to display this help message.
|
||||
|
||||
mount
|
||||
|
||||
* `sudo isodrive /full/path/to/file.iso`
|
||||
|
||||
umount
|
||||
|
||||
* `sudo isodrive`
|
||||
|
||||
mount (as cdrom)
|
||||
|
||||
* `sudo isodrive /full/path/to/file.iso 1 1`
|
||||
|
||||
mount (as read write)
|
||||
|
||||
* `sudo isodrive /full/path/to/file.iso 0 0`
|
||||
Optional arguments:
|
||||
-rw Mounts the file in read write mode.
|
||||
-cdrom Mounts the file as a cdrom.
|
||||
```
|
||||
|
||||
## Linux
|
||||
* _Has been only tested on Halium based mobile linux, but should work on mainline devices too._
|
||||
* Has been only tested on Halium based mobile linux, but should work on mainline devices too.
|
||||
|
||||
## Android
|
||||
|
||||
* _On Android you must be compiled in termux, using clang++_
|
||||
* _On Android you might manually need to mount configfs by running: `mount -t configfs configfs /sys/kernel/config`_
|
||||
* On Android can be compiled in termux, using clang++
|
||||
* On Android you might manually need to mount configfs by running: `mount -t configfs configfs /sys/kernel/config`
|
||||
* A magisk module is also available for download [HERE](https://github.com/nitanmarcel/isodrive-magisk/releases/latest)
|
||||
|
||||
## Os Support
|
||||
* _Should support almost every bootable OS images, but for those who don't work or need extra steps, are documented in the [WIKI](https://github.com/nitanmarcel/isodrive/wiki)_
|
||||
* Should support almost every bootable OS images, but for those who don't work or need extra steps, are documented in the [WIKI](https://github.com/nitanmarcel/isodrive/wiki)
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
40
src/main.cpp
40
src/main.cpp
@@ -1,11 +1,45 @@
|
||||
#include "configfsisomanager.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
char *iso_target = argv[1];
|
||||
char *cdrom = (char*)"0";
|
||||
char *ro = (char*)"1";
|
||||
char *iso_target = argv[1];
|
||||
char *cdrom = (char*)"0";
|
||||
char *ro = (char*)"1";
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-rw") == 0)
|
||||
{
|
||||
ro = (char*)"0";
|
||||
}
|
||||
else if (strcmp(argv[i], "-cdrom") == 0)
|
||||
{
|
||||
cdrom = (char*)"1";
|
||||
}
|
||||
else
|
||||
{
|
||||
iso_target = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("cdrom [FILE]... [OPTION]...\n");
|
||||
printf("Mounts the given FILE as a bootable device using configfs.\n");
|
||||
printf("Run without any arguments to unmount any mounted files and display this help message.\n\n");
|
||||
|
||||
printf("Optional arguments:\n");
|
||||
printf("-rw\t Mounts the file in read write mode.\n");
|
||||
printf("-cdrom\t Mounts the file as a cdrom.\n\n");
|
||||
printf("UMOUNT:\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("MOUNT:\n");
|
||||
}
|
||||
|
||||
if (!supported())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user