Bug #73 » zone_get_zoneids.patch
usr/src/head/zone.h | ||
---|---|---|
63 | 63 |
extern int zone_setattr(zoneid_t, int, void *, size_t); |
64 | 64 |
extern int zone_enter(zoneid_t); |
65 | 65 |
extern int zone_list(zoneid_t *, uint_t *); |
66 |
extern int zone_get_zoneids(zoneid_t **, uint_t *); |
|
66 | 67 |
extern int zone_shutdown(zoneid_t); |
67 | 68 |
extern int zone_version(int *); |
68 | 69 |
extern int zone_add_datalink(zoneid_t, datalink_id_t); |
usr/src/lib/libc/port/mapfile-vers | ||
---|---|---|
2912 | 2912 |
zone_enter; |
2913 | 2913 |
zone_getattr; |
2914 | 2914 |
zone_get_id; |
2915 |
zone_get_zoneids; |
|
2915 | 2916 |
zone_list; |
2916 | 2917 |
zone_list_datalink; |
2917 | 2918 |
zonept; |
usr/src/lib/libc/port/sys/zone.c | ||
---|---|---|
185 | 185 |
return (syscall(SYS_zone, ZONE_LIST, zonelist, numzones)); |
186 | 186 |
} |
187 | 187 | |
188 |
int |
|
189 |
zone_get_zoneids(zoneid_t **zonelist, uint_t *numzones) |
|
190 |
zoneid_t *zids = NULL; |
|
191 |
uint_t nzids, nzids_saved; |
|
192 | ||
193 |
if (zone_list(NULL, &nzids) != 0) |
|
194 |
return (errno); |
|
195 |
again: |
|
196 |
nzids *= 2; |
|
197 |
if ((zids = malloc(nzids * sizeof (zoneid_t))) == NULL) |
|
198 |
return (errno); |
|
199 |
nzids_saved = nzids; |
|
200 |
if (zone_list(zids, &nzids) != 0) { |
|
201 |
free(zids); |
|
202 |
return (errno); |
|
203 |
} |
|
204 |
if (nzids > nzids_saved) { |
|
205 |
free(zids); |
|
206 |
goto again; |
|
207 |
} |
|
208 |
if(numzones) |
|
209 |
*numzones = nzids; |
|
210 |
if(zonelist) |
|
211 |
*zonelist = zids; |
|
212 |
else |
|
213 |
free(zids); |
|
214 | ||
215 |
return 0; |
|
216 |
} |
|
217 | ||
188 | 218 |
/* |
189 | 219 |
* Underlying implementation for getzoneid and getzoneidbyname. |
190 | 220 |
*/ |