crazy Debian GNU/kFreeBSD guy wanted this
This commit is contained in:
parent
6e183316de
commit
f9d99085e7
@ -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;
|
||||
|
@ -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>"
|
||||
|
12
ps/common.h
12
ps/common.h
@ -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)
|
||||
@ -60,15 +60,17 @@
|
||||
* 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 *******************/
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user