Print this page
*** NO COMMENTS ***

*** 21,38 **** /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ /* ! * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ /* * System includes */ #include <assert.h> #include <errno.h> #include <libintl.h> #include <libnvpair.h> #include <libzfs.h> #include <stdio.h> #include <stdlib.h> --- 21,39 ---- /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ /* ! * Copyright 2013 Nexenta Systems, Inc. All rights reserved. */ /* * System includes */ #include <assert.h> #include <errno.h> + #include <libgen.h> #include <libintl.h> #include <libnvpair.h> #include <libzfs.h> #include <stdio.h> #include <stdlib.h>
*** 324,342 **** --- 325,358 ---- gen_tmp_altroot = B_TRUE; } else { tmp_altroot = *altroot; } + md.altroot = tmp_altroot; + md.shared_fs = flags & BE_MOUNT_FLAG_SHARED_FS; + md.shared_rw = flags & BE_MOUNT_FLAG_SHARED_RW; + /* Mount the BE's root file system */ + if (getzoneid() == GLOBAL_ZONEID) { if ((ret = be_mount_root(zhp, tmp_altroot)) != BE_SUCCESS) { be_print_err(gettext("be_mount: failed to " "mount BE root file system\n")); if (gen_tmp_altroot) free(tmp_altroot); ZFS_CLOSE(zhp); return (ret); } + } else { + /* Legacy mount the zone root dataset */ + if ((ret = be_mount_zone_root(zhp, &md)) != BE_SUCCESS) { + be_print_err(gettext("be_mount: failed to " + "mount BE zone root file system\n")); + free(md.altroot); + ZFS_CLOSE(zhp); + return (ret); + } + } /* Iterate through BE's children filesystems */ if ((err = zfs_iter_filesystems(zhp, be_mount_callback, tmp_altroot)) != 0) { be_print_err(gettext("be_mount: failed to "
*** 345,358 **** free(tmp_altroot); ZFS_CLOSE(zhp); return (err); } - md.altroot = tmp_altroot; - md.shared_fs = flags & BE_MOUNT_FLAG_SHARED_FS; - md.shared_rw = flags & BE_MOUNT_FLAG_SHARED_RW; - /* * Mount shared file systems if mount flag says so. */ if (md.shared_fs) { /* --- 361,370 ----
*** 526,539 **** --- 538,558 ---- ZFS_CLOSE(zhp); return (zret); } /* Unmount this BE's root filesystem */ + if (getzoneid() == GLOBAL_ZONEID) { if ((ret = be_unmount_root(zhp, &ud)) != BE_SUCCESS) { ZFS_CLOSE(zhp); return (ret); } + } else { + if ((ret = be_unmount_zone_root(zhp, &ud)) != BE_SUCCESS) { + ZFS_CLOSE(zhp); + return (ret); + } + } ZFS_CLOSE(zhp); return (BE_SUCCESS); }
*** 551,560 **** --- 570,580 ---- * Semi-private (library wide use only) */ int be_mount_zone_root(zfs_handle_t *zhp, be_mount_data_t *md) { + struct stat buf; char mountpoint[MAXPATHLEN]; int err = 0; /* Get mountpoint property of dataset */ if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint,
*** 574,583 **** --- 594,613 ---- be_print_err(gettext("be_mount_zone_root: " "zone root dataset mountpoint is not 'legacy'\n")); return (BE_ERR_ZONE_ROOT_NOT_LEGACY); } + /* Create the mountpoint if it doesn't exist */ + if (lstat(md->altroot, &buf) != 0) { + if (mkdirp(md->altroot, 0755) != 0) { + err = errno; + be_print_err(gettext("be_mount_zone_root: failed " + "to create mountpoint %s\n"), md->altroot); + return (errno_to_be_err(err)); + } + } + /* * Legacy mount the zone root dataset. * * As a workaround for 6176743, we mount the zone's root with the * MS_OVERLAY option in case an alternate BE is mounted, and we're