svn commit: trunk/busybox/procps

vda at busybox.net vda at busybox.net
Sat Feb 2 16:43:51 UTC 2008


Author: vda
Date: 2008-02-02 08:43:51 -0800 (Sat, 02 Feb 2008)
New Revision: 20930

Log:
ps: add (disabled) compat code



Modified:
   trunk/busybox/procps/ps.c


Changeset:
Modified: trunk/busybox/procps/ps.c
===================================================================
--- trunk/busybox/procps/ps.c	2008-02-02 16:23:43 UTC (rev 20929)
+++ trunk/busybox/procps/ps.c	2008-02-02 16:43:51 UTC (rev 20930)
@@ -157,7 +157,21 @@
 
 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)




More information about the busybox-cvs mailing list