blob: e87eb774adf31c7cccf8ecae23f915bfd36c0135 [file] [log] [blame]
Cosmos Nicolaou87c0a552014-12-02 23:05:49 -08001package platform
Cosmos Nicolaou39a00e02014-08-14 11:04:14 -07002
3// #include <sys/utsname.h>
4// #include <errno.h>
5import "C"
6
7import (
8 "fmt"
9
Jiri Simsa764efb72014-12-25 20:57:03 -080010 "v.io/core/veyron2"
Cosmos Nicolaou39a00e02014-08-14 11:04:14 -070011)
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.
16func 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 Nicolaou39a00e02014-08-14 11:04:14 -070030 return d, nil
31}