vplat.c (5596:e1223011b5eb) vplat.c (5829:20241b1ccadc)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29/*
30 * This module contains functions used to bring up and tear down the
31 * Virtual Platform: [un]mounting file-systems, [un]plumbing network

--- 96 unchanged lines hidden (view full) ---

128#define V6_ADDR_LEN 128
129
130#define IPD_DEFAULT_OPTS \
131 MNTOPT_RO "," MNTOPT_LOFS_NOSUB "," MNTOPT_NODEVICES
132
133#define DFSTYPES "/etc/dfs/fstypes"
134#define MAXTNZLEN 2048
135
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29/*
30 * This module contains functions used to bring up and tear down the
31 * Virtual Platform: [un]mounting file-systems, [un]plumbing network

--- 96 unchanged lines hidden (view full) ---

128#define V6_ADDR_LEN 128
129
130#define IPD_DEFAULT_OPTS \
131 MNTOPT_RO "," MNTOPT_LOFS_NOSUB "," MNTOPT_NODEVICES
132
133#define DFSTYPES "/etc/dfs/fstypes"
134#define MAXTNZLEN 2048
135
136#define ALT_MOUNT(mount_cmd) ((mount_cmd) != Z_MNT_BOOT)
137
136/* for routing socket */
137static int rts_seqno = 0;
138
139/* mangled zone name when mounting in an alternate root environment */
140static char kernzone[ZONENAME_MAX];
141
142/* array of cached mount entries for resolve_lofs */
143static struct mnttab *resolve_lofs_mnts, *resolve_lofs_mnt_max;

--- 1173 unchanged lines hidden (view full) ---

1317 * is done this way because:
1318 * We need to have both /etc and /var in the root of the scratchzone.
1319 * We loopback mount zone's own /etc and /var into the root of the
1320 * scratch zone. Unlike /etc, /var can be a seperate filesystem. So we
1321 * need to delay the mount of /var till the zone's root gets populated.
1322 * So mounting of localdirs[](/etc and /var) have been moved to the
1323 * build_mounted_post_var() which gets called only after the zone
1324 * specific filesystems are mounted.
138/* for routing socket */
139static int rts_seqno = 0;
140
141/* mangled zone name when mounting in an alternate root environment */
142static char kernzone[ZONENAME_MAX];
143
144/* array of cached mount entries for resolve_lofs */
145static struct mnttab *resolve_lofs_mnts, *resolve_lofs_mnt_max;

--- 1173 unchanged lines hidden (view full) ---

