Allow not unique mounts as well as not unique mountpoint

OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=120
This commit is contained in:
Dr. Werner Fink 2020-04-27 14:58:59 +00:00 committed by Git OBS Bridge
parent e7b4dde9cf
commit c9cdb3a11c
4 changed files with 91 additions and 89 deletions

View File

@ -1,6 +1,6 @@
From 8d0edbbb8d09bc7998bf926b318270b6f7989195 Mon Sep 17 00:00:00 2001 From 63d402a35e29106828f59b0b5b42a277136460c0 Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de> From: Werner Fink <werner@suse.de>
Date: Mon, 22 Oct 2018 12:02:50 +0200 Date: Mon, 27 Apr 2020 14:41:03 +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
which allows to distinguish different mounts with the which allows to distinguish different mounts with the
@ -14,14 +14,16 @@ get the real mount ID for each file
Support also BtrFS with its various subvolumes Support also BtrFS with its various subvolumes
On BtrFS stat(2) on binary does not see subvol dev On BtrFS stat(2) on binary does not see subvol dev
Allow not unique mounts as well as not unique mountpoint
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 | 647 ++++++++++++++++++++++++++++--------- src/fuser.c | 638 ++++++++++++++++++++++-------
src/fuser.h | 27 +- src/fuser.h | 27 +-
testsuite/Makefile.am | 3 +- testsuite/Makefile.am | 3 +-
testsuite/killall.test/killall.exp | 4 + testsuite/killall.test/killall.exp | 4 +
5 files changed, 546 insertions(+), 153 deletions(-) 5 files changed, 537 insertions(+), 153 deletions(-)
diff --git configure.ac configure.ac diff --git configure.ac configure.ac
index 176a2fc..d8d3366 100644 index 176a2fc..d8d3366 100644
@ -67,7 +69,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 c44cee8..48d52d0 100644 index c44cee8..1b58374 100644
--- src/fuser.c --- src/fuser.c
+++ src/fuser.c +++ src/fuser.c
@@ -32,6 +32,10 @@ @@ -32,6 +32,10 @@
@ -287,7 +289,7 @@ index c44cee8..48d52d0 100644
#endif /* DEBUG */ #endif /* DEBUG */
add_inode(ino_list, this_name, this_name->st.st_dev, add_inode(ino_list, this_name, this_name->st.st_dev,
this_name->st.st_ino); this_name->st.st_ino);
@@ -502,12 +554,54 @@ parse_mounts(struct names *this_name, struct device_list **dev_list, @@ -502,12 +554,45 @@ parse_mounts(struct names *this_name, struct device_list **dev_list,
const opt_type opts) const opt_type opts)
{ {
dev_t match_device; dev_t match_device;
@ -304,8 +306,6 @@ index c44cee8..48d52d0 100644
+ count = 0; + count = 0;
+ list_for_each(ptr, &mntinfo) { + list_for_each(ptr, &mntinfo) {
+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); + mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
+ if (match_device != mnt->dev && match_device != mnt->vol)
+ continue;
+ if (S_ISBLK(this_name->st.st_mode)) { + if (S_ISBLK(this_name->st.st_mode)) {
+ /* Skip mount IDs check if a block device + /* Skip mount IDs check if a block device
+ * was specified */ + * was specified */
@ -329,13 +329,6 @@ index c44cee8..48d52d0 100644
+ this_name->filename); + this_name->filename);
+ return -1; + return -1;
+ } + }
+ if (count > 1) {
+ errno = ENOTUNIQ;
+ fprintf(stderr,
+ _("The device %u:%u is not unique. Please change!\n"),
+ major(match_device), minor(match_device));
+ /* return -1 */
+ }
+ if (S_ISBLK(this_name->st.st_mode)) + if (S_ISBLK(this_name->st.st_mode))
+ return 0; + return 0;
+ this_name->mnt_id = mountinfo->id; + this_name->mnt_id = mountinfo->id;
@ -343,7 +336,7 @@ index c44cee8..48d52d0 100644
return 0; return 0;
} }
@@ -621,7 +715,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) @@ -621,7 +706,7 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
fprintf(stderr, _("Unknown local port AF %d\n"), fprintf(stderr, _("Unknown local port AF %d\n"),
res->ai_family); res->ai_family);
freeaddrinfo(res); freeaddrinfo(res);
@ -352,7 +345,7 @@ index c44cee8..48d52d0 100644
return -1; return -1;
} }
freeaddrinfo(res); freeaddrinfo(res);
@@ -684,10 +778,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) @@ -684,10 +769,12 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list)
break; break;
#endif #endif
} }
@ -368,7 +361,7 @@ index c44cee8..48d52d0 100644
} }
return 1; return 1;
} }
@@ -953,6 +1049,21 @@ free_inodes(struct inode_list **match_inodes) @@ -953,6 +1040,21 @@ free_inodes(struct inode_list **match_inodes)
/* /*
* Free up structures allocated in add_device * Free up structures allocated in add_device
*/ */
@ -390,7 +383,7 @@ index c44cee8..48d52d0 100644
static void static void
free_devices(struct device_list **match_devices) free_devices(struct device_list **match_devices)
{ {
@@ -960,6 +1071,8 @@ free_devices(struct device_list **match_devices) @@ -960,6 +1062,8 @@ free_devices(struct device_list **match_devices)
device_tmp = *match_devices; device_tmp = *match_devices;
while(device_tmp != NULL) { while(device_tmp != NULL) {
@ -399,7 +392,7 @@ index c44cee8..48d52d0 100644
device_next = device_tmp->next; device_next = device_tmp->next;
free(device_tmp); free(device_tmp);
device_tmp = device_next; device_tmp = device_next;
@@ -1162,16 +1275,11 @@ int main(int argc, char *argv[]) @@ -1162,16 +1266,11 @@ int main(int argc, char *argv[])
skip_argv = 1; skip_argv = 1;
//while(option != '\0') option++; //while(option != '\0') option++;
if (strcmp(argv[argc_cnt], "tcp") == 0) if (strcmp(argv[argc_cnt], "tcp") == 0)
@ -421,7 +414,7 @@ index c44cee8..48d52d0 100644
else else
usage(_ usage(_
("Invalid namespace name")); ("Invalid namespace name"));
@@ -1211,7 +1319,7 @@ int main(int argc, char *argv[]) @@ -1211,7 +1310,7 @@ int main(int argc, char *argv[])
} }
#if defined(WITH_MOUNTINFO_LIST) #if defined(WITH_MOUNTINFO_LIST)
@ -430,7 +423,7 @@ index c44cee8..48d52d0 100644
thestat = mntstat; thestat = mntstat;
#endif #endif
/* an option */ /* an option */
@@ -1525,7 +1633,7 @@ print_matches(struct names *names_head, const opt_type opts, @@ -1525,7 +1624,7 @@ print_matches(struct names *names_head, const opt_type opts,
} }
@ -439,7 +432,7 @@ index c44cee8..48d52d0 100644
{ {
char pathname[256]; char pathname[256];
struct stat *st; struct stat *st;
@@ -1537,6 +1645,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename) @@ -1537,6 +1636,15 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename)
free(st); free(st);
return NULL; return NULL;
} }
@ -455,7 +448,7 @@ index c44cee8..48d52d0 100644
return st; return st;
} }
@@ -1551,7 +1668,8 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, @@ -1551,7 +1659,8 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
struct inode_list *ino_tmp; struct inode_list *ino_tmp;
struct device_list *dev_tmp; struct device_list *dev_tmp;
struct unixsocket_list *sock_tmp; struct unixsocket_list *sock_tmp;
@ -465,7 +458,7 @@ index c44cee8..48d52d0 100644
char *dirpath; char *dirpath;
char filepath[PATH_MAX]; char filepath[PATH_MAX];
@@ -1590,11 +1708,27 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, @@ -1590,11 +1699,27 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
} }
for (dev_tmp = dev_head; dev_tmp != NULL; for (dev_tmp = dev_head; dev_tmp != NULL;
dev_tmp = dev_tmp->next) { dev_tmp = dev_tmp->next) {
@ -496,7 +489,7 @@ index c44cee8..48d52d0 100644
add_matched_proc(dev_tmp->name, add_matched_proc(dev_tmp->name,
pid, uid, pid, uid,
ACCESS_FILEWR | ACCESS_FILEWR |
@@ -1616,9 +1750,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, @@ -1616,9 +1741,10 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
continue; continue;
} }
if (st.st_ino == ino_tmp->inode) { if (st.st_ino == ino_tmp->inode) {
@ -509,7 +502,7 @@ index c44cee8..48d52d0 100644
add_matched_proc(ino_tmp->name, add_matched_proc(ino_tmp->name,
pid, uid, pid, uid,
ACCESS_FILEWR | ACCESS_FILEWR |
@@ -1647,31 +1782,54 @@ check_map(const pid_t pid, const char *filename, @@ -1647,31 +1773,54 @@ check_map(const pid_t pid, const char *filename,
FILE *fp; FILE *fp;
unsigned long long tmp_inode; unsigned long long tmp_inode;
unsigned int tmp_maj, tmp_min; unsigned int tmp_maj, tmp_min;
@ -574,7 +567,7 @@ index c44cee8..48d52d0 100644
} }
fclose(fp); fclose(fp);
} }
@@ -1695,6 +1853,7 @@ static uid_t getpiduid(const pid_t pid) @@ -1695,6 +1844,7 @@ static uid_t getpiduid(const pid_t pid)
* fill_unix_cache : Create a list of Unix sockets * fill_unix_cache : Create a list of Unix sockets
* This list is used later for matching purposes * This list is used later for matching purposes
*/ */
@ -582,7 +575,7 @@ index c44cee8..48d52d0 100644
void fill_unix_cache(struct unixsocket_list **unixsocket_head) void fill_unix_cache(struct unixsocket_list **unixsocket_head)
{ {
FILE *fp; FILE *fp;
@@ -1711,6 +1870,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) @@ -1711,6 +1861,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
while (fgets(line, BUFSIZ, fp) != NULL) { while (fgets(line, BUFSIZ, fp) != NULL) {
char *path; char *path;
char *scanned_path = NULL; char *scanned_path = NULL;
@ -591,7 +584,7 @@ index c44cee8..48d52d0 100644
if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms", if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %ms",
&scanned_inode, &scanned_path) != 2) { &scanned_inode, &scanned_path) != 2) {
if (scanned_path) if (scanned_path)
@@ -1726,6 +1887,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) @@ -1726,6 +1878,8 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
free(path); free(path);
continue; continue;
} }
@ -600,7 +593,7 @@ index c44cee8..48d52d0 100644
if ((newsocket = (struct unixsocket_list *) if ((newsocket = (struct unixsocket_list *)
malloc(sizeof(struct unixsocket_list))) == NULL) { malloc(sizeof(struct unixsocket_list))) == NULL) {
free(path); free(path);
@@ -1734,6 +1897,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) @@ -1734,6 +1888,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
newsocket->sun_name = strdup(scanned_path); newsocket->sun_name = strdup(scanned_path);
newsocket->inode = st.st_ino; newsocket->inode = st.st_ino;
newsocket->dev = st.st_dev; newsocket->dev = st.st_dev;
@ -608,7 +601,7 @@ index c44cee8..48d52d0 100644
newsocket->net_inode = scanned_inode; newsocket->net_inode = scanned_inode;
newsocket->next = *unixsocket_head; newsocket->next = *unixsocket_head;
*unixsocket_head = newsocket; *unixsocket_head = newsocket;
@@ -1746,6 +1910,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) @@ -1746,6 +1901,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
/* /*
* Free up the list of Unix sockets * Free up the list of Unix sockets
*/ */
@ -616,7 +609,7 @@ index c44cee8..48d52d0 100644
void clear_unix_cache(struct unixsocket_list **unixsocket_head) void clear_unix_cache(struct unixsocket_list **unixsocket_head)
{ {
while(*unixsocket_head != NULL) { while(*unixsocket_head != NULL) {
@@ -1913,30 +2078,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, @@ -1913,30 +2069,22 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
{ {
struct device_list *dev_tmp; struct device_list *dev_tmp;
struct inode_list *ino_tmp; struct inode_list *ino_tmp;
@ -657,7 +650,7 @@ index c44cee8..48d52d0 100644
add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0, add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0,
find_mountp); find_mountp);
} }
@@ -1948,7 +2105,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, @@ -1948,7 +2096,6 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
find_mountp); find_mountp);
} }
} }
@ -665,7 +658,7 @@ index c44cee8..48d52d0 100644
} }
static void static void
@@ -1998,16 +2154,44 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, @@ -1998,16 +2145,44 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
fclose(fp); fclose(fp);
} }
@ -714,7 +707,7 @@ index c44cee8..48d52d0 100644
{ {
list_t *ptr, *tmp; list_t *ptr, *tmp;
@@ -2018,72 +2202,247 @@ static void clear_mntinfo(void) @@ -2018,72 +2193,247 @@ static void clear_mntinfo(void)
} }
} }
@ -763,17 +756,8 @@ index c44cee8..48d52d0 100644
+ stat(mpoint, &st); + stat(mpoint, &st);
+ mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ + mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */
+ } + }
} + }
- append(mnt, mntinfo); + }
- mnt->mpoint = ((char *)mnt) + alignof(mntinfo_t);
- strcpy(mnt->mpoint, mpoint);
- mnt->nlen = nlen;
- mnt->parid = parid;
- mnt->dev = makedev(maj, min);
- mnt->id = mid;
- if (mid > max)
- max = mid;
}
+#else +#else
+ if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0) + if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0)
+ return; + return;
@ -793,12 +777,26 @@ index c44cee8..48d52d0 100644
+ if (mntinf && strncmp(devname, "/dev/", 5) == 0 && stat(devname, &st) == 0) { + 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; + mntinf->vol = st.st_rdev;
+ } }
+ } - append(mnt, mntinfo);
- mnt->mpoint = ((char *)mnt) + alignof(mntinfo_t);
- strcpy(mnt->mpoint, mpoint);
- mnt->nlen = nlen;
- mnt->parid = parid;
- mnt->dev = makedev(maj, min);
- mnt->id = mid;
- if (mid > max)
- max = mid;
}
+#endif +#endif
fclose(mnt); 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 +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)
+{ +{
@ -859,12 +857,7 @@ index c44cee8..48d52d0 100644
+ } + }
+ return ret == 2 ? 0 : -1; + return ret == 2 ? 0 : -1;
+} +}
+
- /* 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) {
+#if defined(HAS_NAME_TO_HANDLE_AT) +#if defined(HAS_NAME_TO_HANDLE_AT)
+static int +static int
+get_mountid(const char *path) +get_mountid(const char *path)
@ -1006,7 +999,7 @@ index c44cee8..48d52d0 100644
/* /*
* Determine device of links below /proc/ * Determine device of links below /proc/
*/ */
@@ -2091,8 +2450,7 @@ static int mntstat(const char *path, struct stat *buf) @@ -2091,8 +2441,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;
@ -1016,7 +1009,7 @@ index c44cee8..48d52d0 100644
if ((use = realpath(path, name)) == NULL || *use != '/') if ((use = realpath(path, name)) == NULL || *use != '/')
{ {
@@ -2104,27 +2462,26 @@ static int mntstat(const char *path, struct stat *buf) @@ -2104,27 +2453,26 @@ static int mntstat(const char *path, struct stat *buf)
errno = 0; errno = 0;
return stat(path, buf); return stat(path, buf);
} }
@ -1179,5 +1172,5 @@ index 8bb3889..a345582 100644
set test "killall list signals" set test "killall list signals"
spawn $killall -l spawn $killall -l
-- --
2.16.4 2.25.0

