]> granicus.if.org Git - procps-ng/commitdiff
crazy Debian GNU/kFreeBSD guy wanted this
authoralbert <>
Thu, 27 Jan 2005 04:08:10 +0000 (04:08 +0000)
committeralbert <>
Thu, 27 Jan 2005 04:08:10 +0000 (04:08 +0000)
proc/devname.c
proc/escape.h
ps/common.h
ps/global.c
ps/output.c

index a80313c715ddec53b78eeef019e26909297c5fcf..2fe7ea5b12753b7e8a2cb0ef240e1ec02078006f 100644 (file)
@@ -22,7 +22,7 @@
 // This is the buffer size for a tty name. Any path is legal,
 // which makes PAGE_SIZE appropriate (see kernel source), but
 // that is only 99% portable and utmp only holds 32 anyway.
-#define NAME_SIZE 128
+#define TTY_NAME_SIZE 128
 
 /* Who uses what:
  *
@@ -219,7 +219,7 @@ static int link_name(char *restrict const buf, unsigned maj, unsigned min, int p
   char path[32];
   int count;
   sprintf(path, "/proc/%d/%s", pid, name);  /* often permission denied */
-  count = readlink(path,buf,NAME_SIZE-1);
+  count = readlink(path,buf,TTY_NAME_SIZE-1);
   if(count == -1) return 0;
   buf[count] = '\0';
   if(stat(buf, &sbuf) < 0) return 0;
@@ -230,7 +230,7 @@ static int link_name(char *restrict const buf, unsigned maj, unsigned min, int p
 
 /* number --> name */
 unsigned dev_to_tty(char *restrict ret, unsigned chop, dev_t dev_t_dev, int pid, unsigned int flags) {
-  static char buf[NAME_SIZE];
+  static char buf[TTY_NAME_SIZE];
   char *restrict tmp = buf;
   unsigned dev = dev_t_dev;
   unsigned i = 0;
index 7b9400ad36d3e63d403af2a726a8cb5602c0a946..172960f5842c2a8dfef49c90841718636c43c584 100644 (file)
@@ -8,6 +8,8 @@
 
 EXTERN_C_BEGIN
 
+#define ESC_STRETCH 1  // since we mangle to '?' this is 1 (would be 4 for octal escapes)
+
 #define ESC_ARGS     0x1  // try to use cmdline instead of cmd
 #define ESC_BRACKETS 0x2  // if using cmd, put '[' and ']' around it
 #define ESC_DEFUNCT  0x4  // mark zombies with " <defunct>"
index b8b180c1b9a8e15c5eb726bf47a2bb101da20e02..0b47d9069926eb7ed805807487efe4a2ca56a0fe 100644 (file)
@@ -13,8 +13,8 @@
 #define PROCPS_PS_H
 
 #include "../proc/procps.h"
+#include "../proc/escape.h"
 #include "../proc/readproc.h"
-#include <asm/page.h>  /* looks safe for glibc, we need PAGE_SIZE */
 
 #if 0
 #define trace(args...) printf(## args)
  * Try not to overflow the output buffer:
  *    32 pages for env+cmd
  *    64 kB pages on IA-64
- *    4 chars for "\377"
+ *    4 chars for "\377", or 1 when mangling to '?'  (ESC_STRETCH)
  *    plus some slack for other stuff
  * That is about 8.5 MB on IA-64, or 0.6 MB on i386
+ *
+ * Sadly, current kernels only supply one page of env/command data.
+ * The buffer is now protected with a guard page, and via other means
+ * to avoid hitting the guard page.
  */
 
-/* maximum escape expansion is 4, for \377 */
-#define ESC_STRETCH 4
 /* output buffer size */
-#define OUTBUF_SIZE (32*PAGE_SIZE*ESC_STRETCH + 8*PAGE_SIZE)
+#define OUTBUF_SIZE (2 * 64*1024 * ESC_STRETCH)
 
 /******************* PS DEFINE *******************/
 
index bef10ea1a13451a511e926f05d19db4d6711c07a..b54f4eb47481639d9214677d3455d64bb7dce95f 100644 (file)
@@ -479,10 +479,10 @@ void self_info(void){
 
   fprintf(stderr,
     "personality=0x%08x (from \"%s\")\n"
-    "EUID=%d TTY=%d,%d Hertz=%Ld PAGE_SIZE=%d page_size=%d\n",
+    "EUID=%d TTY=%d,%d Hertz=%Ld page_size=%d\n",
     personality, saved_personality_text,
     cached_euid, (int)major(cached_tty), (int)minor(cached_tty), Hertz,
-    (int)(PAGE_SIZE), (int)(page_size)
+    (int)(page_size)
   );
 
   fprintf(stderr,
index f4e4beabe9c6655ac94218175a3b67b6d4deb0cc..00d66d8304d8038bc98f4b6a47f6b6df785528cd 100644 (file)
@@ -696,7 +696,7 @@ static int pr_tty4(char *restrict const outbuf, const proc_t *restrict const pp)
 /* Unix98: format is unspecified, but must match that used by who(1). */
 static int pr_tty8(char *restrict const outbuf, const proc_t *restrict const pp){
 /* snprintf(outbuf, COLWID, "%02x:%02x", pp->tty>>8, pp->tty&0xff); */
-  return dev_to_tty(outbuf, PAGE_SIZE-1, pp->tty, pp->XXXID, ABBREV_DEV);
+  return dev_to_tty(outbuf, COLWID, pp->tty, pp->XXXID, ABBREV_DEV);
 }
 
 #if 0
@@ -804,7 +804,7 @@ static int pr_alarm(char *restrict const outbuf, const proc_t *restrict const pp
 
 /* HP-UX puts this in pages and uses "vsz" for kB */
 static int pr_sz(char *restrict const outbuf, const proc_t *restrict const pp){
-  return snprintf(outbuf, COLWID, "%lu", (pp->vm_size)/(PAGE_SIZE/1024));
+  return snprintf(outbuf, COLWID, "%lu", (pp->vm_size)/(page_size/1024));
 }