Allow device-less mounts for things like googlefs...

Accept -o as -p; update usage text.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19872 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2007-01-20 00:35:17 +00:00
parent eaac07392a
commit b3e65bfd2e
+14 -7
View File
@@ -18,9 +18,11 @@ static void
usage(const char *programName)
{
printf("usage: %s [-ro] [-t fstype] [-p parameter] device directory\n"
printf("usage: %s [-ro] [-t fstype] [-p parameter] [device] directory\n"
"\t-ro\tmounts the volume read-only\n"
"\t-t\tspecifies the file system to use (defaults to automatic recognition)\n",programName);
"\t-t\tspecifies the file system to use (defaults to automatic recognition)\n"
"\t-p\tspecifies parameters to pass to the file system (-o also accepted)\n"
"\tif device is not specified, NULL is passed (for in-memory filesystems)\n",programName);
exit(1);
}
@@ -29,7 +31,8 @@ int
main(int argc, char **argv)
{
const char *programName = argv[0];
const char *device, *mountPoint;
const char *device = NULL;
const char *mountPoint;
const char *parameter = NULL;
const char *fs = NULL;
struct stat mountStat;
@@ -56,7 +59,7 @@ main(int argc, char **argv)
break;
fs = *++argv;
argc--;
} else if (!strcmp(arg, "p") && parameter == NULL) {
} else if ((!strcmp(arg, "p") || !strcmp(arg, "o")) && parameter == NULL) {
if (argc <= 1)
break;
parameter = *++argv;
@@ -67,10 +70,14 @@ main(int argc, char **argv)
/* check the arguments */
device = argv[0];
mountPoint = argv[1];
if (argc > 1) {
device = argv[0];
argv++;
argc--;
}
mountPoint = argv[0];
if (device == NULL || mountPoint == NULL)
if (mountPoint == NULL)
usage(programName);
if (stat(mountPoint, &mountStat) < 0) {