Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created April 23, 2017 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclulow/9016043b2a0edf42109e75c4216b1af7 to your computer and use it in GitHub Desktop.
Save jclulow/9016043b2a0edf42109e75c4216b1af7 to your computer and use it in GitHub Desktop.
package illumos;
/*
#include <stdlib.h>
#include <zone.h>
*/
import "C";
import "unsafe";
func Getzoneid() (zoneid int) {
return (int(C.getzoneid()));
}
func Getzonenamebyid(zone_id int) (zonename string) {
var cstr *C.char = (*C.char)(C.malloc(C.ZONENAME_MAX));
defer C.free(unsafe.Pointer(cstr));
sz := C.getzonenamebyid((C.zoneid_t)(zone_id), cstr, C.ZONENAME_MAX);
if (sz < 0) {
panic("getzonenamebyid(3C) failed");
}
return (C.GoString(cstr));
}
func Getzonename() (zonename string) {
return (Getzonenamebyid(Getzoneid()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment