Print this page
libdladm needs to be a bit more LX-aware

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdladm/common/linkprop.c
          +++ new/usr/src/lib/libdladm/common/linkprop.c
↓ open down ↓ 1488 lines elided ↑ open up ↑
1489 1489  
1490 1490                  (void) strncpy(*prop_val, zone_name, DLADM_PROP_VAL_MAX);
1491 1491          } else {
1492 1492                  *prop_val[0] = '\0';
1493 1493          }
1494 1494  
1495 1495          return (DLADM_STATUS_OK);
1496 1496  }
1497 1497  
1498 1498  typedef int (*zone_get_devroot_t)(char *, char *, size_t);
     1499 +typedef int (*zone_get_brand_t)(char *, char *, size_t);
1499 1500  
1500 1501  static int
1501 1502  i_dladm_get_zone_dev(char *zone_name, char *dev, size_t devlen)
1502 1503  {
1503 1504          char                    root[MAXPATHLEN];
     1505 +        char                    brand[MAXPATHLEN]; /* Overkill, for sure. */
     1506 +        static char             *full_native_path = "/native/dev";
     1507 +        char                    *native_dev_path = full_native_path;
1504 1508          zone_get_devroot_t      real_zone_get_devroot;
     1509 +        zone_get_brand_t        real_zone_get_brand;
1505 1510          void                    *dlhandle;
1506 1511          void                    *sym;
1507 1512          int                     ret;
1508 1513  
1509 1514          if ((dlhandle = dlopen("libzonecfg.so.1", RTLD_LAZY)) == NULL)
1510 1515                  return (-1);
1511 1516  
1512 1517          if ((sym = dlsym(dlhandle, "zone_get_devroot")) == NULL) {
1513 1518                  (void) dlclose(dlhandle);
1514 1519                  return (-1);
1515 1520          }
1516      -
1517 1521          real_zone_get_devroot = (zone_get_devroot_t)sym;
1518 1522  
     1523 +        if ((sym = dlsym(dlhandle, "zone_get_brand")) == NULL) {
     1524 +                (void) dlclose(dlhandle);
     1525 +                return (-1);
     1526 +        }
     1527 +        real_zone_get_brand = (zone_get_devroot_t)sym;
     1528 +
     1529 +        /* Have "/dev" be LX-agile for possibility of "/native/dev". */
     1530 +        ret = real_zone_get_brand(zone_name, brand, sizeof (brand));
     1531 +        if (ret != 0) {
     1532 +                (void) dlclose(dlhandle);
     1533 +                return (ret);
     1534 +        }
     1535 +        /* Can use strcmp with constant string... */
     1536 +        if (strcmp(brand, "lx") != 0) {
     1537 +                /* Non-LX zone, don't use "/native/dev" */
     1538 +                native_dev_path += 7;   /* strlen("/native") */
     1539 +        }
     1540 +
1519 1541          if ((ret = real_zone_get_devroot(zone_name, root, sizeof (root))) == 0)
1520      -                (void) snprintf(dev, devlen, "%s%s", root, "/dev");
     1542 +                (void) snprintf(dev, devlen, "%s%s", root, native_dev_path);
1521 1543          (void) dlclose(dlhandle);
1522 1544          return (ret);
1523 1545  }
1524 1546  
1525 1547  static dladm_status_t
1526 1548  i_dladm_update_deventry(dladm_handle_t handle, zoneid_t zid,
1527 1549      datalink_id_t linkid, boolean_t add)
1528 1550  {
1529 1551          char            path[MAXPATHLEN];
1530 1552          char            name[MAXLINKNAMELEN];
↓ open down ↓ 3299 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX