diff options
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/lib/libstand/zfs/zfs.c | 210 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/part.c | 6 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/part.h | 3 | ||||
-rw-r--r-- | usr/src/boot/sys/sys/gpt.h | 10 | ||||
-rw-r--r-- | usr/src/test/util-tests/tests/date/date_test.ksh | 8 |
6 files changed, 28 insertions, 211 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index cf66bc1bc8..9d40ee8993 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2019.10.29.1 +BOOT_VERSION = $(LOADER_VERSION)-2019.11.04.1 diff --git a/usr/src/boot/lib/libstand/zfs/zfs.c b/usr/src/boot/lib/libstand/zfs/zfs.c index 018b43a8a0..9cdb90f6b4 100644 --- a/usr/src/boot/lib/libstand/zfs/zfs.c +++ b/usr/src/boot/lib/libstand/zfs/zfs.c @@ -108,9 +108,10 @@ zfs_open(const char *upath, struct open_file *f) return (EINVAL); /* allocate file system specific data structure */ - fp = malloc(sizeof(struct file)); - bzero(fp, sizeof(struct file)); - f->f_fsdata = (void *)fp; + fp = calloc(1, sizeof (struct file)); + if (fp == NULL) + return (ENOMEM); + f->f_fsdata = fp; rc = zfs_lookup(mount, upath, &fp->f_dnode); fp->f_seekp = 0; @@ -127,9 +128,7 @@ zfs_close(struct open_file *f) struct file *fp = (struct file *)f->f_fsdata; dnode_cache_obj = 0; - f->f_fsdata = (void *)0; - if (fp == (struct file *)0) - return (0); + f->f_fsdata = NULL; free(fp); return (0); @@ -248,7 +247,9 @@ zfs_readdir(struct open_file *f, struct dirent *d) return (rc); fp->f_seekp = bsize; - fp->f_zap_leaf = (zap_leaf_phys_t *)malloc(bsize); + fp->f_zap_leaf = malloc(bsize); + if (fp->f_zap_leaf == NULL) + return (ENOMEM); rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, fp->f_zap_leaf, @@ -622,8 +623,11 @@ zfs_dev_open(struct open_file *f, ...) spa = spa_find_by_guid(dev->pool_guid); if (!spa) return (ENXIO); - mount = malloc(sizeof(*mount)); - rv = zfs_mount(spa, dev->root_guid, mount); + mount = malloc(sizeof (*mount)); + if (mount == NULL) + rv = ENOMEM; + else + rv = zfs_mount(spa, dev->root_guid, mount); if (rv != 0) { free(mount); return (rv); @@ -845,191 +849,3 @@ zfs_list(const char *name) return (zfs_list_dataset(spa, objid)); } - -#ifdef __FreeBSD__ -void -init_zfs_bootenv(char *currdev) -{ - char *beroot; - - if (strlen(currdev) == 0) - return; - if(strncmp(currdev, "zfs:", 4) != 0) - return; - /* Remove the trailing : */ - currdev[strlen(currdev) - 1] = '\0'; - setenv("zfs_be_active", currdev, 1); - setenv("zfs_be_currpage", "1", 1); - /* Forward past zfs: */ - currdev = strchr(currdev, ':'); - currdev++; - /* Remove the last element (current bootenv) */ - beroot = strrchr(currdev, '/'); - if (beroot != NULL) - beroot[0] = '\0'; - beroot = currdev; - setenv("zfs_be_root", beroot, 1); -} - -int -zfs_bootenv(const char *name) -{ - static char poolname[ZFS_MAXNAMELEN], *dsname, *root; - char becount[4]; - uint64_t objid; - spa_t *spa; - int len, rv, pages, perpage, currpage; - - if (name == NULL) - return (EINVAL); - if ((root = getenv("zfs_be_root")) == NULL) - return (EINVAL); - - if (strcmp(name, root) != 0) { - if (setenv("zfs_be_root", name, 1) != 0) - return (ENOMEM); - } - - SLIST_INIT(&zfs_be_head); - zfs_env_count = 0; - len = strlen(name); - dsname = strchr(name, '/'); - if (dsname != NULL) { - len = dsname - name; - dsname++; - } else - dsname = ""; - memcpy(poolname, name, len); - poolname[len] = '\0'; - - spa = spa_find_by_name(poolname); - if (!spa) - return (ENXIO); - rv = zfs_lookup_dataset(spa, dsname, &objid); - if (rv != 0) - return (rv); - rv = zfs_callback_dataset(spa, objid, zfs_belist_add); - - /* Calculate and store the number of pages of BEs */ - perpage = (ZFS_BE_LAST - ZFS_BE_FIRST + 1); - pages = (zfs_env_count / perpage) + ((zfs_env_count % perpage) > 0 ? 1 : 0); - snprintf(becount, 4, "%d", pages); - if (setenv("zfs_be_pages", becount, 1) != 0) - return (ENOMEM); - - /* Roll over the page counter if it has exceeded the maximum */ - currpage = strtol(getenv("zfs_be_currpage"), NULL, 10); - if (currpage > pages) { - if (setenv("zfs_be_currpage", "1", 1) != 0) - return (ENOMEM); - } - - /* Populate the menu environment variables */ - zfs_set_env(); - - /* Clean up the SLIST of ZFS BEs */ - while (!SLIST_EMPTY(&zfs_be_head)) { - zfs_be = SLIST_FIRST(&zfs_be_head); - SLIST_REMOVE_HEAD(&zfs_be_head, entries); - free(zfs_be); - } - - return (rv); -} - -int -zfs_belist_add(const char *name, uint64_t value __unused) -{ - - /* Skip special datasets that start with a $ character */ - if (strncmp(name, "$", 1) == 0) { - return (0); - } - /* Add the boot environment to the head of the SLIST */ - zfs_be = malloc(sizeof(struct zfs_be_entry)); - if (zfs_be == NULL) { - return (ENOMEM); - } - zfs_be->name = name; - SLIST_INSERT_HEAD(&zfs_be_head, zfs_be, entries); - zfs_env_count++; - - return (0); -} - -int -zfs_set_env(void) -{ - char envname[32], envval[256]; - char *beroot, *pagenum; - int rv, page, ctr; - - beroot = getenv("zfs_be_root"); - if (beroot == NULL) { - return (1); - } - - pagenum = getenv("zfs_be_currpage"); - if (pagenum != NULL) { - page = strtol(pagenum, NULL, 10); - } else { - page = 1; - } - - ctr = 1; - rv = 0; - zfs_env_index = ZFS_BE_FIRST; - SLIST_FOREACH_SAFE(zfs_be, &zfs_be_head, entries, zfs_be_tmp) { - /* Skip to the requested page number */ - if (ctr <= ((ZFS_BE_LAST - ZFS_BE_FIRST + 1) * (page - 1))) { - ctr++; - continue; - } - - snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); - snprintf(envval, sizeof(envval), "%s", zfs_be->name); - rv = setenv(envname, envval, 1); - if (rv != 0) { - break; - } - - snprintf(envname, sizeof(envname), "bootenvansi_caption[%d]", zfs_env_index); - rv = setenv(envname, envval, 1); - if (rv != 0){ - break; - } - - snprintf(envname, sizeof(envname), "bootenvmenu_command[%d]", zfs_env_index); - rv = setenv(envname, "set_bootenv", 1); - if (rv != 0){ - break; - } - - snprintf(envname, sizeof(envname), "bootenv_root[%d]", zfs_env_index); - snprintf(envval, sizeof(envval), "zfs:%s/%s", beroot, zfs_be->name); - rv = setenv(envname, envval, 1); - if (rv != 0){ - break; - } - - zfs_env_index++; - if (zfs_env_index > ZFS_BE_LAST) { - break; - } - - } - - for (; zfs_env_index <= ZFS_BE_LAST; zfs_env_index++) { - snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); - (void)unsetenv(envname); - snprintf(envname, sizeof(envname), "bootenvansi_caption[%d]", zfs_env_index); - (void)unsetenv(envname); - snprintf(envname, sizeof(envname), "bootenvmenu_command[%d]", zfs_env_index); - (void)unsetenv(envname); - snprintf(envname, sizeof(envname), "bootenv_root[%d]", zfs_env_index); - (void)unsetenv(envname); - } - - return (rv); -} -#endif diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c index fa3ec75e0f..23c3dce452 100644 --- a/usr/src/boot/sys/boot/common/part.c +++ b/usr/src/boot/sys/boot/common/part.c @@ -64,6 +64,7 @@ static const uuid_t gpt_uuid_illumos_boot = GPT_ENT_TYPE_ILLUMOS_BOOT; static const uuid_t gpt_uuid_illumos_ufs = GPT_ENT_TYPE_ILLUMOS_UFS; static const uuid_t gpt_uuid_illumos_zfs = GPT_ENT_TYPE_ILLUMOS_ZFS; static const uuid_t gpt_uuid_reserved = GPT_ENT_TYPE_RESERVED; +static const uuid_t gpt_uuid_apple_apfs = GPT_ENT_TYPE_APPLE_APFS; #endif struct pentry { @@ -114,7 +115,8 @@ static struct parttypes { { PART_VTOC_USR, "usr" }, { PART_VTOC_STAND, "stand" }, { PART_VTOC_VAR, "var" }, - { PART_VTOC_HOME, "home" } + { PART_VTOC_HOME, "home" }, + { PART_APFS, "APFS" } }; const char * @@ -168,6 +170,8 @@ gpt_parttype(uuid_t type) return (PART_ILLUMOS_ZFS); else if (uuid_equal(&type, &gpt_uuid_reserved, NULL)) return (PART_RESERVED); + else if (uuid_equal(&type, &gpt_uuid_apple_apfs, NULL)) + return (PART_APFS); return (PART_UNKNOWN); } diff --git a/usr/src/boot/sys/boot/common/part.h b/usr/src/boot/sys/boot/common/part.h index 2881c78b64..bed69c4484 100644 --- a/usr/src/boot/sys/boot/common/part.h +++ b/usr/src/boot/sys/boot/common/part.h @@ -64,7 +64,8 @@ enum partition_type { PART_VTOC_BACKUP, PART_VTOC_STAND, PART_VTOC_VAR, - PART_VTOC_HOME + PART_VTOC_HOME, + PART_APFS }; struct ptable_entry { diff --git a/usr/src/boot/sys/sys/gpt.h b/usr/src/boot/sys/sys/gpt.h index b04d86312d..bb39876e35 100644 --- a/usr/src/boot/sys/sys/gpt.h +++ b/usr/src/boot/sys/sys/gpt.h @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. * @@ -22,8 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _SYS_GPT_H_ @@ -151,11 +149,13 @@ struct gpt_ent { #define GPT_ENT_TYPE_APPLE_RAID_OFFLINE \ {0x52414944,0x5f4f,0x11aa,0xaa,0x22,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_APPLE_LABEL \ - {0x4C616265,0x6c00,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} + {0x4C616265,0x6c00,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_APPLE_TV_RECOVERY \ - {0x5265636f,0x7665,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} + {0x5265636f,0x7665,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_APPLE_CORE_STORAGE \ {0x53746f72,0x6167,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} +#define GPT_ENT_TYPE_APPLE_APFS \ + {0x7C3457EF,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} #define GPT_ENT_TYPE_NETBSD_FFS \ {0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} diff --git a/usr/src/test/util-tests/tests/date/date_test.ksh b/usr/src/test/util-tests/tests/date/date_test.ksh index dc410ef40a..2cabc2848e 100644 --- a/usr/src/test/util-tests/tests/date/date_test.ksh +++ b/usr/src/test/util-tests/tests/date/date_test.ksh @@ -11,18 +11,14 @@ # # -# Copyright (c) 2017, Joyent, Inc. +# Copyright 2019 Joyent, Inc. # # # Basic tests of date -r. # -# -# Make sure that we're executing in the C locale and that a given user's -# locale doesn't impact this test. -# -export LANG=C +export LC_ALL=C date_arg0="$(basename $0)" date_prog=/usr/bin/date |