diff options
| author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-05 00:43:51 +0000 |
|---|---|---|
| committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-05 00:43:51 +0000 |
| commit | 48b1ebd12ec4ef182b4ea423f2309705ae141e8e (patch) | |
| tree | 5deb7d2b82c280440761cceb4281738867d5631a /include | |
| parent | d2c185589694b83e492144a6a5d0f79e16dd9b74 (diff) | |
| download | busybox-w32-48b1ebd12ec4ef182b4ea423f2309705ae141e8e.tar.gz busybox-w32-48b1ebd12ec4ef182b4ea423f2309705ae141e8e.tar.bz2 busybox-w32-48b1ebd12ec4ef182b4ea423f2309705ae141e8e.zip | |
replace /proc scanning code by more versatile one.
Use it where appropriate.
Stop scanning /etc/passwd *for every process*!!! (uid->username)
top: reduce memory usage - we won't save unneeded fields
from /proc info anymore. Downside: ~+250 bytes of code
git-svn-id: svn://busybox.net/trunk/busybox@16509 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'include')
| -rw-r--r-- | include/libbb.h | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/include/libbb.h b/include/libbb.h index 7b5221d87..607433118 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -501,23 +501,47 @@ enum { COMM_LEN = 16 }; | |||
| 501 | #endif | 501 | #endif |
| 502 | #endif | 502 | #endif |
| 503 | typedef struct { | 503 | typedef struct { |
| 504 | int pid, ppid; | 504 | DIR *dir; |
| 505 | char user[9]; | 505 | /* Fields are set to 0/NULL if failed to determine (or not requested) */ |
| 506 | char state[4]; | 506 | char *cmd; |
| 507 | unsigned long rss; | 507 | unsigned long rss; |
| 508 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE | ||
| 509 | unsigned pcpu; | ||
| 510 | unsigned long stime, utime; | 508 | unsigned long stime, utime; |
| 511 | #endif | 509 | unsigned pid; |
| 512 | char *cmd; | 510 | unsigned ppid; |
| 513 | 511 | unsigned pgid; | |
| 514 | /* basename of executable file in call to exec(2), | 512 | unsigned sid; |
| 515 | size from kernel headers */ | 513 | unsigned uid; |
| 516 | char short_cmd[COMM_LEN]; | 514 | unsigned gid; |
| 515 | /* basename of executable file in call to exec(2), size from */ | ||
| 516 | /* sizeof(task_struct.comm) in /usr/include/linux/sched.h */ | ||
| 517 | char state[4]; | ||
| 518 | char comm[COMM_LEN]; | ||
| 519 | // user/group? - use passwd/group parsing functions | ||
| 517 | } procps_status_t; | 520 | } procps_status_t; |
| 518 | procps_status_t* procps_scan(int save_user_arg0); | 521 | enum { |
| 522 | PSSCAN_PID = 1 << 0, | ||
| 523 | PSSCAN_PPID = 1 << 1, | ||
| 524 | PSSCAN_PGID = 1 << 2, | ||
| 525 | PSSCAN_SID = 1 << 3, | ||
| 526 | PSSCAN_UIDGID = 1 << 4, | ||
| 527 | PSSCAN_COMM = 1 << 5, | ||
| 528 | PSSCAN_CMD = 1 << 6, | ||
| 529 | PSSCAN_STATE = 1 << 7, | ||
| 530 | PSSCAN_RSS = 1 << 8, | ||
| 531 | PSSCAN_STIME = 1 << 9, | ||
| 532 | PSSCAN_UTIME = 1 << 10, | ||
| 533 | /* These are all retrieved from proc/NN/stat in one go: */ | ||
| 534 | PSSCAN_STAT = PSSCAN_PPID | PSSCAN_PGID | PSSCAN_SID | ||
| 535 | | PSSCAN_COMM | PSSCAN_STATE | ||
| 536 | | PSSCAN_RSS | PSSCAN_STIME | PSSCAN_UTIME, | ||
| 537 | }; | ||
| 538 | procps_status_t* alloc_procps_scan(int flags); | ||
| 539 | void free_procps_scan(procps_status_t* sp); | ||
| 540 | procps_status_t* procps_scan(procps_status_t* sp, int flags); | ||
| 519 | pid_t *find_pid_by_name(const char* procName); | 541 | pid_t *find_pid_by_name(const char* procName); |
| 520 | pid_t *pidlist_reverse(pid_t *pidList); | 542 | pid_t *pidlist_reverse(pid_t *pidList); |
| 543 | void clear_username_cache(void); | ||
| 544 | const char* get_cached_username(uid_t uid); | ||
| 521 | 545 | ||
| 522 | 546 | ||
| 523 | extern const char bb_uuenc_tbl_base64[]; | 547 | extern const char bb_uuenc_tbl_base64[]; |
