Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. diff --git a/usr/src/head/zone.h b/usr/src/head/zone.h
  2. index 34528a2..2181ff9 100644
  3. --- a/usr/src/head/zone.h
  4. +++ b/usr/src/head/zone.h
  5. @@ -63,6 +63,7 @@ extern ssize_t zone_getattr(zoneid_t, int, void *, size_t);
  6. extern int zone_setattr(zoneid_t, int, void *, size_t);
  7. extern int zone_enter(zoneid_t);
  8. extern int zone_list(zoneid_t *, uint_t *);
  9. +extern int zone_get_zoneids(zoneid_t **, uint_t *);
  10. extern int zone_shutdown(zoneid_t);
  11. extern int zone_version(int *);
  12. extern int zone_add_datalink(zoneid_t, datalink_id_t);
  13. diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
  14. index 5999988..f2b908d 100644
  15. --- a/usr/src/lib/libc/port/mapfile-vers
  16. +++ b/usr/src/lib/libc/port/mapfile-vers
  17. @@ -2912,6 +2912,7 @@ $endif
  18. zone_enter;
  19. zone_getattr;
  20. zone_get_id;
  21. + zone_get_zoneids;
  22. zone_list;
  23. zone_list_datalink;
  24. zonept;
  25. diff --git a/usr/src/lib/libc/port/sys/zone.c b/usr/src/lib/libc/port/sys/zone.c
  26. index 4a4c700..0faf377 100644
  27. --- a/usr/src/lib/libc/port/sys/zone.c
  28. +++ b/usr/src/lib/libc/port/sys/zone.c
  29. @@ -185,6 +185,36 @@ zone_list(zoneid_t *zonelist, uint_t *numzones)
  30. return (syscall(SYS_zone, ZONE_LIST, zonelist, numzones));
  31. }
  32.  
  33. +int
  34. +zone_get_zoneids(zoneid_t **zonelist, uint_t *numzones)
  35. + zoneid_t *zids = NULL;
  36. + uint_t nzids, nzids_saved;
  37. +
  38. + if (zone_list(NULL, &nzids) != 0)
  39. + return (errno);
  40. +again:
  41. + nzids *= 2;
  42. + if ((zids = malloc(nzids * sizeof (zoneid_t))) == NULL)
  43. + return (errno);
  44. + nzids_saved = nzids;
  45. + if (zone_list(zids, &nzids) != 0) {
  46. + free(zids);
  47. + return (errno);
  48. + }
  49. + if (nzids > nzids_saved) {
  50. + free(zids);
  51. + goto again;
  52. + }
  53. + if(numzones)
  54. + *numzones = nzids;
  55. + if(zonelist)
  56. + *zonelist = zids;
  57. + else
  58. + free(zids);
  59. +
  60. + return 0;
  61. +}
  62. +
  63. /*
  64. * Underlying implementation for getzoneid and getzoneidbyname.
  65. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement