From: Craig Small Date: Fri, 23 Apr 2004 14:11:02 +0000 (+0000) Subject: Some SF related bugs fixed X-Git-Tag: v22.11~161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b020ab4c080219cffa3baf9bb3b724c68732b723;p=psmisc Some SF related bugs fixed --- diff --git a/src/fuser.c b/src/fuser.c index 75e4826..8e165d6 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -320,7 +320,7 @@ fill_unix_cache (void) static unsigned long -try_to_find_unix_dev (unsigned long inode) +try_to_find_unix_dev (ino_t inode) { UNIX_CACHE *walk; @@ -332,13 +332,13 @@ try_to_find_unix_dev (unsigned long inode) static void -add_file (const char *path, unsigned long device, unsigned long inode, +add_file (const char *path, dev_t device, ino_t inode, pid_t pid, int ref) { struct stat st; FILE_DSC *file, *next; ITEM_DSC **item, *this; - unsigned long mount_dev; + dev_t mount_dev; if (device) mount_dev = device; @@ -382,8 +382,8 @@ add_file (const char *path, unsigned long device, unsigned long inode, static void -add_other (ITEM_TYPE type, unsigned long mount_dev, - unsigned long device, unsigned long inode, const char *path) +add_other (ITEM_TYPE type, dev_t mount_dev, + dev_t device, ino_t inode, const char *path) { FILE_DSC *file, *next; ITEM_DSC **item, *this; @@ -433,16 +433,19 @@ check_map (const char *rel, pid_t pid, int type) FILE *file; char line[MAX_LINE + 1]; int major, minor; - unsigned long inode; + ino_t inode; + unsigned long long tmp_inode; if (!(file = fopen (rel, "r"))) return; while (fgets (line, MAX_LINE, file)) { - if (sscanf (line, "%*s %*s %*s %x:%x %ld", &major, &minor, &inode) != 3) + if (sscanf (line, "%*s %*s %*s %x:%x %lld", &major, &minor, &tmp_inode) != 3) continue; - if (major || minor || inode) - add_file (rel, MKDEV (major, minor), inode, pid, type); + if (major || minor || tmp_inode) { + inode = (ino_t)(tmp_inode); + add_file (rel, MKDEV (major, minor), inode, pid, type); + } } fclose (file); } @@ -893,7 +896,6 @@ parse_inet (const char *spec, const char *name_space, int *lcl_port, address_match = 0; for (here = s; here; here = next ? next + 1 : NULL) { - printf("here: %s\n", here); next = strchr (here, ','); if (next) *next = 0; @@ -1184,7 +1186,7 @@ main (int argc, char **argv) } for (walk = this_name_space->cache; walk; walk = walk->next) if ((lcl_port == -1 || walk->lcl_port == lcl_port) && - (rmt_addr.ss_family = 0|| ( memcmp( + (rmt_addr.ss_family == 0 || ( memcmp( &((struct sockaddr_in6*)&walk->rmt_addr)->sin6_addr, &((struct sockaddr_in6*)&rmt_addr)->sin6_addr, sizeof(struct in6_addr)) == 0) ) && diff --git a/src/killall.c b/src/killall.c index 9bb7ffd..1e9ef67 100644 --- a/src/killall.c +++ b/src/killall.c @@ -38,12 +38,12 @@ #define PROC_BASE "/proc" -#define MAX_NAMES (sizeof(unsigned long)*8) +#define MAX_NAMES (int)(sizeof(unsigned long)*8) -static int verbose = 0, exact = 0, interactive = 0, quiet = - 0, wait_until_dead = 0, process_group = 0, user = 0, pidof; - +static int verbose = 0, exact = 0, interactive = 0, + quiet = 0, wait_until_dead = 0, process_group = 0, + ignore_case = 0, pidof; static int ask (char *name, pid_t pid) @@ -254,8 +254,16 @@ kill_all (int signal, int names, char **namelist) { if (length != COMM_LEN - 1 || name_len[j] < COMM_LEN - 1) { - if (strcmp (namelist[j], comm)) + if (ignore_case == 1) + { + if (strcasecmp (namelist[j], comm)) + continue; + } + else + { + if (strcmp(namelist[j], comm)) continue; + } } else if (got_long ? strcmp (namelist[j], command) : strncmp (namelist[j], comm, COMM_LEN - 1)) @@ -395,6 +403,7 @@ usage_killall (void) fprintf (stderr, " killall -l, --list\n"); fprintf (stderr, " killall -V --version\n\n"); fprintf (stderr, " -e,--exact require exact match for very long names\n"); + fprintf (stderr, " -I,--ignore-case- case insensitive process name match\n"); fprintf (stderr, " -g,--process-group kill process group instead of process\n"); fprintf (stderr, " -i,--interactive ask for confirmation before killing\n"); fprintf (stderr, " -l,--list list all known signal names\n"); @@ -442,6 +451,7 @@ main (int argc, char **argv) struct option options[] = { {"exact", 0, NULL, 'e'}, + {"ignore-case", 0, NULL, 'I'}, {"process-group", 0, NULL, 'g'}, {"interactive", 0, NULL, 'i'}, {"list-signals", 0, NULL, 'l'}, @@ -479,9 +489,9 @@ main (int argc, char **argv) opterr = 0; #ifdef FLASK_LINUX - while ( (optc = getopt_long_only(argc,argv,"egilqs:vwd:c:V",options,NULL)) != EOF) { + while ( (optc = getopt_long_only(argc,argv,"egilqs:vwd:c:VI",options,NULL)) != EOF) { #else - while ( (optc = getopt_long_only(argc,argv,"egilqs:vwV",options,NULL)) != EOF) { + while ( (optc = getopt_long_only(argc,argv,"egilqs:vwVI",options,NULL)) != EOF) { #endif switch (optc) { case 'e': @@ -519,6 +529,9 @@ main (int argc, char **argv) usage(); wait_until_dead = 1; break; + case 'I': + ignore_case = 1; + break; case 'V': print_version(); return 0; diff --git a/src/pstree.c b/src/pstree.c index abb3090..dcbce90 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -128,7 +128,7 @@ out_char (char c) cur_x += (c & 0xc0) != 0x80; /* only count first UTF-8 char */ if (cur_x <= output_width || !trunc) putchar (c); - if (cur_x == output_width + 1 && trunc) + if (cur_x == output_width + 1 && trunc && ((c & 0xc0) != 0x80)) { if (last_char || (c & 0x80)) putchar ('+');