From 499dfe62817f46e2132dd265dbe3603e5929279e Mon Sep 17 00:00:00 2001 From: Jan Rybar Date: Tue, 19 Feb 2019 16:39:17 +0100 Subject: [PATCH 04/11] NULLptr sanity added in scan fns to avoid useless prep work (stalls NFS) --- src/fuser.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/fuser.c b/src/fuser.c index c44cee8..b8662a3 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -188,6 +188,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head, pid_t pid, my_pid; uid_t uid; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + if ((topproc_dir = opendir("/proc")) == NULL) { fprintf(stderr, _("Cannot open /proc directory: %s\n"), strerror(errno)); @@ -1873,6 +1876,10 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + + if ((fp = fopen(KNFSD_EXPORTS, "r")) == NULL) { #ifdef DEBUG printf("Cannot open %s\n", KNFSD_EXPORTS); @@ -1919,6 +1926,10 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + + if ((fp = fopen(PROC_MOUNTS, "r")) == NULL) { fprintf(stderr, "Cannot open %s\n", PROC_MOUNTS); return; @@ -1962,6 +1973,9 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, char *find_space; struct stat st; + if ( (ino_head == NULL) && (dev_head == NULL) ) + return; + if ((fp = fopen(PROC_SWAPS, "r")) == NULL) { /*fprintf(stderr, "Cannot open %s\n", PROC_SWAPS); */ return; -- 2.20.1