summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-02-08 18:04:54 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-02-08 18:04:54 +0000
commit3c42af1fe5bc3ca618a4bd677f2f7f476c9c307b (patch)
tree19aefc2547c01226dfa496f37d9815b3c16d0b7f /libdiskfs
parent3a1b50c24804f0e5135a753b7f66df731b174b17 (diff)
Initial revision
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/boot-parse.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/libdiskfs/boot-parse.c b/libdiskfs/boot-parse.c
new file mode 100644
index 00000000..342e9486
--- /dev/null
+++ b/libdiskfs/boot-parse.c
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 1993, 1994 Free Software Foundation
+
+This file is part of the GNU Hurd.
+
+The GNU Hurd is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+The GNU Hurd is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU Hurd; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Written by Michael I. Bushnell. */
+
+/* Call this if the bootstrap port is null and you want to support
+ being a bootstrap filesystem. ARGC and ARGV should be as passed
+ to main. If the arguments are not in the proper format, an
+ error message will be printed on stderr and exit called. Otherwise,
+ diskfs_priv_host, diskfs_master_device, and diskfs_bootflags will be
+ set and the Mach kernel name of the bootstrap device will be
+ returned. */
+char *
+diskfs_parse_bootargs (int argc, char **argv)
+{
+ char *devname;
+
+ /* The arguments, as passed by the kernel, are as follows:
+ -<flags> hostport deviceport rootname */
+
+ if (argc != 5 || argv[1][0] != '-')
+ {
+ fprintf (stderr, "Usage: %s: -[qsdnx] hostport deviceport rootname\n",
+ program_invocation_name);
+ exit (1);
+ }
+ diskfs_host_priv = atoi (argv[2]);
+ diskfs_master_device = atoi (argv[3]);
+ devname = argv[4];
+
+ (void) device_open (master_device_port, D_WRITE, "console", &con);
+ stderr = stdout = mach_open_devstream (con, "w");
+ stdin = mach_open_devstream (con, "r");
+
+ /* For now... */
+ /* readonly = 1; */
+
+ /* The possible flags are
+ q -- RB_ASKNAME
+ s -- RB_SINGLE
+ d -- RB_KDB
+ n -- RB_INITNAME */
+ /* q tells us to ask about what device to use, n
+ about what to run as init. */
+
+ diskfs_bootflags = 0;
+ if (index (argv[1], 'q'))
+ diskfs_bootflags |= RB_ASKNAME;
+ if (index (argv[1], 's'))
+ diskfs_bootflags |= RB_SINGLE;
+ if (index (argv[1], 'd'))
+ diskfs_bootflags |= RB_KDB;
+ if (index (argv[1], 'n'))
+ diskfs_bootflags |= RB_INITNAME;
+
+ if (diskfs_bootflags & RB_ASKNAME)
+ {
+ char *tmp;
+ printf ("Bootstap filesystem device name [%s]: ", devname);
+ fflush (stdout);
+ scanf ("%a\n", &tmp);
+ if (*tmp)
+ devname = tmp;
+ }
+
+ return devname;
+}
+