From e87257963674c52ede5a339f7e820d9f334929ac Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 30 Nov 2018 14:26:22 +0000 Subject: [PATCH] Always initialize head of simple linked list OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=116 --- ...to-be-able-to-use-the-mount-identity.patch | 22 +++--- ...-2-system-call-to-avoid-hangs-on-NFS.patch | 78 +++++++++++++++---- psmisc.changes | 7 ++ 3 files changed, 84 insertions(+), 23 deletions(-) diff --git a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch index 259048b..4c746a5 100644 --- a/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch +++ b/0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch @@ -1,4 +1,4 @@ -From 2588a03273329961e5eefe6fed695b8f80a352e3 Mon Sep 17 00:00:00 2001 +From 8d0edbbb8d09bc7998bf926b318270b6f7989195 Mon Sep 17 00:00:00 2001 From: Werner Fink Date: Mon, 22 Oct 2018 12:02:50 +0200 Subject: [PATCH] Use mountinfo to be able to use the mount identity @@ -12,15 +12,16 @@ Add support for name_to_handle_at() system call to get the real mount ID for each file Support also BtrFS with its various subvolumes +On BtrFS stat(2) on binary does not see subvol dev Signed-off-by: Werner Fink --- configure.ac | 18 +- - src/fuser.c | 644 ++++++++++++++++++++++++++++--------- + src/fuser.c | 647 ++++++++++++++++++++++++++++--------- src/fuser.h | 27 +- testsuite/Makefile.am | 3 +- testsuite/killall.test/killall.exp | 4 + - 5 files changed, 543 insertions(+), 153 deletions(-) + 5 files changed, 546 insertions(+), 153 deletions(-) diff --git configure.ac configure.ac index 176a2fc..d8d3366 100644 @@ -66,7 +67,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 c44cee8..7ee9b49 100644 +index c44cee8..48d52d0 100644 --- src/fuser.c +++ src/fuser.c @@ -32,6 +32,10 @@ @@ -248,9 +249,9 @@ index c44cee8..7ee9b49 100644 dev_tmp->name = this_name; dev_tmp->device = device; + dev_tmp->mnt_id = this_name->mnt_id; ++ dev_tmp->vol = NULL; + if (dev_tmp->device != subvol) + add_subvol(&dev_tmp->vol, subvol, this_name->mnt_id); -+ else dev_tmp->vol = NULL; dev_tmp->next = dev_head; *dev_list = dev_tmp; } @@ -713,7 +714,7 @@ index c44cee8..7ee9b49 100644 { list_t *ptr, *tmp; -@@ -2018,72 +2202,244 @@ static void clear_mntinfo(void) +@@ -2018,72 +2202,247 @@ static void clear_mntinfo(void) } } @@ -757,8 +758,11 @@ index c44cee8..7ee9b49 100644 + struct stat st; + mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min)); + if (mntinf && strncmp(devname, "/dev/", 5) == 0 && stat(devname, &st) == 0) { -+ if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) ++ if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) { + mntinf->vol = st.st_rdev; ++ stat(mpoint, &st); ++ mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ ++ } } - append(mnt, mntinfo); - mnt->mpoint = ((char *)mnt) + alignof(mntinfo_t); @@ -1002,7 +1006,7 @@ index c44cee8..7ee9b49 100644 /* * Determine device of links below /proc/ */ -@@ -2091,8 +2447,7 @@ static int mntstat(const char *path, struct stat *buf) +@@ -2091,8 +2450,7 @@ static int mntstat(const char *path, struct stat *buf) { char name[PATH_MAX + 1]; const char *use; @@ -1012,7 +1016,7 @@ index c44cee8..7ee9b49 100644 if ((use = realpath(path, name)) == NULL || *use != '/') { -@@ -2104,27 +2459,26 @@ static int mntstat(const char *path, struct stat *buf) +@@ -2104,27 +2462,26 @@ static int mntstat(const char *path, struct stat *buf) errno = 0; return stat(path, buf); } diff --git a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch index 9756f2d..a2f3c62 100644 --- a/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch +++ b/0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch @@ -90,7 +90,7 @@ index d8d3366..81d3674 100644 # Enable hardened compile and link flags AC_ARG_ENABLE([harden_flags], diff --git src/fuser.c src/fuser.c -index 7ee9b49..3f512de 100644 +index 48d52d0..f824581 100644 --- src/fuser.c +++ src/fuser.c @@ -63,7 +63,7 @@ @@ -235,7 +235,38 @@ index 7ee9b49..3f512de 100644 continue; } /* Scan the devices */ -@@ -2296,7 +2291,7 @@ out: +@@ -2225,10 +2220,10 @@ init_mntinfo(void) + &mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) { + struct stat st; + mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min)); +- if (mntinf && strncmp(devname, "/dev/", 5) == 0 && stat(devname, &st) == 0) { ++ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && statn(devname, 0, &st) == 0) { + if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) { + mntinf->vol = st.st_rdev; +- stat(mpoint, &st); ++ statn(mpoint, 0, &st); + mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ + } + } +@@ -2240,7 +2235,7 @@ init_mntinfo(void) + parid = -1; + while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) { + struct stat st; +- if (stat(mpoint, &st) != 0) { ++ if (statn(mpoint, 0, &st) != 0) { + if (errno != EACCES) { + fprintf(stderr, _("Cannot stat %s: %s\n"), + mnt->mpoint, strerror(errno)); +@@ -2249,7 +2244,7 @@ init_mntinfo(void) + st.st_dev = (dev_t)-1; + } + mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev); +- if (mntinf && strncmp(devname, "/dev/", 5) == 0 && stat(devname, &st) == 0) { ++ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && statn(devname, 0, &st) == 0) { + if (st.st_rdev != 0 && mntinf->dev != st.st_rdev) + mntinf->vol = st.st_rdev; + } +@@ -2299,7 +2294,7 @@ out: struct stat lst; snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); @@ -244,7 +275,25 @@ index 7ee9b49..3f512de 100644 if (lst.st_mode & S_IWUSR) info->flags |= O_WRONLY; ret++; -@@ -2439,49 +2434,6 @@ out: +@@ -2372,7 +2367,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo) + + /* could be a chroot or a container */ + +- if (stat(path, &st) != 0) { ++ if (statn(path, 0, &st) != 0) { + if (errno != EACCES) { + fprintf(stderr, _("Cannot stat %s: %s\n"), + path, strerror(errno)); +@@ -2404,7 +2399,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo) + + /* could be a chroot or a container */ + +- if (stat(use, &st) != 0) { ++ if (statn(use, 0, &st) != 0) { + if (errno != EACCES) { + fprintf(stderr, _("Cannot stat %s: %s\n"), + use, strerror(errno)); +@@ -2442,49 +2437,6 @@ out: return ret; } @@ -296,10 +345,10 @@ index 7ee9b49..3f512de 100644 * it avoids lstat(2) system calls. diff --git src/statx.c src/statx.c new file mode 100644 -index 0000000..2554da7 +index 0000000..a598c89 --- /dev/null +++ src/statx.c -@@ -0,0 +1,147 @@ +@@ -0,0 +1,149 @@ +/* + * statx.c - Map modern statx(2) system call to older stat(2), lstat(2), + * and fstat(2) replacements named {,l,f}statn() @@ -333,10 +382,12 @@ index 0000000..2554da7 +# include /* Definition of AT_* and AT_STATX_* constants ! */ +#endif +#include /* Definition of AT_* constants */ -+#ifndef HAVE_STATX -+# include /* Provides 'struct statx' and STATX_* ! */ -+#endif +#include ++#ifndef HAVE_STATX ++# ifndef STATX_TYPE ++# include /* Provides 'struct statx' and STATX_* ! */ ++# endif ++#endif +#include +#include +#include @@ -449,10 +500,10 @@ index 0000000..2554da7 +} diff --git src/statx.h src/statx.h new file mode 100644 -index 0000000..bc9eda7 +index 0000000..fdd0137 --- /dev/null +++ src/statx.h -@@ -0,0 +1,66 @@ +@@ -0,0 +1,68 @@ +/* + * statx.h - Map modern statx(2) system call to older stat(2), lstat(2), + * and fstat(2) replacements named {,l,f}statn() @@ -482,7 +533,9 @@ index 0000000..bc9eda7 +# ifndef HAVE_STATX +# define _ASM_GENERIC_FCNTL_H /* Avoid collisions between asm/fcntl.h and bits/fcntl.h ! */ +# include /* Definition of AT_* and AT_STATX_* constants ! */ -+# include /* Provides 'struct statx' and STATX_* ! */ ++# ifndef STATX_TYPE ++# include /* Provides 'struct statx' and STATX_* ! */ ++# endif +# endif +extern int statn(const char*, unsigned int, struct stat*); +extern int fstatn(int, unsigned int, struct stat*); @@ -948,6 +1001,3 @@ index f372297..0000000 -#endif - -#endif --- -2.16.4 - diff --git a/psmisc.changes b/psmisc.changes index 55b3b3e..4b4acf0 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Nov 30 13:21:44 UTC 2018 - Dr. Werner Fink + +- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch + * Always initialize head of simple linked list (bsc#1098697) + * stat(2) on binary does not see subvol dev + ------------------------------------------------------------------- Wed Nov 14 07:44:55 UTC 2018 - Dr. Werner Fink