]> granicus.if.org Git - psmisc/commitdiff
fuser -M and -m flags work either way
authorCraig Small <csmall@enc.com.au>
Fri, 31 Jan 2014 13:09:35 +0000 (00:09 +1100)
committerCraig Small <csmall@enc.com.au>
Fri, 31 Jan 2014 13:09:35 +0000 (00:09 +1100)
Previously fuser -M -m /dir worked while fuser -m /dir -M would
not limit the search. This change means either way will work.

References: http://bugs.debian.org/606178

Signed-off-by: Craig Small <csmall@enc.com.au>
ChangeLog
src/fuser.c

index de416e6493f37b1ba4faa62211a408eb0d5c71fc..fd1cccf3738d339bb70b09dff395b8c90d7592c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@ Changes in 22.21
        * pstree shows proper thread names SF Bug#57
        * pstree shows namespace options SF Patch#30
        * killall.1 minor fixes SF Bug#59
+       * peekfd for m68k SF Patch#31
+       * Fixing some derefefed pointers SF Patch#32
+       * Minor typos in man pages SF Bug#61 Bug#60
+       * fuser -m and -M flags work either way Debian #606178
 
 Changes in 22.20
 ================
index e82d6e071dfb6842691d465f01dc6bd3a412dc2b..b485f65c13bee4acf55adc651b1a6eeaf63dbb23 100644 (file)
@@ -4,7 +4,7 @@
  * Based on fuser.c Copyright (C) 1993-2005 Werner Almesberger and Craig Small
  *
  * Completely re-written
- * Copyright (C) 2005-2012 Craig Small
+ * Copyright (C) 2005-2014 Craig Small
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -884,6 +884,29 @@ static int is_mountpoint(struct mount_list **mnt_list, char *arg)
        return 0;
 }
 
+static void check_mountpoints(struct mount_list **mnt_list, struct names **head, struct names **tail)
+{
+    struct names *this, *last;
+
+    last = NULL;
+    for(this = *head; this != NULL; this = this->next) {
+       if (this->name_space == NAMESPACE_FILE &&
+               !is_mountpoint(mnt_list, this->filename)) {
+           fprintf(stderr,
+                   _("Specified filename %s is not a mountpoint.\n"),
+                   this->filename);
+           /* Remove from list */
+           if (last)
+               last->next = this->next;
+           if (*head == this)
+               *head = this->next;
+           if (*tail == this)
+               *tail = last;
+       } else {
+           last = this;
+       }
+    }
+}
 int main(int argc, char *argv[])
 {
        opt_type opts;
@@ -1100,11 +1123,6 @@ int main(int argc, char *argv[])
                    && this_name->name_space != NAMESPACE_FILE)
                        usage(_
                              ("You can only use files with mountpoint options"));
-               if (opts & OPT_ISMOUNTPOINT &&
-                   !is_mountpoint(&mounts, current_argv)) {
-                       free(this_name);
-                       continue;
-               }
                switch (this_name->name_space) {
                case NAMESPACE_TCP:
                        if (asprintf
@@ -1155,6 +1173,11 @@ int main(int argc, char *argv[])
        if (names_head == NULL)
                usage(_("No process specification given"));
 
+       /* Check if -M flag was used and if so check mounts */
+       if (opts * OPT_ISMOUNTPOINT) {
+           check_mountpoints(&mounts, &names_head, &names_tail);
+       }
+
        if (opts & OPT_SILENT) {
                opts &= ~OPT_VERBOSE;
                opts &= ~OPT_USER;