diff options
author | Joshua M. Clulow <josh@sysmgr.org> | 2021-03-09 22:10:34 -0800 |
---|---|---|
committer | Joshua M. Clulow <josh@sysmgr.org> | 2021-03-09 22:11:24 -0800 |
commit | f6c47fdeea63a9c5d1abefdffb93d3f87e12b7d0 (patch) | |
tree | 2132819ab094c681a812dcec50367463f1f172ac | |
parent | 2587b3a0593a431a99cc2dc78bf1034e672a35e2 (diff) | |
download | illumos-gate-f6c47fdeea63a9c5d1abefdffb93d3f87e12b7d0.tar.gz |
13605 ramdisk systems have no boot_archive
Reviewed by: Andy Fiddaman <andy@omnios.org>
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/cmd/Makefile.cmd | 1 | ||||
-rw-r--r-- | usr/src/cmd/boot/scripts/boot-archive-update.ksh | 10 | ||||
-rw-r--r-- | usr/src/cmd/svc/Makefile | 6 | ||||
-rw-r--r-- | usr/src/cmd/svc/configd/Makefile | 8 | ||||
-rw-r--r-- | usr/src/cmd/svc/lsvcrun/Makefile | 11 | ||||
-rw-r--r-- | usr/src/cmd/svc/mfstscan/Makefile | 11 | ||||
-rw-r--r-- | usr/src/cmd/svc/milestone/boot-archive | 10 | ||||
-rw-r--r-- | usr/src/cmd/svc/rootisramdisk/Makefile | 37 | ||||
-rw-r--r-- | usr/src/cmd/svc/rootisramdisk/rootisramdisk.c | 86 | ||||
-rw-r--r-- | usr/src/cmd/svc/shell/smf_include.sh | 10 | ||||
-rw-r--r-- | usr/src/cmd/svc/startd/Makefile | 4 | ||||
-rw-r--r-- | usr/src/pkg/manifests/SUNWcs.mf | 2 |
12 files changed, 163 insertions, 33 deletions
diff --git a/usr/src/cmd/Makefile.cmd b/usr/src/cmd/Makefile.cmd index b616d6a7ac..d346b79b74 100644 --- a/usr/src/cmd/Makefile.cmd +++ b/usr/src/cmd/Makefile.cmd @@ -162,6 +162,7 @@ ROOTPROG32= $(PROG:%=$(ROOTBIN32)/%) ROOTCMD64= $(PROG:%=$(ROOTCMDDIR64)/%) ROOTUSRSBINPROG32= $(PROG:%=$(ROOTUSRSBIN32)/%) ROOTUSRSBINPROG64= $(PROG:%=$(ROOTUSRSBIN64)/%) +ROOTLIBSVCBINPROG= $(PROG:%=$(ROOTLIBSVCBIN)/%) # Symlink rules for /usr/ccs/bin commands. Note, those commands under # the rule of the linker area, are controlled by a different set of diff --git a/usr/src/cmd/boot/scripts/boot-archive-update.ksh b/usr/src/cmd/boot/scripts/boot-archive-update.ksh index deae20e814..24810a22db 100644 --- a/usr/src/cmd/boot/scripts/boot-archive-update.ksh +++ b/usr/src/cmd/boot/scripts/boot-archive-update.ksh @@ -23,6 +23,7 @@ # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2021 Oxide Computer Company # . /lib/svc/share/smf_include.sh @@ -30,7 +31,14 @@ UPDATEFILE=/etc/svc/volatile/boot_archive_safefile_update -smf_is_globalzone || exit $SMF_EXIT_OK +if smf_is_nonglobalzone || smf_root_is_ramdisk; then + # + # Boot archives only exist in the global zone of persistent root + # systems, but this is either a non-global zone or a system booted from + # a ramdisk image. + # + exit $SMF_EXIT_OK +fi if [ `uname -p` = "i386" ]; then # on x86 get rid of transient reboot entry in the GRUB menu diff --git a/usr/src/cmd/svc/Makefile b/usr/src/cmd/svc/Makefile index 6bf41324e1..43c917f534 100644 --- a/usr/src/cmd/svc/Makefile +++ b/usr/src/cmd/svc/Makefile @@ -25,7 +25,8 @@ include ../Makefile.cmd -SUBDIR_CMD= lsvcrun mfstscan servinfo svcadm svccfg svcprop svcs +SUBDIR_CMD= lsvcrun mfstscan servinfo svcadm svccfg svcprop svcs \ + rootisramdisk SUBDIR_DAEMON= configd startd SUBDIR_REPO= milestone profile seed SUBDIR_MISC= shell @@ -35,7 +36,6 @@ all := TARGET = all install := TARGET = install clean := TARGET = clean clobber := TARGET = clobber -lint := TARGET = lint _msg := TARGET = _msg .KEEP_STATE: @@ -58,7 +58,7 @@ ROOTCLASSACTIONS = $(CLASSACTIONS:%=$(ROOT)/usr/sadm/install/scripts/%) install: $(ROOTDTDS) $(ROOTCLASSACTIONS) -all install lint clean clobber: $(SUBDIRS) +all install clean clobber: $(SUBDIRS) _msg: $(SUBDIR_CMD) startd diff --git a/usr/src/cmd/svc/configd/Makefile b/usr/src/cmd/svc/configd/Makefile index 19ce51199a..9511b53fab 100644 --- a/usr/src/cmd/svc/configd/Makefile +++ b/usr/src/cmd/svc/configd/Makefile @@ -50,8 +50,6 @@ NATIVE_BUILD=$(POUND_SIGN) $(NATIVE_BUILD)PROG = $(MYPROG:%=%-native) $(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o) -ROOTCMDDIR= $(ROOT)/lib/svc/bin - MYCPPFLAGS = -I. -I../common -I../../../common/svc \ -I$(ROOT)/usr/include/sqlite-sys -D_REENTRANT CPPFLAGS += $(MYCPPFLAGS) @@ -75,7 +73,7 @@ LIBUUTIL = $(SRC)/lib/libuutil LIBSCF = $(SRC)/lib/libscf SCRIPTFILE = restore_repository -ROOTSCRIPTFILE = $(ROOTCMDDIR)/$(SCRIPTFILE) +ROOTSCRIPTFILE = $(ROOTLIBSVCBIN)/$(SCRIPTFILE) # # Native variant (used in ../seed). @@ -121,10 +119,10 @@ $(PROG): $(OBJS) $(COMPILE.c) -o $@ $< $(POST_PROCESS_O) -$(ROOTCMDDIR)/%: %.sh +$(ROOTLIBSVCBIN)/%: %.sh $(INS.rename) -install: all $(ROOTCMD) $(ROOTVARSADMFILE) $(ROOTSCRIPTFILE) +install: all $(ROOTLIBSVCBINPROG) $(ROOTVARSADMFILE) $(ROOTSCRIPTFILE) clean: FRC $(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) diff --git a/usr/src/cmd/svc/lsvcrun/Makefile b/usr/src/cmd/svc/lsvcrun/Makefile index 91634e8b32..ed94b1892a 100644 --- a/usr/src/cmd/svc/lsvcrun/Makefile +++ b/usr/src/cmd/svc/lsvcrun/Makefile @@ -27,9 +27,7 @@ PROG = lsvcrun OBJS = lsvcrun.o SRCS = $(OBJS:%.o=%.c) -POFILES = $(OBJS:.o=.po) - -ROOTLIBSVCBINPROG = $(ROOT)/lib/svc/bin/$(PROG) +POFILES = $(OBJS:.o=.po) include ../../Makefile.cmd @@ -37,8 +35,6 @@ LDLIBS += -lcontract -lscf -luutil CERRWARN += -_gcc=-Wno-parentheses CERRWARN += $(CNOWARN_UNINIT) -lint := LINTFLAGS = -ux - .KEEP_STATE: all: $(PROG) @@ -49,12 +45,7 @@ $(PROG): $(OBJS) install: all $(ROOTLIBSVCBINPROG) -$(ROOTLIBSVCBIN)/%: % - $(INS.file) - clean: $(RM) $(OBJS) -lint: lint_SRCS - include ../../Makefile.targ diff --git a/usr/src/cmd/svc/mfstscan/Makefile b/usr/src/cmd/svc/mfstscan/Makefile index 64bcea95b8..7d0071dc52 100644 --- a/usr/src/cmd/svc/mfstscan/Makefile +++ b/usr/src/cmd/svc/mfstscan/Makefile @@ -33,9 +33,7 @@ SRCS = mfstscan.c \ ../common/manifest_find.c \ ../common/manifest_hash.c -POFILES = $(SRCS:.c=.po) - -ROOTLIBSVCBINPROG = $(ROOT)/lib/svc/bin/$(PROG) +POFILES = $(SRCS:.c=.po) include ../../Makefile.cmd @@ -47,8 +45,6 @@ CLOBBERFILES += $(POFILES) CERRWARN += $(CNOWARN_UNINIT) CERRWARN += -_gcc=-Wno-unused-label -lint := LINTFLAGS = -ux -erroff=E_GLOBAL_COULD_BE_STATIC2 - .KEEP_STATE: all: $(PROG) @@ -62,14 +58,9 @@ $(POFILE): $(POFILES) install: all $(ROOTLIBSVCBINPROG) -$(ROOTLIBSVCBIN)/%: % - $(INS.file) - clean: $(RM) $(OBJS) -lint: lint_SRCS - %.o: ../common/%.c $(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK) $(POST_PROCESS_O) diff --git a/usr/src/cmd/svc/milestone/boot-archive b/usr/src/cmd/svc/milestone/boot-archive index bdf6c0dc9b..b7c859c1c8 100644 --- a/usr/src/cmd/svc/milestone/boot-archive +++ b/usr/src/cmd/svc/milestone/boot-archive @@ -22,6 +22,7 @@ # # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2021 Oxide Computer Company # . /lib/svc/share/smf_include.sh @@ -30,7 +31,14 @@ FILELIST=/etc/svc/volatile/boot_archive_filelist UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update -smf_is_globalzone || exit $SMF_EXIT_OK +if smf_is_nonglobalzone || smf_root_is_ramdisk; then + # + # Boot archives only exist in the global zone of persistent root + # systems, but this is either a non-global zone or a system booted from + # a ramdisk image. + # + exit $SMF_EXIT_OK +fi # # Now check the archive. diff --git a/usr/src/cmd/svc/rootisramdisk/Makefile b/usr/src/cmd/svc/rootisramdisk/Makefile new file mode 100644 index 0000000000..be6888b2d6 --- /dev/null +++ b/usr/src/cmd/svc/rootisramdisk/Makefile @@ -0,0 +1,37 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Oxide Computer Company +# + +PROG = rootisramdisk +OBJS = rootisramdisk.o +SRCS = $(OBJS:%.o=%.c) + +include ../../Makefile.cmd +include ../../Makefile.cmd.64 +include ../../Makefile.ctf + +.KEEP_STATE: + +all: $(PROG) + +$(PROG): $(OBJS) + $(LINK.c) -o $@ $(OBJS) $(LDLIBS) + $(POST_PROCESS) + +install: all $(ROOTLIBSVCBINPROG) + +clean: + $(RM) $(OBJS) + +include ../../Makefile.targ diff --git a/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c b/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c new file mode 100644 index 0000000000..353be0141a --- /dev/null +++ b/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c @@ -0,0 +1,86 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 Oxide Computer Company + */ + +/* + * rootisramdisk: a helper program for smf_root_is_ramdisk() in + * "/lib/svc/share/smf_include.sh". Exits zero if the root file system is + * mounted from a ramdisk, or non-zero if not, or if we hit an error condition. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> +#include <fcntl.h> +#include <err.h> +#include <limits.h> +#include <string.h> +#include <sys/modctl.h> +#include <sys/types.h> +#include <sys/mkdev.h> +#include <sys/stat.h> + +#define EXIT_USAGE 2 +#define EXIT_NOT_RAMDISK 3 + +bool g_verbose = false; + +static bool +root_is_ramdisk(void) +{ + struct stat st; + major_t maj; + char driver[PATH_MAX + 1]; + + if (stat("/", &st) != 0) { + err(EXIT_FAILURE, "stat"); + } + + maj = major(st.st_dev); + if (g_verbose) { + fprintf(stderr, "major = %lu\n", (long unsigned)maj); + } + + if (modctl(MODGETNAME, driver, sizeof (driver), &maj) != 0) { + err(EXIT_FAILURE, "modctl"); + } + + if (g_verbose) { + fprintf(stderr, "driver = %s\n", driver); + } + + return (strcmp(driver, "ramdisk") == 0); +} + +int +main(int argc, char *argv[]) +{ + int c; + + while ((c = getopt(argc, argv, ":v")) != -1) { + switch (c) { + case 'v': + g_verbose = true; + break; + case ':': + errx(EXIT_USAGE, "-%c requires an operand", optopt); + break; + case '?': + errx(EXIT_USAGE, "-%c unknown", optopt); + break; + } + } + + return (root_is_ramdisk() ? EXIT_SUCCESS : EXIT_NOT_RAMDISK); +} diff --git a/usr/src/cmd/svc/shell/smf_include.sh b/usr/src/cmd/svc/shell/smf_include.sh index 4acbed7d90..25bffca1bf 100644 --- a/usr/src/cmd/svc/shell/smf_include.sh +++ b/usr/src/cmd/svc/shell/smf_include.sh @@ -24,6 +24,7 @@ # Use is subject to license terms. # Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2012 Joyent, Inc. All rights reserved. +# Copyright 2021 Oxide Computer Company # smf_present () { @@ -75,6 +76,15 @@ smf_is_nonglobalzone() { return 1 } +# smf_root_is_ramdisk +# +# Returns zero (success) if the system root file system is mounted from a +# ramdisk, non-zero otherwise. +# +smf_root_is_ramdisk() { + /lib/svc/bin/rootisramdisk +} + # smf_configure_ip # # Returns zero (success) if this zone needs IP to be configured i.e. diff --git a/usr/src/cmd/svc/startd/Makefile b/usr/src/cmd/svc/startd/Makefile index 8b15034344..bfd2ad2a15 100644 --- a/usr/src/cmd/svc/startd/Makefile +++ b/usr/src/cmd/svc/startd/Makefile @@ -62,8 +62,6 @@ POFILES = $(OBJS:%.o=%.po) \ include ../../Makefile.cmd include ../../Makefile.ctf -ROOTCMDDIR= $(ROOT)/lib/svc/bin - $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG CFLAGS += $(CCVERBOSE) CPPFLAGS += -I. -I../common @@ -131,7 +129,7 @@ $(PROG): $(ALLOBJS) $(POFILE): $(POFILES) cat $(POFILES) > $(POFILE) -install: all $(ROOTCMD) +install: all $(ROOTLIBSVCBINPROG) clean: $(RM) $(ALLOBJS) diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index ed17267840..70a52d058e 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -29,6 +29,7 @@ # Copyright 2019 Joyent, Inc. # Copyright (c) 2011, 2015 by Delphix. All rights reserved. # Copyright 2021 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2021 Oxide Computer Company # <include SUNWcs.man1.inc> @@ -482,6 +483,7 @@ file path=lib/inet/nwamd mode=0555 file path=lib/svc/bin/lsvcrun group=sys mode=0555 file path=lib/svc/bin/mfstscan group=sys mode=0555 file path=lib/svc/bin/restore_repository group=sys mode=0555 +file path=lib/svc/bin/rootisramdisk group=sys mode=0555 file path=lib/svc/bin/sqlite group=sys mode=0555 file path=lib/svc/bin/svc.configd group=sys mode=0555 file path=lib/svc/bin/svc.ipfd group=sys mode=0555 |