summaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-02-02 16:43:51 +0000
committerDenis Vlasenko2008-02-02 16:43:51 +0000
commit5de754a395a36afe7ed89f300d3421ef05c2401b (patch)
tree37b1a19ed3664b093551ee228a7c62e6a4c92f61 /procps/ps.c
parent7cff01ec2dcdd04657fca1b5c572cb2b53d2d4aa (diff)
downloadbusybox-5de754a395a36afe7ed89f300d3421ef05c2401b.zip
busybox-5de754a395a36afe7ed89f300d3421ef05c2401b.tar.gz
ps: add (disabled) compat code
Diffstat (limited to 'procps/ps.c')
-rw-r--r--procps/ps.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 3002fb9..e954da6 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -157,7 +157,21 @@ static unsigned get_kernel_HZ(void)
static void func_user(char *buf, int size, const procps_status_t *ps)
{
+#if 1
safe_strncpy(buf, get_cached_username(ps->uid), size+1);
+#else
+ /* "compatible" version, but it's larger */
+ /* procps 2.18 shows numeric UID if name overflows the field */
+ /* TODO: get_cached_username() returns numeric string if
+ * user has no passwd record, we will display it
+ * left-justified here; too long usernames are shown
+ * as _right-justified_ IDs. Is it worth fixing? */
+ const char *user = get_cached_username(ps->uid);
+ if (strlen(user) <= size)
+ safe_strncpy(buf, get_cached_username(ps->uid), size+1);
+ else
+ sprintf(buf, "%*u", size, (unsigned)ps->uid);
+#endif
}
static void func_comm(char *buf, int size, const procps_status_t *ps)