summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Small <csmall@enc.com.au>2014-02-01 00:09:35 +1100
committerCraig Small <csmall@enc.com.au>2014-02-01 00:09:35 +1100
commitbac7454d3bf9fb59092f105a4282ee82a568c892 (patch)
tree3ad69f07e5c7dd680e8749e613366c8a286ee544
parent87702a095569d8de8d80c0b16a7260d194c80645 (diff)
fuser -M and -m flags work either way
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>
-rw-r--r--ChangeLog4
-rw-r--r--src/fuser.c35
2 files changed, 33 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index de416e6..fd1cccf 100644
--- 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
================
diff --git a/src/fuser.c b/src/fuser.c
index e82d6e0..b485f65 100644
--- a/src/fuser.c
+++ b/src/fuser.c
@@ -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;