blob: 55e39a3af0119467caa5f12da808851341eb39d9 [file] [log] [blame]
Cosmos Nicolaou39a00e02014-08-14 11:04:14 -07001// +build darwin
2
Cosmos Nicolaou6c6fa112014-08-19 13:22:33 -07003package profiles
Cosmos Nicolaou39a00e02014-08-14 11:04:14 -07004
5// #include <sys/utsname.h>
6// #include <errno.h>
7import "C"
8
9import (
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.
19func 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}