diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2018-12-05 19:18:16 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2018-12-05 19:18:16 +0000 |
commit | 827c3852fed2515cf2a557c88fe4b3ecfa01b752 (patch) | |
tree | ab92154d81c35e68277ec1ba1db318b4b04ccc8c | |
parent | 749cdf6f3ba78a5c02b249265a08c29cf999e0cf (diff) | |
download | src-827c3852fed2515cf2a557c88fe4b3ecfa01b752.tar.gz src-827c3852fed2515cf2a557c88fe4b3ecfa01b752.zip |
Further simplify arguments to init.
With the removal of BOOTCDROM and fastboot support, this code always
passed "-s" or "--". The latter simply terminates getopt(3) processing
in init so we only need to pass "-s" in the single user case, or nothing
in other cases.
The passing of "--" seems to have been done to ensure that the number of
arguments passed to init was always the same and thus that argc was the
same.
Also GC the write-only variable pathlen (not in reviewed version).
Reviewed by: kib, jhb
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D18441
Notes
Notes:
svn path=/head/; revision=341604
-rw-r--r-- | sys/kern/init_main.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index a6d32bc50dfe..39c6b7f65178 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -718,9 +718,7 @@ static void start_init(void *dummy) { struct image_args args; - int options, error; - size_t pathlen; - char flags[8], *flagp; + int error; char *var, *path; char *free_init_path, *tmp_init_path; struct thread *td; @@ -744,7 +742,6 @@ start_init(void *dummy) free_init_path = tmp_init_path = strdup(init_path, M_TEMP); while ((path = strsep(&tmp_init_path, ":")) != NULL) { - pathlen = strlen(path) + 1; if (bootverbose) printf("start_init: trying %s\n", path); @@ -757,23 +754,11 @@ start_init(void *dummy) error = exec_args_add_fname(&args, path, UIO_SYSSPACE); if (error != 0) panic("%s: Can't add fname %d", __func__, error); - error = exec_args_add_arg(&args, path, UIO_SYSSPACE); if (error != 0) panic("%s: Can't add argv[0] %d", __func__, error); - - options = 0; - flagp = &flags[0]; - *flagp++ = '-'; - if (boothowto & RB_SINGLE) { - *flagp++ = 's'; - options++; - } - if (options == 0) - *flagp++ = '-'; - *flagp++ = 0; - KASSERT(flagp <= &flags[0] + sizeof(flags), ("Overran flags")); - error = exec_args_add_arg(&args, flags, UIO_SYSSPACE); + if (boothowto & RB_SINGLE) + error = exec_args_add_arg(&args, "-s", UIO_SYSSPACE); if (error != 0) panic("%s: Can't add argv[0] %d", __func__, error); |