Print this page
4220 beadm mount of old BE with zones fails "Read only filesystem"
4235 beadm(1M) mount options undocumented in man page


 365 
 366         /*
 367          * Mount shared file systems if mount flag says so.
 368          */
 369         if (md.shared_fs) {
 370                 /*
 371                  * Mount all ZFS file systems not under the BE's root dataset
 372                  */
 373                 (void) zpool_iter(g_zfs, zpool_shared_fs_callback, &md);
 374 
 375                 /* TODO: Mount all non-ZFS file systems - Not supported yet */
 376         }
 377 
 378         /*
 379          * If we're in the global zone and the global zone has a valid uuid,
 380          * mount all supported non-global zones.
 381          */
 382         if (getzoneid() == GLOBAL_ZONEID &&
 383             !(flags & BE_MOUNT_FLAG_NO_ZONES) &&
 384             be_get_uuid(bt.obe_root_ds, &uu) == BE_SUCCESS) {
 385                 if ((ret = be_mount_zones(zhp, &md)) != BE_SUCCESS) {
 386                         (void) _be_unmount(bt.obe_name, 0);
 387                         if (gen_tmp_altroot)
 388                                 free(tmp_altroot);
 389                         ZFS_CLOSE(zhp);
 390                         return (ret);
 391                 }
 392         }
 393 
 394         ZFS_CLOSE(zhp);
 395 
 396         /*
 397          * If a NULL altroot was passed in, pass the generated altroot
 398          * back to the caller in altroot.
 399          */
 400         if (gen_tmp_altroot)

 401                 *altroot = tmp_altroot;



 402 
 403         return (BE_SUCCESS);
 404 }
 405 
 406 /*
 407  * Function:    _be_unmount
 408  * Description: Unmount a BE.
 409  * Parameters:
 410  *              be_name - pointer to name of BE to unmount.
 411  *              flags - flags for unmounting the BE.
 412  * Returns:
 413  *              BE_SUCCESS - Success
 414  *              be_errno_t - Failure
 415  * Scope:
 416  *              Semi-private (library wide use only)
 417  */
 418 int
 419 _be_unmount(char *be_name, int flags)
 420 {
 421         be_transaction_data_t   bt = { 0 };
 422         be_unmount_data_t       ud = { 0 };
 423         zfs_handle_t    *zhp;


1695                 /* Add the "nosub" option to the mount options string */
1696                 (void) strlcpy(optstr, MNTOPT_NOSUB, sizeof (optstr));
1697 
1698                 /* Loopback mount this dataset at the altroot */
1699                 if (mount(zhp_mountpoint, mountpoint, mflag, MNTTYPE_LOFS,
1700                     NULL, 0, optstr, sizeof (optstr)) != 0) {
1701                         err = errno;
1702                         be_print_err(gettext("loopback_mount_shared_fs: "
1703                             "failed to loopback mount %s at %s: %s\n"),
1704                             zhp_mountpoint, mountpoint, strerror(err));
1705                         return (BE_ERR_MOUNT);
1706                 }
1707         }
1708 
1709         return (BE_SUCCESS);
1710 }
1711 
1712 /*
1713  * Function:    loopback_mount_zonepath
1714  * Description: This function loopback mounts a zonepath into the altroot
1715  *              area of the BE being mounted.  Since these are shared file
1716  *              systems, they are expected to be already mounted for the
1717  *              current BE, and this function just loopback mounts them into
1718  *              the BE mountpoint.
1719  * Parameters:
1720  *              zonepath - pointer to zone path in the current BE
1721  *              md - be_mount_data_t pointer
1722  * Returns:
1723  *              BE_SUCCESS - Success
1724  *              be_errno_t - Failure
1725  * Scope:
1726  *              Private
1727  */
1728 static int
1729 loopback_mount_zonepath(const char *zonepath, be_mount_data_t *md)
1730 {
1731         FILE            *fp = (FILE *)NULL;
1732         struct stat     st;
1733         char            *p;
1734         char            *p1;
1735         char            *parent_dir;
1736         struct extmnttab        extmtab;
1737         dev_t           dev = NODEV;
1738         char            *parentmnt;




 365 
 366         /*
 367          * Mount shared file systems if mount flag says so.
 368          */
 369         if (md.shared_fs) {
 370                 /*
 371                  * Mount all ZFS file systems not under the BE's root dataset
 372                  */
 373                 (void) zpool_iter(g_zfs, zpool_shared_fs_callback, &md);
 374 
 375                 /* TODO: Mount all non-ZFS file systems - Not supported yet */
 376         }
 377 
 378         /*
 379          * If we're in the global zone and the global zone has a valid uuid,
 380          * mount all supported non-global zones.
 381          */
 382         if (getzoneid() == GLOBAL_ZONEID &&
 383             !(flags & BE_MOUNT_FLAG_NO_ZONES) &&
 384             be_get_uuid(bt.obe_root_ds, &uu) == BE_SUCCESS) {
 385                 if (be_mount_zones(zhp, &md) != BE_SUCCESS) {
 386                         ret = BE_ERR_NO_MOUNTED_ZONE;




 387                 }
 388         }
 389 
 390         ZFS_CLOSE(zhp);
 391 
 392         /*
 393          * If a NULL altroot was passed in, pass the generated altroot
 394          * back to the caller in altroot.
 395          */
 396         if (gen_tmp_altroot) {
 397                 if (ret == BE_SUCCESS || ret == BE_ERR_NO_MOUNTED_ZONE)
 398                         *altroot = tmp_altroot;
 399                 else
 400                         free(tmp_altroot);
 401         }
 402 
 403         return (ret);
 404 }
 405 
 406 /*
 407  * Function:    _be_unmount
 408  * Description: Unmount a BE.
 409  * Parameters:
 410  *              be_name - pointer to name of BE to unmount.
 411  *              flags - flags for unmounting the BE.
 412  * Returns:
 413  *              BE_SUCCESS - Success
 414  *              be_errno_t - Failure
 415  * Scope:
 416  *              Semi-private (library wide use only)
 417  */
 418 int
 419 _be_unmount(char *be_name, int flags)
 420 {
 421         be_transaction_data_t   bt = { 0 };
 422         be_unmount_data_t       ud = { 0 };
 423         zfs_handle_t    *zhp;


1695                 /* Add the "nosub" option to the mount options string */
1696                 (void) strlcpy(optstr, MNTOPT_NOSUB, sizeof (optstr));
1697 
1698                 /* Loopback mount this dataset at the altroot */
1699                 if (mount(zhp_mountpoint, mountpoint, mflag, MNTTYPE_LOFS,
1700                     NULL, 0, optstr, sizeof (optstr)) != 0) {
1701                         err = errno;
1702                         be_print_err(gettext("loopback_mount_shared_fs: "
1703                             "failed to loopback mount %s at %s: %s\n"),
1704                             zhp_mountpoint, mountpoint, strerror(err));
1705                         return (BE_ERR_MOUNT);
1706                 }
1707         }
1708 
1709         return (BE_SUCCESS);
1710 }
1711 
1712 /*
1713  * Function:    loopback_mount_zonepath
1714  * Description: This function loopback mounts a zonepath into the altroot
1715  *              area of the BE being mounted.



1716  * Parameters:
1717  *              zonepath - pointer to zone path in the current BE
1718  *              md - be_mount_data_t pointer
1719  * Returns:
1720  *              BE_SUCCESS - Success
1721  *              be_errno_t - Failure
1722  * Scope:
1723  *              Private
1724  */
1725 static int
1726 loopback_mount_zonepath(const char *zonepath, be_mount_data_t *md)
1727 {
1728         FILE            *fp = (FILE *)NULL;
1729         struct stat     st;
1730         char            *p;
1731         char            *p1;
1732         char            *parent_dir;
1733         struct extmnttab        extmtab;
1734         dev_t           dev = NODEV;
1735         char            *parentmnt;