Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/usr/src/head/zone.h b/usr/src/head/zone.h
- index 34528a2..2181ff9 100644
- --- a/usr/src/head/zone.h
- +++ b/usr/src/head/zone.h
- @@ -63,6 +63,7 @@ extern ssize_t zone_getattr(zoneid_t, int, void *, size_t);
- extern int zone_setattr(zoneid_t, int, void *, size_t);
- extern int zone_enter(zoneid_t);
- extern int zone_list(zoneid_t *, uint_t *);
- +extern int zone_get_zoneids(zoneid_t **, uint_t *);
- extern int zone_shutdown(zoneid_t);
- extern int zone_version(int *);
- extern int zone_add_datalink(zoneid_t, datalink_id_t);
- diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
- index 5999988..f2b908d 100644
- --- a/usr/src/lib/libc/port/mapfile-vers
- +++ b/usr/src/lib/libc/port/mapfile-vers
- @@ -2912,6 +2912,7 @@ $endif
- zone_enter;
- zone_getattr;
- zone_get_id;
- + zone_get_zoneids;
- zone_list;
- zone_list_datalink;
- zonept;
- diff --git a/usr/src/lib/libc/port/sys/zone.c b/usr/src/lib/libc/port/sys/zone.c
- index 4a4c700..0faf377 100644
- --- a/usr/src/lib/libc/port/sys/zone.c
- +++ b/usr/src/lib/libc/port/sys/zone.c
- @@ -185,6 +185,36 @@ zone_list(zoneid_t *zonelist, uint_t *numzones)
- return (syscall(SYS_zone, ZONE_LIST, zonelist, numzones));
- }
- +int
- +zone_get_zoneids(zoneid_t **zonelist, uint_t *numzones)
- + zoneid_t *zids = NULL;
- + uint_t nzids, nzids_saved;
- +
- + if (zone_list(NULL, &nzids) != 0)
- + return (errno);
- +again:
- + nzids *= 2;
- + if ((zids = malloc(nzids * sizeof (zoneid_t))) == NULL)
- + return (errno);
- + nzids_saved = nzids;
- + if (zone_list(zids, &nzids) != 0) {
- + free(zids);
- + return (errno);
- + }
- + if (nzids > nzids_saved) {
- + free(zids);
- + goto again;
- + }
- + if(numzones)
- + *numzones = nzids;
- + if(zonelist)
- + *zonelist = zids;
- + else
- + free(zids);
- +
- + return 0;
- +}
- +
- /*
- * Underlying implementation for getzoneid and getzoneidbyname.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement