library: tweak 'other' user/group names for efficiency
This commit just ensures that the relatively expensive ID to name conversions aren't performed unless they're explicitly requested. It also internalizes those flags that required the PROC_FILLSTATUS flag to also be set. [ requiring a caller, in our case pids.c, to provide ] [ two flags when a single field was the objective is ] [ wrong & represents a future potential toe-stubber. ] [ moreover, what's worse is that those two flags are ] [ seemingly unrelated. but, without both, a SEGV can ] [ can be expected when a result.str pointer is NULL. ] [ by contrast, in the master branch those fields are ] [ arrays which, when set to zeroes, produce an empty ] [ string. So, there is no abend (but no name either) ] [ when one of those two required flags were omitted. ] [ and worth noting, in that branch it's not just one ] [ caller required to observe a two flag requirement. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@@ -207,7 +207,6 @@ typedef struct PROCTAB {
|
||||
#define PROC_FILLSTATUS 0x0020 // read status
|
||||
#define PROC_FILLSTAT 0x0040 // read stat
|
||||
#define PROC_FILLCGROUP 0x0200 // alloc and fill in `cgroup` vectors
|
||||
#define PROC_FILLSUPGRP 0x0400 // resolve supplementary group id -> group name
|
||||
#define PROC_FILLOOM 0x0800 // fill in proc_t oom_score and oom_adj
|
||||
#define PROC_FILLNS 0x8000 // fill in proc_t namespace information
|
||||
#define PROC_FILLSYSTEMD 0x80000 // fill in proc_t systemd information
|
||||
@@ -224,6 +223,11 @@ typedef struct PROCTAB {
|
||||
#define PROC_EDITCMDLCVT 0x20000 // edit `cmdline' as regular string
|
||||
#define PROC_EDITENVRCVT 0x40000 // edit `environ' as regular string
|
||||
|
||||
// these three also require the PROC_FILLSTATUS flage
|
||||
#define PROC_FILL_OUSERS ( 0x0080 | PROC_FILLSTATUS ) // obtain other user names
|
||||
#define PROC_FILL_OGROUPS ( 0x0100 | PROC_FILLSTATUS ) // obtain other group names
|
||||
#define PROC_FILL_SUPGRP ( 0x0400 | PROC_FILLSTATUS ) // obtain supplementary group names
|
||||
|
||||
// it helps to give app code a few spare bits
|
||||
#define PROC_SPARE_1 0x01000000
|
||||
#define PROC_SPARE_2 0x02000000
|
||||
|
||||
Reference in New Issue
Block a user