1319 * is done this way because:
1320 * We need to have both /etc and /var in the root of the scratchzone.
1321 * We loopback mount zone's own /etc and /var into the root of the
1322 * scratch zone. Unlike /etc, /var can be a seperate filesystem. So we
1323 * need to delay the mount of /var till the zone's root gets populated.
1324 * So mounting of localdirs[](/etc and /var) have been moved to the
1325 * build_mounted_post_var() which gets called only after the zone
1326 * specific filesystems are mounted.
1327 *
1328 * Note that the scratch zone we set up for updating the zone (Z_MNT_UPDATE)
1329 * does not loopback mount the zone's own /etc and /var into the root of the
1330 * scratch zone.
1325 */
1326static boolean_t
1327build_mounted_pre_var(zlog_t *zlogp, char *rootpath,
1328 size_t rootlen, const char *zonepath, char *luroot, size_t lurootlen)
1329{
1330 char tmp[MAXPATHLEN], fromdir[MAXPATHLEN];
1331 const char **cpp;
1332 static const char *mkdirs[] = {

--- 67 unchanged lines hidden (view full) ---

1400 if (domount(zlogp, MNTTYPE_LOFS, "", rootpath, tmp) != 0)
1401 return (B_FALSE);
1402 (void) strlcpy(rootpath, tmp, rootlen);
1403 return (B_TRUE);
1404}
1405
1406
1407static boolean_t
1331 */
1332static boolean_t
1333build_mounted_pre_var(zlog_t *zlogp, char *rootpath,
1334 size_t rootlen, const char *zonepath, char *luroot, size_t lurootlen)
1335{
1336 char tmp[MAXPATHLEN], fromdir[MAXPATHLEN];
1337 const char **cpp;
1338 static const char *mkdirs[] = {

--- 67 unchanged lines hidden (view full) ---

1406 if (domount(zlogp, MNTTYPE_LOFS, "", rootpath, tmp) != 0)
1407 return (B_FALSE);
1408 (void) strlcpy(rootpath, tmp, rootlen);
1409 return (B_TRUE);
1410}
1411
1412
1413static boolean_t
1408build_mounted_post_var(zlog_t *zlogp, char *rootpath, const char *luroot)
1414build_mounted_post_var(zlog_t *zlogp, zone_mnt_t mount_cmd, char *rootpath,
1415 const char *luroot)
1409{
1410 char tmp[MAXPATHLEN], fromdir[MAXPATHLEN];
1411 const char **cpp;
1416{
1417 char tmp[MAXPATHLEN], fromdir[MAXPATHLEN];
1418 const char **cpp;
1419 const char **loopdirs;
1420 const char **tmpdirs;
1412 static const char *localdirs[] = {
1413 "/etc", "/var", NULL
1414 };
1421 static const char *localdirs[] = {
1422 "/etc", "/var", NULL
1423 };
1415 static const char *loopdirs[] = {
1424 static const char *scr_loopdirs[] = {
1416 "/etc/lib", "/etc/fs", "/lib", "/sbin", "/platform",
1417 "/usr", NULL
1418 };
1425 "/etc/lib", "/etc/fs", "/lib", "/sbin", "/platform",
1426 "/usr", NULL
1427 };
1419 static const char *tmpdirs[] = {
1428 static const char *upd_loopdirs[] = {
1429 "/etc", "/kernel", "/lib", "/opt", "/platform", "/sbin",
1430 "/usr", "/var", NULL
1431 };
1432 static const char *scr_tmpdirs[] = {
1420 "/tmp", "/var/run", NULL
1421 };
1433 "/tmp", "/var/run", NULL
1434 };
1435 static const char *upd_tmpdirs[] = {
1436 "/tmp", "/var/run", "/var/tmp", NULL
1437 };
1422 struct stat st;
1423
1438 struct stat st;
1439
1424 /*
1425 * These are mounted read-write from the zone undergoing upgrade. We
1426 * must be careful not to 'leak' things from the main system into the
1427 * zone, and this accomplishes that goal.
1428 */
1429 for (cpp = localdirs; *cpp != NULL; cpp++) {
1430 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot, *cpp);
1431 (void) snprintf(fromdir, sizeof (fromdir), "%s%s", rootpath,
1432 *cpp);
1433 if (mkdir(tmp, 0755) != 0) {
1434 zerror(zlogp, B_TRUE, "cannot create %s", tmp);
1435 return (B_FALSE);
1436 }
1437 if (domount(zlogp, MNTTYPE_LOFS, "", fromdir, tmp) != 0) {
1438 zerror(zlogp, B_TRUE, "cannot mount %s on %s", tmp,
1440 if (mount_cmd == Z_MNT_SCRATCH) {
1441 /*
1442 * These are mounted read-write from the zone undergoing
1443 * upgrade. We must be careful not to 'leak' things from the
1444 * main system into the zone, and this accomplishes that goal.
1445 */
1446 for (cpp = localdirs; *cpp != NULL; cpp++) {
1447 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot,
1439 *cpp);
1448 *cpp);
1440 return (B_FALSE);
1449 (void) snprintf(fromdir, sizeof (fromdir), "%s%s",
1450 rootpath, *cpp);
1451 if (mkdir(tmp, 0755) != 0) {
1452 zerror(zlogp, B_TRUE, "cannot create %s", tmp);
1453 return (B_FALSE);
1454 }
1455 if (domount(zlogp, MNTTYPE_LOFS, "", fromdir, tmp)
1456 != 0) {
1457 zerror(zlogp, B_TRUE, "cannot mount %s on %s",
1458 tmp, *cpp);
1459 return (B_FALSE);
1460 }
1441 }
1442 }
1443
1461 }
1462 }
1463
1464 if (mount_cmd == Z_MNT_UPDATE)
1465 loopdirs = upd_loopdirs;
1466 else
1467 loopdirs = scr_loopdirs;
1468
1444 /*
1445 * These are things mounted read-only from the running system because
1446 * they contain binaries that must match system.
1447 */
1448 for (cpp = loopdirs; *cpp != NULL; cpp++) {
1449 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot, *cpp);
1450 if (mkdir(tmp, 0755) != 0) {
1451 if (errno != EEXIST) {

--- 16 unchanged lines hidden (view full) ---

1468 if (domount(zlogp, MNTTYPE_LOFS, IPD_DEFAULT_OPTS, *cpp,
1469 tmp) != 0) {
1470 zerror(zlogp, B_TRUE, "cannot mount %s on %s", tmp,
1471 *cpp);
1472 return (B_FALSE);
1473 }
1474 }
1475
1469 /*
1470 * These are things mounted read-only from the running system because
1471 * they contain binaries that must match system.
1472 */
1473 for (cpp = loopdirs; *cpp != NULL; cpp++) {
1474 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot, *cpp);
1475 if (mkdir(tmp, 0755) != 0) {
1476 if (errno != EEXIST) {

--- 16 unchanged lines hidden (view full) ---

1493 if (domount(zlogp, MNTTYPE_LOFS, IPD_DEFAULT_OPTS, *cpp,
1494 tmp) != 0) {
1495 zerror(zlogp, B_TRUE, "cannot mount %s on %s", tmp,
1496 *cpp);
1497 return (B_FALSE);
1498 }
1499 }
1500
1501 if (mount_cmd == Z_MNT_UPDATE)
1502 tmpdirs = upd_tmpdirs;
1503 else
1504 tmpdirs = scr_tmpdirs;
1505
1476 /*
1477 * These are things with tmpfs mounted inside.
1478 */
1479 for (cpp = tmpdirs; *cpp != NULL; cpp++) {
1480 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot, *cpp);
1506 /*
1507 * These are things with tmpfs mounted inside.
1508 */
1509 for (cpp = tmpdirs; *cpp != NULL; cpp++) {
1510 (void) snprintf(tmp, sizeof (tmp), "%s%s", luroot, *cpp);
1481 if (mkdir(tmp, 0755) != 0 && errno != EEXIST) {
1511 if (mount_cmd == Z_MNT_SCRATCH && mkdir(tmp, 0755) != 0 &&
1512 errno != EEXIST) {
1482 zerror(zlogp, B_TRUE, "cannot create %s", tmp);
1483 return (B_FALSE);
1484 }
1485
1486 /*
1487 * We could set the mode for /tmp when we do the mkdir but
1488 * since that can be modified by the umask we will just set
1489 * the correct mode for /tmp now.

--- 100 unchanged lines hidden (view full) ---

1590 fsp->zone_fs_options = NULL;
1591 }
1592 (void) zonecfg_endipdent(handle);
1593 return (0);
1594}
1595
1596static int
1597mount_filesystems_fsent(zone_dochandle_t handle, zlog_t *zlogp,
1513 zerror(zlogp, B_TRUE, "cannot create %s", tmp);
1514 return (B_FALSE);
1515 }
1516
1517 /*
1518 * We could set the mode for /tmp when we do the mkdir but
1519 * since that can be modified by the umask we will just set
1520 * the correct mode for /tmp now.

--- 100 unchanged lines hidden (view full) ---

1621 fsp->zone_fs_options = NULL;
1622 }
1623 (void) zonecfg_endipdent(handle);
1624 return (0);
1625}
1626
1627static int
1628mount_filesystems_fsent(zone_dochandle_t handle, zlog_t *zlogp,
1598 struct zone_fstab **fs_tabp, int *num_fsp, int mount_cmd)
1629 struct zone_fstab **fs_tabp, int *num_fsp, zone_mnt_t mount_cmd)
1599{
1600 struct zone_fstab *tmp_ptr, *fs_ptr, *fsp, fstab;
1601 int num_fs;
1602
1603 num_fs = *num_fsp;
1604 fs_ptr = *fs_tabp;
1605
1606 if (zonecfg_setfsent(handle) != Z_OK) {
1607 zerror(zlogp, B_FALSE, "invalid configuration");
1608 return (-1);
1609 }
1610 while (zonecfg_getfsent(handle, &fstab) == Z_OK) {
1611 /*
1612 * ZFS filesystems will not be accessible under an alternate
1613 * root, since the pool will not be known. Ignore them in this
1614 * case.
1615 */
1630{
1631 struct zone_fstab *tmp_ptr, *fs_ptr, *fsp, fstab;
1632 int num_fs;
1633
1634 num_fs = *num_fsp;
1635 fs_ptr = *fs_tabp;
1636
1637 if (zonecfg_setfsent(handle) != Z_OK) {
1638 zerror(zlogp, B_FALSE, "invalid configuration");
1639 return (-1);
1640 }
1641 while (zonecfg_getfsent(handle, &fstab) == Z_OK) {
1642 /*
1643 * ZFS filesystems will not be accessible under an alternate
1644 * root, since the pool will not be known. Ignore them in this
1645 * case.
1646 */
1616 if (mount_cmd && strcmp(fstab.zone_fs_type, MNTTYPE_ZFS) == 0)
1647 if (ALT_MOUNT(mount_cmd) &&
1648 strcmp(fstab.zone_fs_type, MNTTYPE_ZFS) == 0)
1617 continue;
1618
1619 num_fs++;
1620 if ((tmp_ptr = realloc(fs_ptr,
1621 num_fs * sizeof (*tmp_ptr))) == NULL) {
1622 zerror(zlogp, B_TRUE, "memory allocation failed");
1623 (void) zonecfg_endfsent(handle);
1624 return (-1);

--- 30 unchanged lines hidden (view full) ---

1655 (void) strlcat(fsp->zone_fs_special, fstab.zone_fs_special,
1656 sizeof (fsp->zone_fs_special));
1657 }
1658 (void) zonecfg_endfsent(handle);
1659 return (0);
1660}
1661
1662static int
1649 continue;
1650
1651 num_fs++;
1652 if ((tmp_ptr = realloc(fs_ptr,
1653 num_fs * sizeof (*tmp_ptr))) == NULL) {
1654 zerror(zlogp, B_TRUE, "memory allocation failed");
1655 (void) zonecfg_endfsent(handle);
1656 return (-1);

--- 30 unchanged lines hidden (view full) ---

1687 (void) strlcat(fsp->zone_fs_special, fstab.zone_fs_special,
1688 sizeof (fsp->zone_fs_special));
1689 }
1690 (void) zonecfg_endfsent(handle);
1691 return (0);
1692}
1693
1694static int
1663mount_filesystems(zlog_t *zlogp, boolean_t mount_cmd)
1695mount_filesystems(zlog_t *zlogp, zone_mnt_t mount_cmd)
1664{
1665 char rootpath[MAXPATHLEN];
1666 char zonepath[MAXPATHLEN];
1667 char brand[MAXNAMELEN];
1668 char luroot[MAXPATHLEN];
1669 int i, num_fs = 0;
1670 struct zone_fstab *fs_ptr = NULL;
1671 zone_dochandle_t handle = NULL;

--- 97 unchanged lines hidden (view full) ---

1769 * case and instead mount it at <zoneroot>/lu/dev.
1770 *
1771 * All this work is done in three phases:
1772 * 1) Create and populate lu directory (build_mounted_pre_var()).
1773 * 2) Mount the required filesystems as per the zone configuration.
1774 * 3) Set up the rest of the scratch zone environment
1775 * (build_mounted_post_var()).
1776 */
1696{
1697 char rootpath[MAXPATHLEN];
1698 char zonepath[MAXPATHLEN];
1699 char brand[MAXNAMELEN];
1700 char luroot[MAXPATHLEN];
1701 int i, num_fs = 0;
1702 struct zone_fstab *fs_ptr = NULL;
1703 zone_dochandle_t handle = NULL;

--- 97 unchanged lines hidden (view full) ---

1801 * case and instead mount it at <zoneroot>/lu/dev.
1802 *
1803 * All this work is done in three phases:
1804 * 1) Create and populate lu directory (build_mounted_pre_var()).
1805 * 2) Mount the required filesystems as per the zone configuration.
1806 * 3) Set up the rest of the scratch zone environment
1807 * (build_mounted_post_var()).
1808 */
1777 if (mount_cmd &&
1778 !build_mounted_pre_var(zlogp,
1809 if (ALT_MOUNT(mount_cmd) && !build_mounted_pre_var(zlogp,
1779 rootpath, sizeof (rootpath), zonepath, luroot, sizeof (luroot)))
1780 goto bad;
1781
1782 qsort(fs_ptr, num_fs, sizeof (*fs_ptr), fs_compare);
1783
1784 for (i = 0; i < num_fs; i++) {
1810 rootpath, sizeof (rootpath), zonepath, luroot, sizeof (luroot)))
1811 goto bad;
1812
1813 qsort(fs_ptr, num_fs, sizeof (*fs_ptr), fs_compare);
1814
1815 for (i = 0; i < num_fs; i++) {
1785 if (mount_cmd &&
1816 if (ALT_MOUNT(mount_cmd) &&
1786 strcmp(fs_ptr[i].zone_fs_dir, "/dev") == 0) {
1787 size_t slen = strlen(rootpath) - 2;
1788
1789 /*
1790 * By default we'll try to mount /dev as /a/dev
1791 * but /dev is special and always goes at the top
1792 * so strip the trailing '/a' from the rootpath.
1793 */
1794 assert(zone_isnative || zone_iscluster);
1795 assert(strcmp(&rootpath[slen], "/a") == 0);
1796 rootpath[slen] = '\0';
1797 if (mount_one(zlogp, &fs_ptr[i], rootpath) != 0)
1798 goto bad;
1799 rootpath[slen] = '/';
1800 continue;
1801 }
1802 if (mount_one(zlogp, &fs_ptr[i], rootpath) != 0)
1803 goto bad;
1804 }
1817 strcmp(fs_ptr[i].zone_fs_dir, "/dev") == 0) {
1818 size_t slen = strlen(rootpath) - 2;
1819
1820 /*
1821 * By default we'll try to mount /dev as /a/dev
1822 * but /dev is special and always goes at the top
1823 * so strip the trailing '/a' from the rootpath.
1824 */
1825 assert(zone_isnative || zone_iscluster);
1826 assert(strcmp(&rootpath[slen], "/a") == 0);
1827 rootpath[slen] = '\0';
1828 if (mount_one(zlogp, &fs_ptr[i], rootpath) != 0)
1829 goto bad;
1830 rootpath[slen] = '/';
1831 continue;
1832 }
1833 if (mount_one(zlogp, &fs_ptr[i], rootpath) != 0)
1834 goto bad;
1835 }
1805 if (mount_cmd &&
1806 !build_mounted_post_var(zlogp, rootpath, luroot))
1836 if (ALT_MOUNT(mount_cmd) &&
1837 !build_mounted_post_var(zlogp, mount_cmd, rootpath, luroot))
1807 goto bad;
1808
1809 /*
1810 * For Trusted Extensions cross-mount each lower level /export/home
1811 */
1838 goto bad;
1839
1840 /*
1841 * For Trusted Extensions cross-mount each lower level /export/home
1842 */
1812 if (!mount_cmd && tsol_mounts(zlogp, zone_name, rootpath) != 0)
1843 if (mount_cmd == Z_MNT_BOOT &&
1844 tsol_mounts(zlogp, zone_name, rootpath) != 0)
1813 goto bad;
1814
1815 free_fs_data(fs_ptr, num_fs);
1816
1817 /*
1818 * Everything looks fine.
1819 */
1820 return (0);

--- 1081 unchanged lines hidden (view full) ---

2902 remote6->sin6_addr = in6addr_any;
2903
2904 if ((error = tcp_abort_conn(zlogp, zoneid, &l, &r)) != 0)
2905 return (error);
2906 return (0);
2907}
2908
2909static int
1845 goto bad;
1846
1847 free_fs_data(fs_ptr, num_fs);
1848
1849 /*
1850 * Everything looks fine.
1851 */
1852 return (0);

--- 1081 unchanged lines hidden (view full) ---

2934 remote6->sin6_addr = in6addr_any;
2935
2936 if ((error = tcp_abort_conn(zlogp, zoneid, &l, &r)) != 0)
2937 return (error);
2938 return (0);
2939}
2940
2941static int
2910get_privset(zlog_t *zlogp, priv_set_t *privs, boolean_t mount_cmd)
2942get_privset(zlog_t *zlogp, priv_set_t *privs, zone_mnt_t mount_cmd)
2911{
2912 int error = -1;
2913 zone_dochandle_t handle;
2914 char *privname = NULL;
2915
2916 if ((handle = zonecfg_init_handle()) == NULL) {
2917 zerror(zlogp, B_TRUE, "getting zone configuration handle");
2918 return (-1);
2919 }
2920 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
2921 zerror(zlogp, B_FALSE, "invalid configuration");
2922 zonecfg_fini_handle(handle);
2923 return (-1);
2924 }
2925
2943{
2944 int error = -1;
2945 zone_dochandle_t handle;
2946 char *privname = NULL;
2947
2948 if ((handle = zonecfg_init_handle()) == NULL) {
2949 zerror(zlogp, B_TRUE, "getting zone configuration handle");
2950 return (-1);
2951 }
2952 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
2953 zerror(zlogp, B_FALSE, "invalid configuration");
2954 zonecfg_fini_handle(handle);
2955 return (-1);
2956 }
2957
2926 if (mount_cmd) {
2958 if (ALT_MOUNT(mount_cmd)) {
2927 zone_iptype_t iptype;
2928 const char *curr_iptype;
2929
2930 if (zonecfg_get_iptype(handle, &iptype) != Z_OK) {
2931 zerror(zlogp, B_TRUE, "unable to determine ip-type");
2932 zonecfg_fini_handle(handle);
2933 return (-1);
2934 }

--- 1070 unchanged lines hidden (view full) ---

4005 zonecfg_strerror(res));
4006 }
4007
4008 zonecfg_fini_handle(handle);
4009 return (Z_OK);
4010}
4011
4012zoneid_t
2959 zone_iptype_t iptype;
2960 const char *curr_iptype;
2961
2962 if (zonecfg_get_iptype(handle, &iptype) != Z_OK) {
2963 zerror(zlogp, B_TRUE, "unable to determine ip-type");
2964 zonecfg_fini_handle(handle);
2965 return (-1);
2966 }