View File

@ -1,18 +1,18 @@
From d4b2099ffd77d1fdea380ac42326b11a5be35e72 Mon Sep 17 00:00:00 2001 From 59144ef25a4bf0ecceb27e1c2dd2276de54555fe Mon Sep 17 00:00:00 2001
From: Werner Fink <werner@suse.de> From: Werner Fink <werner@suse.de>
Date: Thu, 15 Nov 2018 07:41:23 +0100 Date: Mon, 27 Apr 2020 16:44:17 +0200
Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS
Signed-off-by: Werner Fink <werner@suse.de> Signed-off-by: Werner Fink <werner@suse.de>
--- ---
Makefile.am | 4 +- Makefile.am | 4 +-
configure.ac | 38 +++--- configure.ac | 38 ++----
src/fuser.c | 86 +++----------- src/fuser.c | 98 ++++---------
src/statx.c | 147 +++++++++++++++++++++++ src/statx.c | 149 ++++++++++++++++++++
src/statx.h | 66 +++++++++++ src/statx.h | 68 +++++++++
src/timeout.c | 372 ---------------------------------------------------------- src/timeout.c | 372 --------------------------------------------------
src/timeout.h | 45 ------- src/timeout.h | 45 ------
7 files changed, 248 insertions(+), 510 deletions(-) 7 files changed, 258 insertions(+), 516 deletions(-)
create mode 100644 src/statx.c create mode 100644 src/statx.c
create mode 100644 src/statx.h create mode 100644 src/statx.h
delete mode 100644 src/timeout.c delete mode 100644 src/timeout.c
@ -90,7 +90,7 @@ index d8d3366..81d3674 100644
# Enable hardened compile and link flags # Enable hardened compile and link flags
AC_ARG_ENABLE([harden_flags], AC_ARG_ENABLE([harden_flags],
diff --git src/fuser.c src/fuser.c diff --git src/fuser.c src/fuser.c
index 48d52d0..f824581 100644 index 1b58374..fc98790 100644
--- src/fuser.c --- src/fuser.c
+++ src/fuser.c +++ src/fuser.c
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
@ -122,7 +122,7 @@ index 48d52d0..f824581 100644
find_mountpoint(this_name->filename, &mountinfo) != 0) { find_mountpoint(this_name->filename, &mountinfo) != 0) {
if (errno == ENOENT) if (errno == ENOENT)
fprintf(stderr, fprintf(stderr,
@@ -1250,9 +1246,7 @@ int main(int argc, char *argv[]) @@ -1241,9 +1237,7 @@ int main(int argc, char *argv[])
opts |= OPT_INTERACTIVE; opts |= OPT_INTERACTIVE;
break; break;
case 'I': case 'I':
@ -132,7 +132,7 @@ index 48d52d0..f824581 100644
break; break;
case 'k': case 'k':
opts |= OPT_KILL; opts |= OPT_KILL;
@@ -1318,10 +1312,11 @@ int main(int argc, char *argv[]) @@ -1309,10 +1303,11 @@ int main(int argc, char *argv[])
continue; continue;
} }
@ -147,7 +147,7 @@ index 48d52d0..f824581 100644
/* an option */ /* an option */
/* Not an option, must be a file specification */ /* Not an option, must be a file specification */
if ((this_name = malloc(sizeof(struct names))) == NULL) if ((this_name = malloc(sizeof(struct names))) == NULL)
@@ -1641,7 +1636,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id) @@ -1632,7 +1627,7 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename, int *id)
if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL) if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL)
return NULL; return NULL;
snprintf(pathname, 256, "/proc/%d/%s", pid, filename); snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
@ -156,7 +156,7 @@ index 48d52d0..f824581 100644
free(st); free(st);
return NULL; return NULL;
} }
@@ -1688,7 +1683,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, @@ -1679,7 +1674,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s", snprintf(filepath, sizeof filepath - 1, "/proc/%d/%s/%s",
pid, dirname, direntry->d_name); pid, dirname, direntry->d_name);
@ -165,7 +165,7 @@ index 48d52d0..f824581 100644
if (errno != ENOENT && errno != ENOTDIR) { if (errno != ENOENT && errno != ENOTDIR) {
fprintf(stderr, _("Cannot stat file %s: %s\n"), fprintf(stderr, _("Cannot stat file %s: %s\n"),
filepath, strerror(errno)); filepath, strerror(errno));
@@ -1743,7 +1738,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, @@ -1734,7 +1729,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
if (thedev != ino_tmp->device) if (thedev != ino_tmp->device)
continue; continue;
if (!st.st_ino if (!st.st_ino
@ -174,7 +174,7 @@ index 48d52d0..f824581 100644
fprintf(stderr, fprintf(stderr,
_("Cannot stat file %s: %s\n"), _("Cannot stat file %s: %s\n"),
filepath, strerror(errno)); filepath, strerror(errno));
@@ -1841,11 +1836,11 @@ static uid_t getpiduid(const pid_t pid) @@ -1832,11 +1827,11 @@ static uid_t getpiduid(const pid_t pid)
if (asprintf(&pathname, "/proc/%d", pid) < 0) if (asprintf(&pathname, "/proc/%d", pid) < 0)
return 0; return 0;
@ -190,7 +190,7 @@ index 48d52d0..f824581 100644
return st.st_uid; return st.st_uid;
} }
@@ -1883,7 +1878,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head) @@ -1874,7 +1869,7 @@ void fill_unix_cache(struct unixsocket_list **unixsocket_head)
path = scanned_path; path = scanned_path;
if (*scanned_path == '@') if (*scanned_path == '@')
scanned_path++; scanned_path++;
@ -199,7 +199,7 @@ index 48d52d0..f824581 100644
free(path); free(path);
continue; continue;
} }
@@ -2018,7 +2013,7 @@ static dev_t find_net_dev(void) @@ -2009,7 +2004,7 @@ static dev_t find_net_dev(void)
fprintf(stderr, _("Cannot open a network socket.\n")); fprintf(stderr, _("Cannot open a network socket.\n"));
return -1; return -1;
} }
@ -208,7 +208,7 @@ index 48d52d0..f824581 100644
fprintf(stderr, _("Cannot find socket's device number.\n")); fprintf(stderr, _("Cannot find socket's device number.\n"));
close(skt); close(skt);
return -1; return -1;
@@ -2051,7 +2046,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head, @@ -2042,7 +2037,7 @@ scan_knfsd(struct names *names_head, struct inode_list *ino_head,
if ((find_space = strpbrk(line, " \t")) == NULL) if ((find_space = strpbrk(line, " \t")) == NULL)
continue; continue;
*find_space = '\0'; *find_space = '\0';
@ -217,7 +217,7 @@ index 48d52d0..f824581 100644
continue; continue;
} }
/* Scan the devices */ /* Scan the devices */
@@ -2086,7 +2081,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head, @@ -2077,7 +2072,7 @@ scan_mounts(struct names *names_head, struct inode_list *ino_head,
mntinfo_t *mnt = list_entry(ptr, mntinfo_t); mntinfo_t *mnt = list_entry(ptr, mntinfo_t);
const char *find_mountp = mnt->mpoint; const char *find_mountp = mnt->mpoint;
@ -226,7 +226,7 @@ index 48d52d0..f824581 100644
continue; continue;
/* Scan the devices */ /* Scan the devices */
@@ -2133,7 +2128,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, @@ -2124,7 +2119,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
if (*find_space == '\0') if (*find_space == '\0')
continue; continue;
} }
@ -235,7 +235,7 @@ index 48d52d0..f824581 100644
continue; continue;
} }
/* Scan the devices */ /* Scan the devices */
@@ -2225,10 +2220,10 @@ init_mntinfo(void) @@ -2216,10 +2211,10 @@ init_mntinfo(void)
&mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) { &mid, &parid, &maj, &min, &mpoint[0], &type[0], &devname[0]) == 7) {
struct stat st; struct stat st;
mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min)); mntinf = add_mntinfo(mpoint, type, mid, parid, makedev(maj, min));
@ -248,7 +248,7 @@ index 48d52d0..f824581 100644
mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */ mntinf->dev = st.st_dev; /* stat(2) on binary does not see subvol dev */
} }
} }
@@ -2240,7 +2235,7 @@ init_mntinfo(void) @@ -2231,7 +2226,7 @@ init_mntinfo(void)
parid = -1; parid = -1;
while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) { while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], &type[0]) == 3) {
struct stat st; struct stat st;
@ -257,7 +257,7 @@ index 48d52d0..f824581 100644
if (errno != EACCES) { if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"), fprintf(stderr, _("Cannot stat %s: %s\n"),
mnt->mpoint, strerror(errno)); mnt->mpoint, strerror(errno));
@@ -2249,7 +2244,7 @@ init_mntinfo(void) @@ -2240,7 +2235,7 @@ init_mntinfo(void)
st.st_dev = (dev_t)-1; st.st_dev = (dev_t)-1;
} }
mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev); mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev);
@ -266,7 +266,7 @@ index 48d52d0..f824581 100644
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; mntinf->vol = st.st_rdev;
} }
@@ -2299,7 +2294,7 @@ out: @@ -2290,7 +2285,7 @@ out:
struct stat lst; struct stat lst;
snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd); snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
@ -275,7 +275,7 @@ index 48d52d0..f824581 100644
if (lst.st_mode & S_IWUSR) if (lst.st_mode & S_IWUSR)
info->flags |= O_WRONLY; info->flags |= O_WRONLY;
ret++; ret++;
@@ -2372,7 +2367,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo) @@ -2363,7 +2358,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
/* could be a chroot or a container */ /* could be a chroot or a container */
@ -284,7 +284,7 @@ index 48d52d0..f824581 100644
if (errno != EACCES) { if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"), fprintf(stderr, _("Cannot stat %s: %s\n"),
path, strerror(errno)); path, strerror(errno));
@@ -2404,7 +2399,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo) @@ -2395,7 +2390,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
/* could be a chroot or a container */ /* could be a chroot or a container */
@ -293,7 +293,7 @@ index 48d52d0..f824581 100644
if (errno != EACCES) { if (errno != EACCES) {
fprintf(stderr, _("Cannot stat %s: %s\n"), fprintf(stderr, _("Cannot stat %s: %s\n"),
use, strerror(errno)); use, strerror(errno));
@@ -2442,49 +2437,6 @@ out: @@ -2433,49 +2428,6 @@ out:
return ret; return ret;
} }
@ -1001,3 +1001,6 @@ index f372297..0000000
-#endif -#endif
- -
-#endif -#endif
--
2.25.0

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Apr 27 14:57:57 UTC 2020 - Dr. Werner Fink <werner@suse.de>
- Modify patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch
* Allow not unique mounts as well as not unique mountpoint
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Sep 19 11:57:44 UTC 2019 - Ludwig Nussel <lnussel@suse.de> Thu Sep 19 11:57:44 UTC 2019 - Ludwig Nussel <lnussel@suse.de>

View File

@ -1,7 +1,7 @@
# #
# spec file for package psmisc # spec file for package psmisc
# #
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2020 SUSE LLC
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -26,7 +26,7 @@ BuildRequires: glibc-devel
BuildRequires: libselinux-devel BuildRequires: libselinux-devel
BuildRequires: linux-glibc-devel >= 4.12 BuildRequires: linux-glibc-devel >= 4.12
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
Url: https://gitlab.com/psmisc/psmisc/ URL: https://gitlab.com/psmisc/psmisc/
Version: 23.2 Version: 23.2
Release: 0 Release: 0
Provides: ps:/usr/bin/killall Provides: ps:/usr/bin/killall