Dr. Werner Fink 2017-10-13 07:45:00 +00:00 committed by Git OBS Bridge
parent e446792e1d
commit 6ab4e37d35

View File

@ -1,4 +1,4 @@
From 02b6674c8b57db637093a1f753075a601c460c80 Mon Sep 17 00:00:00 2001 From 8fa126fdf938cef959bd64d8da2aff2e7bc5dd37 Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de> From: Werner Fink <werner@suse.de>
Date: Thu, 29 Jun 2017 15:18:28 +0200 Date: Thu, 29 Jun 2017 15:18:28 +0200
Subject: [PATCH] Use mountinfo to be able to use the mount identity Subject: [PATCH] Use mountinfo to be able to use the mount identity
@ -14,11 +14,11 @@ get the real mount ID for each file
Signed-off-by: Werner Fink <werner@suse.de> Signed-off-by: Werner Fink <werner@suse.de>
--- ---
configure.ac | 18 +- configure.ac | 18 +-
src/fuser.c | 530 +++++++++++++++++++++++++++---------- src/fuser.c | 528 +++++++++++++++++++++++++++----------
src/fuser.h | 19 +- src/fuser.h | 19 +-
testsuite/Makefile.am | 3 +- testsuite/Makefile.am | 3 +-
testsuite/killall.test/killall.exp | 4 + testsuite/killall.test/killall.exp | 4 +
5 files changed, 426 insertions(+), 148 deletions(-) 5 files changed, 424 insertions(+), 148 deletions(-)
diff --git configure.ac configure.ac diff --git configure.ac configure.ac
index 176a2fc..d8d3366 100644 index 176a2fc..d8d3366 100644
@ -64,7 +64,7 @@ index 176a2fc..d8d3366 100644
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST AC_C_CONST
diff --git src/fuser.c src/fuser.c diff --git src/fuser.c src/fuser.c
index 31ef30c..d5d72a9 100644 index 31ef30c..d7fd729 100644
--- src/fuser.c --- src/fuser.c
+++ src/fuser.c +++ src/fuser.c
@@ -32,6 +32,10 @@ @@ -32,6 +32,10 @@
@ -588,7 +588,7 @@ index 31ef30c..d5d72a9 100644
{ {
list_t *ptr, *tmp; list_t *ptr, *tmp;
@@ -2005,72 +2095,234 @@ static void clear_mntinfo(void) @@ -2005,72 +2095,232 @@ static void clear_mntinfo(void)
} }
} }
@ -661,12 +661,13 @@ index 31ef30c..d5d72a9 100644
+static int +static int
+get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info) +get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info)
+{ +{
+ int ret = 0;
+ char pathname[256];
+#if defined(HAS_FDINFO) +#if defined(HAS_FDINFO)
+ const static char delimiters[] = ": \t\n"; + const static char delimiters[] = ": \t\n";
+ char pathname[256];
+ char line[BUFSIZ]; + char line[BUFSIZ];
+ FILE *fp; + FILE *fp;
+ int ret = 0, mnt_id = 0, flags = 0; + int mnt_id = 0, flags = 0;
+ +
+ snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd); + snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd);
+ if ((fp = fopen(pathname, "r")) == NULL) + if ((fp = fopen(pathname, "r")) == NULL)
@ -690,15 +691,12 @@ index 31ef30c..d5d72a9 100644
+ mnt_id++; + mnt_id++;
+ ret++; + ret++;
+ } + }
+
+ } + }
+ fclose(fp); + fclose(fp);
+out: +out:
+#endif +#endif
+ if (!flags || !mnt_id) { + if (!flags || !mnt_id) {
+ char pathname[256];
+ struct stat lst; + struct stat lst;
+ int ret = 0;
+ +
+ snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); + snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
+ if (!flags && ret == lstat(pathname, &lst) == 0) { + if (!flags && ret == lstat(pathname, &lst) == 0) {
@ -867,7 +865,7 @@ index 31ef30c..d5d72a9 100644
/* /*
* Determine device of links below /proc/ * Determine device of links below /proc/
*/ */
@@ -2078,8 +2330,7 @@ static int mntstat(const char *path, struct stat *buf) @@ -2078,8 +2328,7 @@ static int mntstat(const char *path, struct stat *buf)
{ {
char name[PATH_MAX + 1]; char name[PATH_MAX + 1];
const char *use; const char *use;
@ -877,7 +875,7 @@ index 31ef30c..d5d72a9 100644
if ((use = realpath(path, name)) == NULL || *use != '/') if ((use = realpath(path, name)) == NULL || *use != '/')
{ {
@@ -2091,27 +2342,26 @@ static int mntstat(const char *path, struct stat *buf) @@ -2091,27 +2340,26 @@ static int mntstat(const char *path, struct stat *buf)
errno = 0; errno = 0;
return stat(path, buf); return stat(path, buf);
} }