# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # SUBDIRS= fstyp bootinstall all: TARGET= all install: TARGET= install clean: TARGET= clean clobber: TARGET= clobber catalog: TARGET= catalog .KEEP_STATE: .PARALLEL: $(SUBDIRS) all install clean clobber: $(SUBDIRS) catalog: $(SUBDIRS): FRC @cd $@; pwd; $(MAKE) $(TARGET) FRC: # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # FSTYPE= zfs LIBPROG= bootinstall SRCS= bootinstall.sh SUBDIRS= etc all : TARGET = all install : TARGET = install clean : TARGET = clean clobber : TARGET = clobber .KEEP_STATE: include ../../Makefile.fstype all: $(SUBDIRS) $(LIBPROG) install: $(SUBDIRS) clean: $(RM) $(LIBPROG) $(SUBDIRS): FRC @cd $@; pwd; $(MAKE) $(TARGET) FRC: #!/bin/ksh -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2015, Toomas Soome # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # PATH="/bin:/sbin:/usr/bin:/usr/sbin:${PATH}"; export PATH LOGGER="/bin/logger -t $0 -p daemon.notice" POOL="$1" DEV=$(echo "$2" | sed -e 's+/dsk/+/rdsk/+') if [ -z "${POOL}" -o -z "${DEV}" ]; then $LOGGER "Invalid usage" exit 1 fi CURPOOL=$(df -k / | awk 'NR == 2 {print $1}' | sed 's,/.*,,') if [ "$CURPOOL" != "$POOL" ] ; then $LOGGER "Modified pool must be current root pool" exit 1 fi /sbin/bootadm install-bootloader -f if [ $? != 0 ]; then $LOGGER "Failure installing boot block on ${DEV}" exit 1 fi exit 0 # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # .PARALLEL: include $(SRC)/cmd/Makefile.cmd CONF = SUNW,EC_zfs,ESC_ZFS_bootfs_vdev_attach,sysevent.conf CONFDIR = $(ROOTETC)/sysevent/config # utilize the predefined install target patterns in cmd/Makefile.targ by # overriding ROOTCMDDIR # ROOTCMDDIR = $(CONFDIR) FILEMODE = 0644 .KEEP_STATE: all clean clobber lint: install: $(CONF:%=$(CONFDIR)/%) include $(SRC)/cmd/Makefile.targ # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # EC_zfs ESC_ZFS_bootfs_vdev_attach SUNW - - - - /usr/lib/fs/zfs/bootinstall $pool_name $vdev_path # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright 2020 Joyent, Inc. # FSTYP_VERS=1 FSTYPE= zfs LIBPROG= fstyp.so.${FSTYP_VERS} include ../../../../lib/Makefile.lib include ../../Makefile.fstype # There should be a mapfile here MAPFILES = CFLAGS += $(C_PICFLAGS) CFLAGS += -I../../../../lib/libzutil/common DYNLIB= $(LIBPROG) LDLIBS += -lnvpair -lc -lzutil SRCS= ${LIBPROG:%.so.$(FSTYP_VERS)=%.c} CPPFLAGS += -DFSTYP_VERS=${FSTYP_VERS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 # # Override PMAP dependency # PMAP= # # Rules for making shared objects out of .c files. Works well if # we have a one-to-one mapping. Applies in all cases so far. # .SUFFIXES: .so.${FSTYP_VERS} ${SUFFIXES} .c.so.${FSTYP_VERS}: $(CC) $(CPPFLAGS) $(CFLAGS) $(DYNFLAGS) $(GSHARED) -o $@ $< $(LDLIBS) $(POST_PROCESS_SO) .KEEP_STATE: all: $(LIBPROG) install: all $(RM) $(ROOTLIBFSTYPE)/fstyp $(LN) $(ROOTUSRSBIN)/fstyp $(ROOTLIBFSTYPE)/fstyp cstyle: $(CSTYLE) $(SRCS) clean: ${RM} $(LIBPROG) clobber: clean /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Copyright 2020 Joyent, Inc. */ /* * libfstyp module for zfs */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct fstyp_zfs { int fd; nvlist_t *config; }; int fstyp_mod_init(int fd, off_t offset, fstyp_mod_handle_t *handle); void fstyp_mod_fini(fstyp_mod_handle_t handle); int fstyp_mod_ident(fstyp_mod_handle_t handle); int fstyp_mod_get_attr(fstyp_mod_handle_t handle, nvlist_t **attrp); int fstyp_mod_init(int fd, off_t offset, fstyp_mod_handle_t *handle) { struct fstyp_zfs *h; if (offset != 0) { return (FSTYP_ERR_OFFSET); } if ((h = calloc(1, sizeof (struct fstyp_zfs))) == NULL) { return (FSTYP_ERR_NOMEM); } h->fd = fd; *handle = (fstyp_mod_handle_t)h; return (0); } void fstyp_mod_fini(fstyp_mod_handle_t handle) { struct fstyp_zfs *h = (struct fstyp_zfs *)handle; if (h->config != NULL) { nvlist_free(h->config); } free(h); } int fstyp_mod_ident(fstyp_mod_handle_t handle) { struct fstyp_zfs *h = (struct fstyp_zfs *)handle; uint64_t state; char *str; uint64_t u64; char buf[64]; int num_labels = 0; if (zpool_read_label(h->fd, &h->config, &num_labels) != 0) { /* This is the only reason zpool_read_label() can fail */ VERIFY3S(errno, ==, ENOMEM); return (FSTYP_ERR_NOMEM); } if (num_labels == 0) return (FSTYP_ERR_NO_MATCH); if (nvlist_lookup_uint64(h->config, ZPOOL_CONFIG_POOL_STATE, &state) != 0 || state == POOL_STATE_DESTROYED) { nvlist_free(h->config); h->config = NULL; return (FSTYP_ERR_NO_MATCH); } /* add generic attributes */ (void) nvlist_add_boolean_value(h->config, "gen_clean", B_TRUE); if (nvlist_lookup_uint64(h->config, "guid", &u64) == 0) { (void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)u64); (void) nvlist_add_string(h->config, "gen_guid", buf); } if (nvlist_lookup_uint64(h->config, "version", &u64) == 0) { (void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)u64); (void) nvlist_add_string(h->config, "gen_version", buf); } if (nvlist_lookup_string(h->config, "name", &str) == 0) { (void) nvlist_add_string(h->config, "gen_volume_label", str); } return (0); } int fstyp_mod_get_attr(fstyp_mod_handle_t handle, nvlist_t **attrp) { struct fstyp_zfs *h = (struct fstyp_zfs *)handle; *attrp = h->config; return (0); }