Cosmos Nicolaou | 39a00e0 | 2014-08-14 11:04:14 -0700 | [diff] [blame] | 1 | // +build darwin |
| 2 | |
Cosmos Nicolaou | 6c6fa11 | 2014-08-19 13:22:33 -0700 | [diff] [blame] | 3 | package profiles |
Cosmos Nicolaou | 39a00e0 | 2014-08-14 11:04:14 -0700 | [diff] [blame] | 4 | |
| 5 | // #include <sys/utsname.h> |
| 6 | // #include <errno.h> |
| 7 | import "C" |
| 8 | |
| 9 | import ( |
| 10 | "fmt" |
| 11 | |
| 12 | "veyron2" |
| 13 | "veyron2/security" |
| 14 | ) |
| 15 | |
| 16 | // Platform returns the description of the Platform this process is running on. |
| 17 | // A default value for veyron2.Platform is provided even if an error is |
| 18 | // returned; nil is never returned for the first return result. |
| 19 | func Platform() (*veyron2.Platform, error) { |
| 20 | var t C.struct_utsname |
| 21 | if r, err := C.uname(&t); r != 0 { |
| 22 | return &veyron2.Platform{}, fmt.Errorf("uname failed: errno %d", err) |
| 23 | } |
| 24 | d := &veyron2.Platform{ |
| 25 | Vendor: "google", |
| 26 | Model: "generic", |
| 27 | System: C.GoString(&t.sysname[0]), |
| 28 | Version: C.GoString(&t.version[0]), |
| 29 | Release: C.GoString(&t.release[0]), |
| 30 | Machine: C.GoString(&t.machine[0]), |
| 31 | Node: C.GoString(&t.nodename[0]), |
| 32 | } |
| 33 | d.Identity = security.FakePublicID(fmt.Sprintf("%s/%s/%s", d.Vendor, d.Model, d.Node)) |
| 34 | return d, nil |
| 35 | } |