1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
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. */
#include "priv.h"
#include <stdio.h>
#include <device/device.h>
#include <string.h>
#include <sys/reboot.h>
int diskfs_bootflags;
char *diskfs_bootflagarg;
/* 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 (diskfs_master_device, 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;
}
diskfs_bootflagarg = argv[1];
return devname;
}
|