From: Craig Small Date: Wed, 11 Sep 2013 11:34:05 +0000 (+1000) Subject: Merge commit 'refs/merge-requests/13' of git://gitorious.org/procps/procps into merge... X-Git-Tag: v3.3.9~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd6f24dbed12e95235b3df49e550b5039e74e6d8;p=procps-ng Merge commit 'refs/merge-requests/13' of git://gitorious.org/procps/procps into merge-requests/13 Conflicts: pgrep.c ps/output.c ps/ps.1 --- dd6f24dbed12e95235b3df49e550b5039e74e6d8 diff --cc ps/output.c index d457a89c,1d05fbb6..2e9056e5 --- a/ps/output.c +++ b/ps/output.c @@@ -1173,112 -1183,23 +1187,128 @@@ static int pr_sgi_p(char *restrict cons return snprintf(outbuf, COLWID, "*"); } +#ifdef WITH_SYSTEMD +/************************* Systemd stuff ********************************/ +static int pr_sd_unit(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *unit; + + r = sd_pid_get_unit(pp->tgid, &unit); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", unit); + free(unit); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +static int pr_sd_session(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *session; + + r = sd_pid_get_session(pp->tgid, &session); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", session); + free(session); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +static int pr_sd_ouid(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + uid_t ouid; + + r = sd_pid_get_owner_uid(pp->tgid, &ouid); + if(r<0) goto fail; + return snprintf(outbuf, COLWID, "%d", ouid); + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +static int pr_sd_machine(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *machine; + r = sd_pid_get_machine_name(pp->tgid, &machine); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", machine); + free(machine); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +static int pr_sd_uunit(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *unit; + + r = sd_pid_get_user_unit(pp->tgid, &unit); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", unit); + free(unit); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +static int pr_sd_seat(char *restrict const outbuf, const proc_t *restrict const pp){ + int r; + size_t len; + char *session; + char *seat; + r = sd_pid_get_session(pp->tgid, &session); + if(r<0) goto fail; + r = sd_session_get_seat(session, &seat); + free(session); + if(r<0) goto fail; + len = snprintf(outbuf, COLWID, "%s", seat); + free(seat); + return len; + +fail: + outbuf[0] = '-'; + outbuf[1] = '\0'; + return 1; +} + +#endif + /************************ Linux namespaces ******************************/ + + #define _pr_ns(NAME, ID)\ + static int pr_##NAME(char *restrict const outbuf, const proc_t *restrict const pp) {\ + if (pp->ns[ID])\ + return snprintf(outbuf, COLWID, "%li", pp->ns[ID]);\ + else\ + return snprintf(outbuf, COLWID, "-");\ + } + _pr_ns(ipcns, IPCNS); + _pr_ns(mntns, MNTNS); + _pr_ns(netns, NETNS); + _pr_ns(pidns, PIDNS); + _pr_ns(userns, USERNS); + _pr_ns(utsns, UTSNS); + /****************** FLASK & seLinux security stuff **********************/ // move the bulk of this to libproc sometime @@@ -1698,9 -1605,7 +1734,10 @@@ static const format_struct format_array {"usrpri", "UPR", pr_nop, sr_nop, 3, 0, DEC, TO|RIGHT}, /*upr*/ {"util", "C", pr_c, sr_pcpu, 2, 0, SGI, ET|RIGHT}, // not sure about "C" {"utime", "UTIME", pr_nop, sr_utime, 6, 0, LNx, ET|RIGHT}, + {"utsns", "UTSNS", pr_utsns, sr_utsns, 10, NS, LNX, ET|RIGHT}, +#ifdef WITH_SYSTEMD +{"uunit", "UUNIT", pr_sd_uunit, sr_nop, 31, 0, LNX, ET|LEFT}, +#endif {"vm_data", "DATA", pr_nop, sr_vm_data, 5, 0, LNx, PO|RIGHT}, {"vm_exe", "EXE", pr_nop, sr_vm_exe, 5, 0, LNx, PO|RIGHT}, {"vm_lib", "LIB", pr_nop, sr_vm_lib, 5, 0, LNx, PO|RIGHT}, diff --cc ps/ps.1 index 6311b48b,fd774135..80e5ce87 --- a/ps/ps.1 +++ b/ps/ps.1 @@@ -1735,10 -1731,14 +1751,18 @@@ se .BR euser , \ uname ). T} + userns USERNS T{ + Unique inode number describing the namespace the process belongs to. See namespaces(7). + T} + + utsns UTSNS T{ + Unique inode number describing the namespace the process belongs to. See namespaces(7). + T} + +uunit UUNIT T{ +displays systemd user unit which a process belongs to. +T} + vsize VSZ T{ see .BR vsz .