--- 1070 unchanged lines hidden (view full) ---

4037 zonecfg_strerror(res));
4038 }
4039
4040 zonecfg_fini_handle(handle);
4041 return (Z_OK);
4042}
4043
4044zoneid_t
4013vplat_create(zlog_t *zlogp, boolean_t mount_cmd)
4045vplat_create(zlog_t *zlogp, zone_mnt_t mount_cmd)
4014{
4015 zoneid_t rval = -1;
4016 priv_set_t *privs;
4017 char rootpath[MAXPATHLEN];
4018 char modname[MAXPATHLEN];
4019 struct brand_attr attr;
4020 brand_handle_t bh;
4021 char *rctlbuf = NULL;

--- 33 unchanged lines hidden (view full) ---

4055 if ((privs = priv_allocset()) == NULL) {
4056 zerror(zlogp, B_TRUE, "%s failed", "priv_allocset");
4057 return (-1);
4058 }
4059 priv_emptyset(privs);
4060 if (get_privset(zlogp, privs, mount_cmd) != 0)
4061 goto error;
4062
4046{
4047 zoneid_t rval = -1;
4048 priv_set_t *privs;
4049 char rootpath[MAXPATHLEN];
4050 char modname[MAXPATHLEN];
4051 struct brand_attr attr;
4052 brand_handle_t bh;
4053 char *rctlbuf = NULL;

--- 33 unchanged lines hidden (view full) ---

4087 if ((privs = priv_allocset()) == NULL) {
4088 zerror(zlogp, B_TRUE, "%s failed", "priv_allocset");
4089 return (-1);
4090 }
4091 priv_emptyset(privs);
4092 if (get_privset(zlogp, privs, mount_cmd) != 0)
4093 goto error;
4094
4063 if (!mount_cmd && get_rctls(zlogp, &rctlbuf, &rctlbufsz) != 0) {
4095 if (mount_cmd == Z_MNT_BOOT &&
4096 get_rctls(zlogp, &rctlbuf, &rctlbufsz) != 0) {
4064 zerror(zlogp, B_FALSE, "Unable to get list of rctls");
4065 goto error;
4066 }
4067
4068 if (get_datasets(zlogp, &zfsbuf, &zfsbufsz) != 0) {
4069 zerror(zlogp, B_FALSE, "Unable to get list of ZFS datasets");
4070 goto error;
4071 }
4072
4097 zerror(zlogp, B_FALSE, "Unable to get list of rctls");
4098 goto error;
4099 }
4100
4101 if (get_datasets(zlogp, &zfsbuf, &zfsbufsz) != 0) {
4102 zerror(zlogp, B_FALSE, "Unable to get list of ZFS datasets");
4103 goto error;
4104 }
4105
4073 if (!mount_cmd && is_system_labeled()) {
4106 if (mount_cmd == Z_MNT_BOOT && is_system_labeled()) {
4074 zcent = get_zone_label(zlogp, privs);
4075 if (zcent != NULL) {
4076 match = zcent->zc_match;
4077 doi = zcent->zc_doi;
4078 *zlabel = zcent->zc_label;
4079 } else {
4080 goto error;
4081 }

--- 7 unchanged lines hidden (view full) ---

4089 * Next, we reduce to the shortest path and search for loopback mounts
4090 * that use this same source node (same device and inode).
4091 */
4092 if (duplicate_zone_root(zlogp, rootpath))
4093 goto error;
4094 if (duplicate_reachable_path(zlogp, rootpath))
4095 goto error;
4096
4107 zcent = get_zone_label(zlogp, privs);
4108 if (zcent != NULL) {
4109 match = zcent->zc_match;
4110 doi = zcent->zc_doi;
4111 *zlabel = zcent->zc_label;
4112 } else {
4113 goto error;
4114 }

--- 7 unchanged lines hidden (view full) ---

4122 * Next, we reduce to the shortest path and search for loopback mounts
4123 * that use this same source node (same device and inode).
4124 */
4125 if (duplicate_zone_root(zlogp, rootpath))
4126 goto error;
4127 if (duplicate_reachable_path(zlogp, rootpath))
4128 goto error;
4129
4097 if (mount_cmd) {
4130 if (ALT_MOUNT(mount_cmd)) {
4098 assert(zone_isnative || zone_iscluster);
4099 root_to_lu(zlogp, rootpath, sizeof (rootpath), B_TRUE);
4100
4101 /*
4102 * Forge up a special root for this zone. When a zone is
4103 * mounted, we can't let the zone have its own root because the
4104 * tools that will be used in this "scratch zone" need access
4105 * to both the zone's resources and the running machine's

--- 111 unchanged lines hidden (view full) ---

4217 goto error;
4218 }
4219 }
4220
4221 /*
4222 * The following actions are not performed when merely mounting a zone
4223 * for administrative use.
4224 */
4131 assert(zone_isnative || zone_iscluster);
4132 root_to_lu(zlogp, rootpath, sizeof (rootpath), B_TRUE);
4133
4134 /*
4135 * Forge up a special root for this zone. When a zone is
4136 * mounted, we can't let the zone have its own root because the
4137 * tools that will be used in this "scratch zone" need access
4138 * to both the zone's resources and the running machine's

--- 111 unchanged lines hidden (view full) ---

4250 goto error;
4251 }
4252 }
4253
4254 /*
4255 * The following actions are not performed when merely mounting a zone
4256 * for administrative use.
4257 */
4225 if (!mount_cmd) {
4258 if (mount_cmd == Z_MNT_BOOT) {
4226 if (setup_zone_rm(zlogp, zone_name, zoneid) != Z_OK) {
4227 (void) zone_shutdown(zoneid);
4228 goto error;
4229 }
4230
4231 set_mlps(zlogp, zoneid, zcent);
4232 }
4233

--- 86 unchanged lines hidden (view full) ---

4320 uuidstr);
4321 (void) fclose(zet);
4322 }
4323 }
4324 _exit(0);
4325}
4326
4327int
4259 if (setup_zone_rm(zlogp, zone_name, zoneid) != Z_OK) {
4260 (void) zone_shutdown(zoneid);
4261 goto error;
4262 }
4263
4264 set_mlps(zlogp, zoneid, zcent);
4265 }
4266

--- 86 unchanged lines hidden (view full) ---

4353 uuidstr);
4354 (void) fclose(zet);
4355 }
4356 }
4357 _exit(0);
4358}
4359
4360int
4328vplat_bringup(zlog_t *zlogp, boolean_t mount_cmd, zoneid_t zoneid)
4361vplat_bringup(zlog_t *zlogp, zone_mnt_t mount_cmd, zoneid_t zoneid)
4329{
4330 char zonepath[MAXPATHLEN];
4331
4362{
4363 char zonepath[MAXPATHLEN];
4364
4332 if (!mount_cmd && validate_datasets(zlogp) != 0) {
4365 if (mount_cmd == Z_MNT_BOOT && validate_datasets(zlogp) != 0) {
4333 lofs_discard_mnttab();
4334 return (-1);
4335 }
4336
4337 /*
4338 * Before we try to mount filesystems we need to create the
4339 * attribute backing store for /dev
4340 */

--- 10 unchanged lines hidden (view full) ---

4351 return (-1);
4352 }
4353
4354 if (mount_filesystems(zlogp, mount_cmd) != 0) {
4355 lofs_discard_mnttab();
4356 return (-1);
4357 }
4358
4366 lofs_discard_mnttab();
4367 return (-1);
4368 }
4369
4370 /*
4371 * Before we try to mount filesystems we need to create the
4372 * attribute backing store for /dev
4373 */

--- 10 unchanged lines hidden (view full) ---

4384 return (-1);
4385 }
4386
4387 if (mount_filesystems(zlogp, mount_cmd) != 0) {
4388 lofs_discard_mnttab();
4389 return (-1);
4390 }
4391
4359 if (!mount_cmd) {
4392 if (mount_cmd == Z_MNT_BOOT) {
4360 zone_iptype_t iptype;
4361
4362 if (get_iptype(zlogp, &iptype) < 0) {
4363 zerror(zlogp, B_TRUE, "unable to determine ip-type");
4364 lofs_discard_mnttab();
4365 return (-1);
4366 }
4367

--- 342 unchanged lines hidden ---
4393 zone_iptype_t iptype;
4394
4395 if (get_iptype(zlogp, &iptype) < 0) {
4396 zerror(zlogp, B_TRUE, "unable to determine ip-type");
4397 lofs_discard_mnttab();
4398 return (-1);
4399 }
4400

--- 342 unchanged lines hidden ---