summaryrefslogtreecommitdiffhomepage
path: root/src/uss.h
blob: 00245f7f1fa7d07ddad8cb5b01b89efce1aa4cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** @file uss.h
 *  @brief z/OS UNIX readers: processes and mounted file systems.
 *
 *  Two fixed-capacity tables filled in place.  Neither reader allocates, and
 *  on a host that is not z/OS both report the same message the CVT readers
 *  print, so the portable build still links and the view stays honest.
 */
#ifndef ZTOP_USS_H
#define ZTOP_USS_H

#include <stdint.h>

enum {
    USS_MAX_FS = 64,  /**< mounted file systems kept */
    USS_MAX_PS = 128, /**< processes kept */
};

/** @brief One mounted file system, from w_getmntent() and statvfs(). */
typedef struct uss_fs {
    char fsname[45]; /**< aggregate data set name */
    char mount[128]; /**< mount point, trimmed */
    char type[9];    /**< file system type name */
    bool rdonly;     /**< statvfs says ST_RDONLY */
    bool ok;         /**< statvfs succeeded */
    uint64_t kb_total;
    uint64_t kb_free;
    int pct; /**< 0..100, or -1 when the size is unknown */
    int eno; /**< errno from a failed statvfs() */
} uss_fs;

typedef struct uss_fs_list {
    uss_fs fs[USS_MAX_FS];
    int nfs;
    bool truncated;
    char err[160];
} uss_fs_list;

/** @brief One process, from w_getpsent(). */
typedef struct uss_proc {
    int pid;
    int ppid;
    int uid;
    unsigned state; /**< raw ps_state: letter in low bits, flags above */
    char st;        /**< the state letter, ps_state & PS_STATECHAR */
    bool swapped;
    unsigned long cpu_ms; /**< user + system time in milliseconds */
    char tty[16];
    char cmd[64];
} uss_proc;

typedef struct uss_ps_list {
    uss_proc proc[USS_MAX_PS];
    int nproc;
    bool truncated;
    char err[160];
} uss_ps_list;

bool uss_fs_read(uss_fs_list *out);
bool uss_ps_read(uss_ps_list *out);

#endif