]> granicus.if.org Git - psmisc/commitdiff
Some SF related bugs fixed
authorCraig Small <csmall@users.sourceforge.net>
Fri, 23 Apr 2004 14:11:02 +0000 (14:11 +0000)
committerCraig Small <csmall@users.sourceforge.net>
Fri, 23 Apr 2004 14:11:02 +0000 (14:11 +0000)
src/fuser.c
src/killall.c
src/pstree.c

index 75e482673f79a2180e558d74daef1e4b864c78ef..8e165d63653af5d18d8674834fafb9ac9e45dfc3 100644 (file)
@@ -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) ) &&
index 9bb7ffd8edbda8fe3bd0dc6a95b23f88e1cc7a17..1e9ef67052ad870c353b09d324d16dc2f12fe25a 100644 (file)
 
 
 #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;
index abb3090e566d300cd513095bc6298d5efc7e9072..dcbce900dbef9b00c891712d15feaf466fdb97e3 100644 (file)
@@ -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 ('+');