diff options
Diffstat (limited to 'src/include-local')
-rw-r--r-- | src/include-local/mount-constants.h | 78 | ||||
-rw-r--r-- | src/include-local/s6-ps.h | 159 |
2 files changed, 237 insertions, 0 deletions
diff --git a/src/include-local/mount-constants.h b/src/include-local/mount-constants.h new file mode 100644 index 0000000..3b30035 --- /dev/null +++ b/src/include-local/mount-constants.h @@ -0,0 +1,78 @@ +/* ISC license. */ + +#ifndef MOUNT_CONSTANTS_H +#define MOUNT_CONSTANTS_H + +/* taken from util-linux */ + +#ifndef MS_RDONLY +#define MS_RDONLY 1 /* Mount read-only */ +#endif +#ifndef MS_NOSUID +#define MS_NOSUID 2 /* Ignore suid and sgid bits */ +#endif +#ifndef MS_NODEV +#define MS_NODEV 4 /* Disallow access to device special files */ +#endif +#ifndef MS_NOEXEC +#define MS_NOEXEC 8 /* Disallow program execution */ +#endif +#ifndef MS_SYNCHRONOUS +#define MS_SYNCHRONOUS 16 /* Writes are synced at once */ +#endif +#ifndef MS_REMOUNT +#define MS_REMOUNT 32 /* Alter flags of a mounted FS */ +#endif +#ifndef MS_MANDLOCK +#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ +#endif +#ifndef MS_DIRSYNC +#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ +#endif +#ifndef MS_NOSYMFOLLOW +#define MS_NOSYMFOLLOW 256 /* Don't follow symlinks */ +#endif +#ifndef MS_NOATIME +#define MS_NOATIME 0x400 /* 1024: Do not update access times. */ +#endif +#ifndef MS_NODIRATIME +#define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */ +#endif +#ifndef MS_BIND +#define MS_BIND 0x1000 /* 4096: Mount existing tree also elsewhere */ +#endif +#ifndef MS_MOVE +#define MS_MOVE 0x2000 /* 8192: Atomically move tree */ +#endif +#ifndef MS_REC +#define MS_REC 0x4000 /* 16384: Recursive loopback */ +#endif +#ifndef MS_SILENT +#define MS_SILENT 0x8000 /* 32768: Don't emit certain kernel messages */ +#endif +#ifndef MS_UNBINDABLE +#define MS_UNBINDABLE (1<<17) /* 131072: Make unbindable */ +#endif +#ifndef MS_PRIVATE +#define MS_PRIVATE (1<<18) /* 262144: Make private */ +#endif +#ifndef MS_SLAVE +#define MS_SLAVE (1<<19) /* 524288: Make slave */ +#endif +#ifndef MS_SHARED +#define MS_SHARED (1<<20) /* 1048576: Make shared */ +#endif +#ifndef MS_RELATIME +#define MS_RELATIME (1<<21) /* 2097152: Update atime relative to mtime/ctime */ +#endif +#ifndef MS_I_VERSION +#define MS_I_VERSION (1<<23) /* Update the inode I_version field */ +#endif +#ifndef MS_STRICTATIME +#define MS_STRICTATIME (1<<24) /* Always perform atime updates */ +#endif +#ifndef MS_LAZYTIME +#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ +#endif + +#endif diff --git a/src/include-local/s6-ps.h b/src/include-local/s6-ps.h new file mode 100644 index 0000000..7c963f1 --- /dev/null +++ b/src/include-local/s6-ps.h @@ -0,0 +1,159 @@ +/* ISC license. */ + +#ifndef S6PS_H +#define S6PS_H + +#include <sys/types.h> +#include <stdint.h> + +#include <skalibs/uint64.h> +#include <skalibs/stralloc.h> +#include <skalibs/tai.h> +#include <skalibs/avltreen.h> + + +typedef struct dius_s dius_t, *dius_t_ref ; +struct dius_s +{ + uint32_t left ; + size_t right ; +} ; +#define DIUS_ZERO { .left = 0, .right = 0 } + +typedef enum pfield_e pfield_t, *pfield_t_ref ; +enum pfield_e +{ + PFIELD_PID, + PFIELD_COMM, + PFIELD_STATE, + PFIELD_PPID, + PFIELD_PGRP, + PFIELD_SESSION, + PFIELD_TTY, + PFIELD_TPGID, + PFIELD_UTIME, + PFIELD_STIME, + PFIELD_CUTIME, + PFIELD_CSTIME, + PFIELD_PRIO, + PFIELD_NICE, + PFIELD_THREADS, + PFIELD_START, + PFIELD_VSIZE, + PFIELD_RSS, + PFIELD_RSSLIM, + PFIELD_CPUNO, + PFIELD_RTPRIO, + PFIELD_RTPOLICY, + PFIELD_USER, + PFIELD_GROUP, + PFIELD_PMEM, + PFIELD_WCHAN, + PFIELD_ARGS, + PFIELD_ENV, + PFIELD_PCPU, + PFIELD_TTIME, + PFIELD_CTTIME, + PFIELD_TSTART, + PFIELD_CPCPU, + PFIELD_PHAIL +} ; + +extern char const *const *s6ps_opttable ; +extern char const *const *s6ps_fieldheaders ; + +typedef struct pscan_s pscan_t, *pscan_t_ref ; +struct pscan_s +{ + stralloc data ; + pid_t pid ; + signed int height ; + size_t statlen ; + size_t commlen ; + size_t cmdlen ; + size_t envlen ; + uid_t uid ; + gid_t gid ; + pid_t ppid ; + unsigned int state ; + pid_t pgrp ; + pid_t session ; + dev_t ttynr ; + pid_t tpgid ; + uint64_t utime ; + uint64_t stime ; + uint64_t cutime ; + uint64_t cstime ; + int prio ; + int nice ; + uint64_t threads ; + uint64_t start ; + uint64_t vsize ; + uint64_t rss ; + uint64_t rsslim ; + uint64_t wchan ; + uint64_t cpuno ; + uint64_t rtprio ; + uint64_t policy ; +} ; + +#define PSCAN_ZERO \ +{ \ + .data = STRALLOC_ZERO, \ + .pid = 0, \ + .height = 0, \ + .statlen = 0, \ + .commlen = 0, \ + .cmdlen = 0, \ + .envlen = 0, \ + .uid = 0, \ + .gid = 0, \ + .ppid = 0, \ + .state = 0, \ + .pgrp = 0, \ + .session = 0, \ + .ttynr = 0, \ + .tpgid = -1, \ + .utime = 0, \ + .stime = 0, \ + .cutime = 0, \ + .cstime = 0, \ + .prio = 0, \ + .nice = 0, \ + .threads = 0, \ + .start = 0, \ + .vsize = 0, \ + .rss = 0, \ + .rsslim = 0, \ + .wchan = 0, \ + .cpuno = 0, \ + .rtprio = 0, \ + .policy = 0 \ +} + +extern int s6ps_statparse (pscan_t *) ; +extern void s6ps_otree (pscan_t *, unsigned int, avltreen *, unsigned int *) ; + +extern int s6ps_compute_boottime (pscan_t *, unsigned int) ; + +typedef int pfieldfmt_func (pscan_t *, size_t *, size_t *) ; +typedef pfieldfmt_func *pfieldfmt_func_ref ; + +extern pfieldfmt_func_ref *s6ps_pfield_fmt ; + +extern void *left_dtok (unsigned int, void *) ; +extern int uint32_cmp (void const *, void const *, void *) ; +extern int s6ps_pwcache_init (void) ; +extern void s6ps_pwcache_finish (void) ; +extern int s6ps_pwcache_lookup (stralloc *, uid_t) ; +extern int s6ps_grcache_init (void) ; +extern void s6ps_grcache_finish (void) ; +extern int s6ps_grcache_lookup (stralloc *, gid_t) ; +extern int s6ps_ttycache_init (void) ; +extern void s6ps_ttycache_finish (void) ; +extern int s6ps_ttycache_lookup (stralloc *, dev_t) ; +extern int s6ps_wchan_init (char const *) ; +extern void s6ps_wchan_finish (void) ; +extern int s6ps_wchan_lookup (stralloc *, uint64_t) ; + +#endif |