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