svn commit: r227834 - head/sys/fs/procfs

Mikolaj Golub trociny at FreeBSD.org
Tue Nov 22 20:43:04 UTC 2011


Author: trociny
Date: Tue Nov 22 20:43:03 2011
New Revision: 227834
URL: http://svn.freebsd.org/changeset/base/227834

Log:
  In procfs_doproccmdline() if arguments are not cashed read them from
  the process stack.
  
  Suggested by:	kib
  Reviewed by:	kib
  Tested by:	pho
  MFC after:	2 weeks

Modified:
  head/sys/fs/procfs/procfs_status.c

Modified: head/sys/fs/procfs/procfs_status.c
==============================================================================
--- head/sys/fs/procfs/procfs_status.c	Tue Nov 22 20:40:18 2011	(r227833)
+++ head/sys/fs/procfs/procfs_status.c	Tue Nov 22 20:43:03 2011	(r227834)
@@ -170,15 +170,10 @@ procfs_doprocstatus(PFS_FILL_ARGS)
 int
 procfs_doproccmdline(PFS_FILL_ARGS)
 {
-	struct ps_strings pstr;
-	char **ps_argvstr;
-	int error, i;
 
 	/*
 	 * If we are using the ps/cmdline caching, use that.  Otherwise
-	 * revert back to the old way which only implements full cmdline
-	 * for the current process and just p->p_comm for all other
-	 * processes.
+	 * read argv from the process space.
 	 * Note that if the argv is no longer available, we deliberately
 	 * don't fall back on p->p_comm or return an error: the authentic
 	 * Linux behaviour is to return zero-length in this case.
@@ -190,30 +185,13 @@ procfs_doproccmdline(PFS_FILL_ARGS)
 		PROC_UNLOCK(p);
 		return (0);
 	}
-	PROC_UNLOCK(p);
-	if (p != td->td_proc) {
-		sbuf_printf(sb, "%.*s", MAXCOMLEN, p->p_comm);
-	} else {
-		error = copyin((void *)p->p_sysent->sv_psstrings, &pstr,
-		    sizeof(pstr));
-		if (error)
-			return (error);
-		if (pstr.ps_nargvstr > ARG_MAX)
-			return (E2BIG);
-		ps_argvstr = malloc(pstr.ps_nargvstr * sizeof(char *),
-		    M_TEMP, M_WAITOK);
-		error = copyin((void *)pstr.ps_argvstr, ps_argvstr,
-		    pstr.ps_nargvstr * sizeof(char *));
-		if (error) {
-			free(ps_argvstr, M_TEMP);
-			return (error);
-		}
-		for (i = 0; i < pstr.ps_nargvstr; i++) {
-			sbuf_copyin(sb, ps_argvstr[i], 0);
-			sbuf_printf(sb, "%c", '\0');
-		}
-		free(ps_argvstr, M_TEMP);
+
+	if ((p->p_flag & P_SYSTEM) != 0) {
+		PROC_UNLOCK(p);
+		return (0);
 	}
 
-	return (0);
+	PROC_UNLOCK(p);
+
+	return (proc_getargv(td, p, sb, ARG_MAX));
 }


More information about the svn-src-head mailing list