let it build even without statx around

OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=111
This commit is contained in:
Dr. Werner Fink 2018-11-05 08:39:03 +00:00 committed by Git OBS Bridge
parent 6fc55b0b96
commit e208f05622

View File

@ -1,4 +1,4 @@
From 7181b4125fc2a1057dffffaa643e6bcb549fd0eb Mon Sep 17 00:00:00 2001
From f6e5c845e75ffda1381b3a72b068ce806d01d751 Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de>
Date: Fri, 2 Nov 2018 14:27:00 +0100
Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS
@ -12,7 +12,7 @@ Signed-off-by: Werner Fink <werner@suse.de>
src/statx.h | 66 +++++++++++
src/timeout.c | 372 ----------------------------------------------------------
src/timeout.h | 45 -------
7 files changed, 247 insertions(+), 511 deletions(-)
7 files changed, 248 insertions(+), 510 deletions(-)
create mode 100644 src/statx.c
create mode 100644 src/statx.h
delete mode 100644 src/timeout.c
@ -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 2681f74..c717e19 100644
index 2681f74..92ffa37 100644
--- src/fuser.c
+++ src/fuser.c
@@ -63,7 +63,7 @@
@ -132,21 +132,22 @@ index 2681f74..c717e19 100644
break;
case 'k':
opts |= OPT_KILL;
@@ -1261,10 +1255,9 @@ int main(int argc, char *argv[])
@@ -1261,10 +1255,11 @@ int main(int argc, char *argv[])
continue;
}
-#if defined(WITH_MOUNTINFO_LIST)
- if ((opts & (OPT_MOUNTS|OPT_ALWAYSSTAT)) == OPT_MOUNTS)
- thestat = mntstat;
-#endif
+#if defined(HAVE_DECL_SYS_STATX) && HAVE_DECL_SYS_STATX == 1
+ if ((opts & OPT_ALWAYSSTAT))
+ stat_flags = 0; /* Triggers sync with e.g. remote NFS server even on autofs */
#endif
+
/* an option */
/* Not an option, must be a file specification */
if ((this_name = malloc(sizeof(struct names))) == NULL)
@@ -1584,7 +1577,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
@@ -1584,7 +1579,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL)
return NULL;
snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
@ -155,7 +156,7 @@ index 2681f74..c717e19 100644
free(st);
return NULL;
}
@@ -1631,7 +1624,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1631,7 +1626,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s",
pid, dirname, direntry->d_name);
@ -164,7 +165,7 @@ index 2681f74..c717e19 100644
if (errno != ENOENT && errno != ENOTDIR) {
fprintf(stderr, _("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1673,7 +1666,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
@@ -1673,7 +1668,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
if (thedev != ino_tmp->device)
continue;
if (!st.st_ino
@ -173,7 +174,7 @@ index 2681f74..c717e19 100644
fprintf(stderr,
_("Cannot stat file %s: %s\n"),
filepath, strerror(errno));
@@ -1761,11 +1754,11 @@ static uid_t getpiduid(const pid_t pid)
@@ -1761,11 +1756,11 @@ static uid_t getpiduid(const pid_t pid)
if (asprintf(&pathname, "/proc/%d", pid) < 0)
return 0;
@ -189,7 +190,7 @@ index 2681f74..c717e19 100644
return st.st_uid;
}
@@ -1803,7 +1796,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
@@ -1803,7 +1798,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
path = scanned_path;
if (*scanned_path == '@')
scanned_path++;
@ -198,7 +199,7 @@ index 2681f74..c717e19 100644
free(path);
continue;
}
@@ -1938,7 +1931,7 @@ static dev_t find_net_dev(void)
@@ -1938,7 +1933,7 @@ static dev_t find_net_dev(void)
fprintf(stderr, _("Cannot open a network socket.\n"));
return -1;
}
@ -207,7 +208,7 @@ index 2681f74..c717e19 100644
fprintf(stderr, _("Cannot find socket's device number.\n"));
close(skt);
return -1;
@@ -1971,7 +1964,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head,
@@ -1971,7 +1966,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head,
if ((find_space = strpbrk(line, " \t")) == NULL)
continue;
*find_space = '\0';
@ -216,7 +217,7 @@ index 2681f74..c717e19 100644
continue;
}
/* Scan the devices */
@@ -2006,7 +1999,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
@@ -2006,7 +2001,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
const char *find_mountp = mnt->mpoint;
@ -225,7 +226,7 @@ index 2681f74..c717e19 100644
continue;
/* Scan the devices */
@@ -2053,7 +2046,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
@@ -2053,7 +2048,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
if (*find_space == '\0')
continue;
}
@ -234,7 +235,7 @@ index 2681f74..c717e19 100644
continue;
}
/* Scan the devices */
@@ -2209,7 +2202,7 @@ out:
@@ -2209,7 +2204,7 @@ out:
struct stat lst;
snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
@ -243,7 +244,7 @@ index 2681f74..c717e19 100644
if (lst.st_mode & S_IWUSR)
info->flags |= O_WRONLY;
ret++;
@@ -2352,49 +2345,6 @@ out:
@@ -2352,49 +2347,6 @@ out:
return ret;
}
@ -448,7 +449,7 @@ index 0000000..2554da7
+}
diff --git src/statx.h src/statx.h
new file mode 100644
index 0000000..548583d
index 0000000..bc9eda7
--- /dev/null
+++ src/statx.h
@@ -0,0 +1,66 @@
@ -488,19 +489,19 @@ index 0000000..548583d
+extern int lstatn(const char*, unsigned int, struct stat*);
+#else
+extern inline int
+statn(const char *path, unsigned int mask __atribute__((unused)), struct stat *st)
+statn(const char *path, unsigned int mask __attribute__((unused)), struct stat *st)
+{
+ return stat(path, st);
+}
+extern inline int
+fstatn(int fd, unsigned int mask __atribute__((unused)), struct stat *st)
+fstatn(int fd, unsigned int mask __attribute__((unused)), struct stat *st)
+{
+ return fstat(fd, st);
+}
+extern inline int
+lstatn(const char *path, unsigned int mask __atribute__((unused)), struct stat *st)
+lstatn(const char *path, unsigned int mask __attribute__((unused)), struct stat *st)
+{
+ lstat(path, st);
+ return lstat(path, st);
+}
+#define STATX_TYPE 0
+#define STATX_MODE 0