|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
From 28805c3dda0ce9c78f046974454c0bb8dfee615b Mon Sep 17 00:00:00 2001
|
|
|
|
|
From b2adb830fb54f1d4ae227008fc8894aa9b202f82 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Werner Fink <werner@suse.de>
|
|
|
|
|
Date: Thu, 29 Jun 2017 15:18:28 +0200
|
|
|
|
|
Date: Mon, 22 Oct 2018 12:02:50 +0200
|
|
|
|
|
Subject: [PATCH] Use mountinfo to be able to use the mount identity
|
|
|
|
|
|
|
|
|
|
which allows to distinguish different mounts with the
|
|
|
|
@@ -14,11 +14,11 @@ get the real mount ID for each file
|
|
|
|
|
Signed-off-by: Werner Fink <werner@suse.de>
|
|
|
|
|
---
|
|
|
|
|
configure.ac | 18 +-
|
|
|
|
|
src/fuser.c | 540 +++++++++++++++++++++--------
|
|
|
|
|
src/fuser.c | 532 +++++++++++++++++++++++++++----------
|
|
|
|
|
src/fuser.h | 19 +-
|
|
|
|
|
testsuite/Makefile.am | 3 +-
|
|
|
|
|
testsuite/killall.test/killall.exp | 4 +
|
|
|
|
|
5 files changed, 436 insertions(+), 148 deletions(-)
|
|
|
|
|
5 files changed, 432 insertions(+), 144 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git configure.ac configure.ac
|
|
|
|
|
index 176a2fc..d8d3366 100644
|
|
|
|
@@ -64,7 +64,7 @@ index 176a2fc..d8d3366 100644
|
|
|
|
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
|
|
|
|
AC_C_CONST
|
|
|
|
|
diff --git src/fuser.c src/fuser.c
|
|
|
|
|
index 31ef30c..e5337cd 100644
|
|
|
|
|
index c44cee8..78d2683 100644
|
|
|
|
|
--- src/fuser.c
|
|
|
|
|
+++ src/fuser.c
|
|
|
|
|
@@ -32,6 +32,10 @@
|
|
|
|
@@ -78,7 +78,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
@@ -78,7 +82,7 @@ static void check_map(const pid_t pid, const char *filename,
|
|
|
|
|
@@ -79,7 +83,7 @@ static void check_map(const pid_t pid, const char *filename,
|
|
|
|
|
struct device_list *dev_head,
|
|
|
|
|
struct inode_list *ino_head, const uid_t uid,
|
|
|
|
|
const char access);
|
|
|
|
@@ -87,7 +87,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
static uid_t getpiduid(const pid_t pid);
|
|
|
|
|
static int print_matches(struct names *names_head, const opt_type opts,
|
|
|
|
|
const int sig_number);
|
|
|
|
|
@@ -88,8 +92,8 @@ static int kill_matched_proc(struct procs *pptr, const opt_type opts,
|
|
|
|
|
@@ -89,8 +93,8 @@ static int kill_matched_proc(struct procs *pptr, const opt_type opts,
|
|
|
|
|
/*int parse_mount(struct names *this_name, struct device_list **dev_list);*/
|
|
|
|
|
static void add_device(struct device_list **dev_list,
|
|
|
|
|
struct names *this_name, dev_t device);
|
|
|
|
@@ -98,7 +98,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
static void atexit_clear_unix_cache();
|
|
|
|
|
static dev_t find_net_dev(void);
|
|
|
|
|
static void scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -108,9 +112,12 @@ static void debug_match_lists(struct names *names_head,
|
|
|
|
|
@@ -109,9 +113,12 @@ static void debug_match_lists(struct names *names_head,
|
|
|
|
|
struct device_list *dev_head);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@@ -112,7 +112,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
static int mntstat(const char *path, struct stat *buf);
|
|
|
|
|
#endif
|
|
|
|
|
static stat_t thestat = stat;
|
|
|
|
|
@@ -198,6 +205,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -199,6 +206,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
struct stat *cwd_stat = NULL;
|
|
|
|
|
struct stat *exe_stat = NULL;
|
|
|
|
|
struct stat *root_stat = NULL;
|
|
|
|
@@ -120,7 +120,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
|
|
|
|
|
if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */
|
|
|
|
|
continue;
|
|
|
|
|
@@ -207,9 +215,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -208,9 +216,9 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
continue;
|
|
|
|
|
uid = getpiduid(pid);
|
|
|
|
|
|
|
|
|
@@ -133,7 +133,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
cwd_dev = cwd_stat ? cwd_stat->st_dev : 0;
|
|
|
|
|
exe_dev = exe_stat ? exe_stat->st_dev : 0;
|
|
|
|
|
root_dev = root_stat ? root_stat->st_dev : 0;
|
|
|
|
|
@@ -217,21 +225,21 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -218,21 +226,21 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
/* Scan the devices */
|
|
|
|
|
for (dev_tmp = dev_head; dev_tmp != NULL;
|
|
|
|
|
dev_tmp = dev_tmp->next) {
|
|
|
|
@@ -165,7 +165,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if (exe_stat
|
|
|
|
|
&& exe_stat->st_dev == ino_tmp->device
|
|
|
|
|
&& exe_stat->st_ino == ino_tmp->inode)
|
|
|
|
|
@@ -240,7 +248,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -241,7 +249,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
}
|
|
|
|
|
if (root_dev == ino_tmp->device) {
|
|
|
|
|
if (!root_stat)
|
|
|
|
@@ -174,7 +174,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if (root_stat
|
|
|
|
|
&& root_stat->st_dev == ino_tmp->device
|
|
|
|
|
&& root_stat->st_ino == ino_tmp->inode)
|
|
|
|
|
@@ -249,7 +257,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -250,7 +258,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
}
|
|
|
|
|
if (cwd_dev == ino_tmp->device) {
|
|
|
|
|
if (!cwd_stat)
|
|
|
|
@@ -183,7 +183,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if (cwd_stat
|
|
|
|
|
&& cwd_stat->st_dev == ino_tmp->device
|
|
|
|
|
&& cwd_stat->st_ino == ino_tmp->inode)
|
|
|
|
|
@@ -290,6 +298,7 @@ add_inode(struct inode_list **ino_list, struct names *this_name,
|
|
|
|
|
@@ -291,6 +299,7 @@ add_inode(struct inode_list **ino_list, struct names *this_name,
|
|
|
|
|
ino_tmp->name = this_name;
|
|
|
|
|
ino_tmp->device = device;
|
|
|
|
|
ino_tmp->inode = inode;
|
|
|
|
@@ -191,7 +191,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
ino_tmp->next = ino_head;
|
|
|
|
|
*ino_list = ino_tmp;
|
|
|
|
|
}
|
|
|
|
|
@@ -309,6 +318,7 @@ add_device(struct device_list **dev_list, struct names *this_name, dev_t device)
|
|
|
|
|
@@ -310,6 +319,7 @@ add_device(struct device_list **dev_list, struct names *this_name, dev_t device)
|
|
|
|
|
dev_head = *dev_list;
|
|
|
|
|
dev_tmp->name = this_name;
|
|
|
|
|
dev_tmp->device = device;
|
|
|
|
@@ -199,7 +199,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
dev_tmp->next = dev_head;
|
|
|
|
|
*dev_list = dev_tmp;
|
|
|
|
|
}
|
|
|
|
|
@@ -450,13 +460,15 @@ add_special_proc(struct names *name_list, const char ptype, const uid_t uid,
|
|
|
|
|
@@ -451,13 +461,15 @@ add_special_proc(struct names *name_list, const char ptype, const uid_t uid,
|
|
|
|
|
int parse_file(struct names *this_name, struct inode_list **ino_list,
|
|
|
|
|
const opt_type opts)
|
|
|
|
|
{
|
|
|
|
@@ -216,7 +216,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if (errno == ENOENT)
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
_("Specified filename %s does not exist.\n"),
|
|
|
|
|
@@ -466,10 +478,12 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
|
|
|
|
|
@@ -467,10 +479,12 @@ int parse_file(struct names *this_name, struct inode_list **ino_list,
|
|
|
|
|
this_name->filename, strerror(errno));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@@ -231,7 +231,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
add_inode(ino_list, this_name, this_name->st.st_dev,
|
|
|
|
|
this_name->st.st_ino);
|
|
|
|
|
@@ -501,11 +515,51 @@ parse_mounts(struct names *this_name, struct device_list **dev_list,
|
|
|
|
|
@@ -502,11 +516,51 @@ parse_mounts(struct names *this_name, struct device_list **dev_list,
|
|
|
|
|
const opt_type opts)
|
|
|
|
|
{
|
|
|
|
|
dev_t match_device;
|
|
|
|
@@ -283,7 +283,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
add_device(dev_list, this_name, match_device);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
@@ -620,7 +674,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
|
|
|
|
|
@@ -621,7 +675,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
|
|
|
|
|
fprintf(stderr, _("Unknown local port AF %d\n"),
|
|
|
|
|
res->ai_family);
|
|
|
|
|
freeaddrinfo(res);
|
|
|
|
@@ -292,7 +292,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
freeaddrinfo(res);
|
|
|
|
|
@@ -683,10 +737,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
|
|
|
|
|
@@ -684,10 +738,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@@ -308,7 +308,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
@@ -1161,16 +1217,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
@@ -1162,16 +1218,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
skip_argv = 1;
|
|
|
|
|
//while(option != '\0') option++;
|
|
|
|
|
if (strcmp(argv[argc_cnt], "tcp") == 0)
|
|
|
|
@@ -330,7 +330,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
else
|
|
|
|
|
usage(_
|
|
|
|
|
("Invalid namespace name"));
|
|
|
|
|
@@ -1210,7 +1261,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
@@ -1211,7 +1262,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_MOUNTINFO_LIST)
|
|
|
|
@@ -339,7 +339,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
thestat = mntstat;
|
|
|
|
|
#endif
|
|
|
|
|
/* an option */
|
|
|
|
|
@@ -1524,7 +1575,7 @@ print_matches(struct names *names_head, const opt_type opts,
|
|
|
|
|
@@ -1525,7 +1576,7 @@ print_matches(struct names *names_head, const opt_type opts,
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -348,7 +348,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
{
|
|
|
|
|
char pathname[256];
|
|
|
|
|
struct stat *st;
|
|
|
|
|
@@ -1536,6 +1587,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename)
|
|
|
|
|
@@ -1537,6 +1588,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename)
|
|
|
|
|
free(st);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@@ -364,32 +364,17 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
return st;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1550,18 +1610,19 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
@@ -1551,7 +1611,8 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
struct inode_list *ino_tmp;
|
|
|
|
|
struct device_list *dev_tmp;
|
|
|
|
|
struct unixsocket_list *sock_tmp;
|
|
|
|
|
- struct stat st, lst;
|
|
|
|
|
- char dirpath[MAX_PATHNAME];
|
|
|
|
|
- char filepath[MAX_PATHNAME];
|
|
|
|
|
+ struct fdinfo fd;
|
|
|
|
|
+ struct stat st;
|
|
|
|
|
+ char dirpath[PATH_MAX+1];
|
|
|
|
|
+ char filepath[PATH_MAX+1];
|
|
|
|
|
char *dirpath;
|
|
|
|
|
char filepath[PATH_MAX];
|
|
|
|
|
|
|
|
|
|
- snprintf(dirpath, MAX_PATHNAME, "/proc/%d/%s", pid, dirname);
|
|
|
|
|
+ snprintf(dirpath, PATH_MAX, "/proc/%d/%s", pid, dirname);
|
|
|
|
|
if ((dirp = opendir(dirpath)) == NULL)
|
|
|
|
|
return;
|
|
|
|
|
while ((direntry = readdir(dirp)) != NULL) {
|
|
|
|
|
if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9')
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
- snprintf(filepath, MAX_PATHNAME, "/proc/%d/%s/%s",
|
|
|
|
|
+ snprintf(filepath, PATH_MAX, "/proc/%d/%s/%s",
|
|
|
|
|
pid, dirname, direntry->d_name);
|
|
|
|
|
|
|
|
|
|
if (timeout(thestat, filepath, &st, 5) != 0) {
|
|
|
|
|
@@ -1586,9 +1647,12 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
@@ -1592,9 +1653,12 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
dev_tmp = dev_tmp->next) {
|
|
|
|
|
if (thedev != dev_tmp->device)
|
|
|
|
|
continue;
|
|
|
|
@@ -404,7 +389,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
add_matched_proc(dev_tmp->name,
|
|
|
|
|
pid, uid,
|
|
|
|
|
ACCESS_FILEWR |
|
|
|
|
|
@@ -1610,9 +1674,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
@@ -1616,9 +1680,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (st.st_ino == ino_tmp->inode) {
|
|
|
|
@@ -417,15 +402,17 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
add_matched_proc(ino_tmp->name,
|
|
|
|
|
pid, uid,
|
|
|
|
|
ACCESS_FILEWR |
|
|
|
|
|
@@ -1641,18 +1706,30 @@ check_map(const pid_t pid, const char *filename,
|
|
|
|
|
@@ -1647,7 +1712,6 @@ check_map(const pid_t pid, const char *filename,
|
|
|
|
|
FILE *fp;
|
|
|
|
|
unsigned long long tmp_inode;
|
|
|
|
|
unsigned int tmp_maj, tmp_min;
|
|
|
|
|
- dev_t tmp_device;
|
|
|
|
|
|
|
|
|
|
snprintf(pathname, MAX_PATHNAME, "/proc/%d/%s", pid, filename);
|
|
|
|
|
if ((fp = fopen(pathname, "r")) == NULL)
|
|
|
|
|
return;
|
|
|
|
|
if (asprintf(&pathname, "/proc/%d/%s", pid, filename) < 0)
|
|
|
|
|
return;
|
|
|
|
|
@@ -1657,12 +1721,25 @@ check_map(const pid_t pid, const char *filename,
|
|
|
|
|
}
|
|
|
|
|
free(pathname);
|
|
|
|
|
while (fgets(line, BUFSIZ, fp)) {
|
|
|
|
|
- if (sscanf(line, "%*s %*s %*s %x:%x %lld",
|
|
|
|
|
- &tmp_maj, &tmp_min, &tmp_inode) == 3) {
|
|
|
|
@@ -453,7 +440,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
add_matched_proc(dev_tmp->name, pid,
|
|
|
|
|
uid, access);
|
|
|
|
|
for (ino_tmp = ino_head; ino_tmp != NULL;
|
|
|
|
|
@@ -1661,7 +1738,8 @@ check_map(const pid_t pid, const char *filename,
|
|
|
|
|
@@ -1671,7 +1748,8 @@ check_map(const pid_t pid, const char *filename,
|
|
|
|
|
&& ino_tmp->inode == tmp_inode)
|
|
|
|
|
add_matched_proc(ino_tmp->name, pid,
|
|
|
|
|
uid, access);
|
|
|
|
@@ -463,7 +450,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
@@ -1682,6 +1760,7 @@ static uid_t getpiduid(const pid_t pid)
|
|
|
|
|
@@ -1695,6 +1773,7 @@ static uid_t getpiduid(const pid_t pid)
|
|
|
|
|
* fill_unix_cache : Create a list of Unix sockets
|
|
|
|
|
* This list is used later for matching purposes
|
|
|
|
|
*/
|
|
|
|
@@ -471,7 +458,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
@@ -1698,6 +1777,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
@@ -1711,6 +1790,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
while (fgets(line, BUFSIZ, fp) != NULL) {
|
|
|
|
|
char *path;
|
|
|
|
|
char *scanned_path = NULL;
|
|
|
|
@@ -480,7 +467,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms",
|
|
|
|
|
&scanned_inode, &scanned_path) != 2) {
|
|
|
|
|
if (scanned_path)
|
|
|
|
|
@@ -1713,6 +1794,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
@@ -1726,6 +1807,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
free(path);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@@ -489,7 +476,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
if ((newsocket = (struct unixsocket_list *)
|
|
|
|
|
malloc(sizeof(struct unixsocket_list))) == NULL) {
|
|
|
|
|
free(path);
|
|
|
|
|
@@ -1721,6 +1804,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
@@ -1734,6 +1817,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
newsocket->sun_name = strdup(scanned_path);
|
|
|
|
|
newsocket->inode = st.st_ino;
|
|
|
|
|
newsocket->dev = st.st_dev;
|
|
|
|
@@ -497,7 +484,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
newsocket->net_inode = scanned_inode;
|
|
|
|
|
newsocket->next = *unixsocket_head;
|
|
|
|
|
*unixsocket_head = newsocket;
|
|
|
|
|
@@ -1733,6 +1817,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
@@ -1746,6 +1830,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
/*
|
|
|
|
|
* Free up the list of Unix sockets
|
|
|
|
|
*/
|
|
|
|
@@ -505,7 +492,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
void clear_unix_cache(struct unixsocket_list **unixsocket_head)
|
|
|
|
|
{
|
|
|
|
|
while(*unixsocket_head != NULL) {
|
|
|
|
|
@@ -1900,30 +1985,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -1913,30 +1998,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
{
|
|
|
|
|
struct device_list *dev_tmp;
|
|
|
|
|
struct inode_list *ino_tmp;
|
|
|
|
@@ -546,7 +533,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0,
|
|
|
|
|
find_mountp);
|
|
|
|
|
}
|
|
|
|
|
@@ -1935,7 +2012,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -1948,7 +2025,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
find_mountp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -554,7 +541,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
@@ -1985,16 +2061,42 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
@@ -1998,16 +2074,42 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -600,7 +587,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
{
|
|
|
|
|
list_t *ptr, *tmp;
|
|
|
|
|
|
|
|
|
|
@@ -2005,72 +2107,232 @@ static void clear_mntinfo(void)
|
|
|
|
|
@@ -2018,72 +2120,232 @@ static void clear_mntinfo(void)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -609,7 +596,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
+init_mntinfo(void)
|
|
|
|
|
{
|
|
|
|
|
+ char type[256];
|
|
|
|
|
char mpoint[PATH_MAX*4 + 1]; // octal escaping takes 4 chars per 1 char
|
|
|
|
|
char mpoint[PATH_MAX *4 + 1]; // octal escaping takes 4 chars per 1 char
|
|
|
|
|
- int mid, parid, max = 0;
|
|
|
|
|
+ int mid, parid;
|
|
|
|
|
+#if defined(HAS_MOUNTINFO)
|
|
|
|
@@ -669,7 +656,12 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
+#endif
|
|
|
|
|
fclose(mnt);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
- /* Sort mount points accordingly to the reverse mount order */
|
|
|
|
|
- initial(&sort);
|
|
|
|
|
- for (mid = 1; mid <= max; mid++) {
|
|
|
|
|
- list_t *ptr, *tmp;
|
|
|
|
|
- list_for_each_safe(ptr, tmp, &mntinfo) {
|
|
|
|
|
+static int
|
|
|
|
|
+get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info)
|
|
|
|
|
+{
|
|
|
|
@@ -680,12 +672,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
+ char line[BUFSIZ];
|
|
|
|
|
+ FILE *fp;
|
|
|
|
|
+ int mnt_id = 0, flags = 0;
|
|
|
|
|
|
|
|
|
|
- /* Sort mount points accordingly to the reverse mount order */
|
|
|
|
|
- initial(&sort);
|
|
|
|
|
- for (mid = 1; mid <= max; mid++) {
|
|
|
|
|
- list_t *ptr, *tmp;
|
|
|
|
|
- list_for_each_safe(ptr, tmp, &mntinfo) {
|
|
|
|
|
+
|
|
|
|
|
+ snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd);
|
|
|
|
|
+ if ((fp = fopen(pathname, "r")) == NULL)
|
|
|
|
|
+ goto out;
|
|
|
|
@@ -877,7 +864,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
/*
|
|
|
|
|
* Determine device of links below /proc/
|
|
|
|
|
*/
|
|
|
|
|
@@ -2078,8 +2340,7 @@ static int mntstat(const char *path, struct stat *buf)
|
|
|
|
|
@@ -2091,8 +2353,7 @@ static int mntstat(const char *path, struct stat *buf)
|
|
|
|
|
{
|
|
|
|
|
char name[PATH_MAX + 1];
|
|
|
|
|
const char *use;
|
|
|
|
@@ -887,7 +874,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
|
|
|
|
|
if ((use = realpath(path, name)) == NULL || *use != '/')
|
|
|
|
|
{
|
|
|
|
|
@@ -2091,27 +2352,26 @@ static int mntstat(const char *path, struct stat *buf)
|
|
|
|
|
@@ -2104,27 +2365,26 @@ static int mntstat(const char *path, struct stat *buf)
|
|
|
|
|
errno = 0;
|
|
|
|
|
return stat(path, buf);
|
|
|
|
|
}
|
|
|
|
@@ -934,7 +921,7 @@ index 31ef30c..e5337cd 100644
|
|
|
|
|
#endif /* WITH_MOUNTINFO_LIST */
|
|
|
|
|
|
|
|
|
|
diff --git src/fuser.h src/fuser.h
|
|
|
|
|
index a4df711..4b9b1d6 100644
|
|
|
|
|
index 93020d5..7886aa3 100644
|
|
|
|
|
--- src/fuser.h
|
|
|
|
|
+++ src/fuser.h
|
|
|
|
|
@@ -37,10 +37,16 @@ struct procs {
|
|
|
|
@@ -999,8 +986,8 @@ index a4df711..4b9b1d6 100644
|
|
|
|
|
|
|
|
|
|
#define NAMESPACE_FILE 0
|
|
|
|
|
#define NAMESPACE_TCP 1
|
|
|
|
|
@@ -108,5 +114,6 @@ typedef struct mntinfo_s {
|
|
|
|
|
#define MAX_CMDNAME 16
|
|
|
|
|
@@ -109,5 +115,6 @@ typedef struct mntinfo_s {
|
|
|
|
|
#endif /* PATH_MAX */
|
|
|
|
|
|
|
|
|
|
#define KNFSD_EXPORTS "/proc/fs/nfs/exports"
|
|
|
|
|
+#define PROC_MOUNTINFO "/proc/self/mountinfo"
|
|
|
|
@@ -1026,7 +1013,7 @@ index 696a44a..739237e 100644
|
|
|
|
|
-
|
|
|
|
|
EXTRA_DIST =
|
|
|
|
|
diff --git testsuite/killall.test/killall.exp testsuite/killall.test/killall.exp
|
|
|
|
|
index b244893..1a10a1a 100644
|
|
|
|
|
index 8bb3889..a345582 100644
|
|
|
|
|
--- testsuite/killall.test/killall.exp
|
|
|
|
|
+++ testsuite/killall.test/killall.exp
|
|
|
|
|
@@ -7,7 +7,11 @@ set fake_proc_name "afakeprocname"
|
|
|
|
@@ -1042,5 +1029,5 @@ index b244893..1a10a1a 100644
|
|
|
|
|
set test "killall list signals"
|
|
|
|
|
spawn $killall -l
|
|
|
|
|
--
|
|
|
|
|
2.17.1
|
|
|
|
|
2.16.4
|
|
|
|
|
|
|
|
|
|