| 31 |  | /* FIXME comments for less obvious fields */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 |  | int sg_init(void); | 
 
 
 
 
 
 
 
 | 34 | + | int sg_snapshot(); | 
 
 
 
 
 
 
 
 | 35 | + | int sg_shutdown(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 36 |  | int sg_drop_privileges(void); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 |  | typedef enum { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 39 |  | SG_ERROR_NONE = 0, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 |  | SG_ERROR_ASPRINTF, | 
 
 
 
 
 
 
 
 | 41 | + | SG_ERROR_DEVICES, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 |  | SG_ERROR_DEVSTAT_GETDEVS, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | SG_ERROR_DEVSTAT_SELECTDEVS, | 
 
 
 
 
 
 
 
 | 44 | + | SG_ERROR_DISKINFO, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 |  | SG_ERROR_ENOENT, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 |  | SG_ERROR_GETIFADDRS, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 |  | SG_ERROR_GETMNTINFO, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 |  | SG_ERROR_GETPAGESIZE, | 
 
 
 
 
 
 
 
 | 49 | + | SG_ERROR_HOST, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 |  | SG_ERROR_KSTAT_DATA_LOOKUP, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 |  | SG_ERROR_KSTAT_LOOKUP, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 |  | SG_ERROR_KSTAT_OPEN, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 |  | SG_ERROR_KVM_GETSWAPINFO, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 55 |  | SG_ERROR_KVM_OPENFILES, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 |  | SG_ERROR_MALLOC, | 
 
 
 
 
 
 
 
 | 57 | + | SG_ERROR_MEMSTATUS, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 |  | SG_ERROR_OPEN, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 |  | SG_ERROR_OPENDIR, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 60 |  | SG_ERROR_PARSE, | 
 
 
 
 
 
 
 
 | 61 | + | SG_ERROR_PDHADD, | 
 
 
 
 
 
 
 
 | 62 | + | SG_ERROR_PDHCOLLECT, | 
 
 
 
 
 
 
 
 | 63 | + | SG_ERROR_PDHOPEN, | 
 
 
 
 
 
 
 
 | 64 | + | SG_ERROR_PDHREAD, | 
 
 
 
 
 
 
 
 | 65 | + | SG_ERROR_PERMISSION, | 
 
 
 
 
 
 
 
 | 66 | + | SG_ERROR_PSTAT, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 67 |  | SG_ERROR_SETEGID, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 68 |  | SG_ERROR_SETEUID, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 69 |  | SG_ERROR_SETMNTENT, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 |  | SG_ERROR_SYSCTLNAMETOMIB, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 76 |  | SG_ERROR_UNAME, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 |  | SG_ERROR_UNSUPPORTED, | 
 
 
 
 
 
 
 
 
 
 
 | 78 | < | SG_ERROR_XSW_VER_MISMATCH, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 67 | < | SG_ERROR_PSTAT | 
 
 
 
 
 
 
 
 
 | 78 | > | SG_ERROR_XSW_VER_MISMATCH | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 |  | } sg_error; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 |  | void sg_set_error(sg_error code, const char *arg); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 252 |  | pid_t parent; /* Parent pid */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 253 |  | pid_t pgid;   /* process id of process group leader */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 254 |  |  | 
 
 
 
 
 
 
 
 | 255 | + | /* Windows does not have uid_t or gid_t types */ | 
 
 
 
 
 
 
 
 | 256 | + | #ifndef WIN32 | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 257 |  | uid_t uid; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 258 |  | uid_t euid; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 259 |  | gid_t gid; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 260 |  | gid_t egid; | 
 
 
 
 
 
 
 
 | 261 | + | #else | 
 
 
 
 
 
 
 
 | 262 | + | int uid; | 
 
 
 
 
 
 
 
 | 263 | + | int euid; | 
 
 
 
 
 
 
 
 | 264 | + | int gid; | 
 
 
 
 
 
 
 
 | 265 | + | int egid; | 
 
 
 
 
 
 
 
 | 266 | + | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 267 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 268 |  | unsigned long long proc_size; /* in bytes */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 269 |  | unsigned long long proc_resident; /* in bytes */ |