Created
April 23, 2017 04:26
-
-
Save jclulow/9016043b2a0edf42109e75c4216b1af7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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