Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package psmisc for openSUSE:Factory checked 
in at 2022-02-24 18:18:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/psmisc (Old)
 and      /work/SRC/openSUSE:Factory/.psmisc.new.1958 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "psmisc"

Thu Feb 24 18:18:29 2022 rev:82 rq:957096 version:23.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/psmisc/psmisc.changes    2022-01-22 
08:18:21.234835122 +0100
+++ /work/SRC/openSUSE:Factory/.psmisc.new.1958/psmisc.changes  2022-02-24 
18:18:39.514735162 +0100
@@ -1,0 +2,15 @@
+Wed Feb 23 13:04:06 UTC 2022 - Dr. Werner Fink <wer...@suse.de>
+
+- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch 
+  * Add a fallback if the system call name_to_handle_at() is
+    not supported by the used file system.
+
+-------------------------------------------------------------------
+Tue Feb  1 12:39:16 UTC 2022 - Dr. Werner Fink <wer...@suse.de>
+
+- Change patch 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch 
+  * Determine the namespace of a process only once to speed
+    up the parsing of fdinfo (bsc#1194172).
+- Adopt patch 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ 0001-Use-mountinfo-to-be-able-to-use-the-mount-identity.patch ++++++
--- /var/tmp/diff_new_pack.4kloir/_old  2022-02-24 18:18:40.650734858 +0100
+++ /var/tmp/diff_new_pack.4kloir/_new  2022-02-24 18:18:40.650734858 +0100
@@ -1,6 +1,6 @@
-From bfa17afa43fc1b98c2bbc9c54416db9ccb505028 Mon Sep 17 00:00:00 2001
+From 1066ab018235e9981d8770f6c94b294f8b16c7fe Mon Sep 17 00:00:00 2001
 From: Werner Fink <wer...@suse.de>
-Date: Fri, 7 May 2021 16:25:13 +0200
+Date: Wed, 23 Feb 2022 13:58:32 +0100
 Subject: [PATCH] Use mountinfo to be able to use the mount identity
 
 which allows to distinguish different mounts with the
@@ -22,13 +22,19 @@
 Correct last change by using our own namespace to
 determine the appropriate mount ID for e.g. qcow2 files.
 
+Determine the namespace of a process only once to speed
+up the parsing of fdinfo.
+
+Add a fallback if the system call name_to_handle_at() is
+not supported by the used file system.
+
 Signed-off-by: Werner Fink <wer...@suse.de>
 ---
  configure.ac  |  15 +-
- src/fuser.c   | 683 +++++++++++++++++++++++++++++++++++++++-----------
+ src/fuser.c   | 734 +++++++++++++++++++++++++++++++++++++++-----------
  src/fuser.h   |  25 +-
  src/timeout.c |   5 +-
- 4 files changed, 567 insertions(+), 161 deletions(-)
+ 4 files changed, 618 insertions(+), 161 deletions(-)
 
 diff --git configure.ac configure.ac
 index 182a0df..d4dee51 100644
@@ -64,7 +70,7 @@
  dnl Checks for typedefs, structures, and compiler characteristics.
  AC_C_CONST
 diff --git src/fuser.c src/fuser.c
-index 03e6237..dd928d2 100644
+index 03e6237..ee2ba15 100644
 --- src/fuser.c
 +++ src/fuser.c
 @@ -32,6 +32,8 @@
@@ -98,7 +104,7 @@
  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,
-@@ -117,9 +119,15 @@ static void debug_match_lists(struct names *names_head,
+@@ -117,9 +119,16 @@ static void debug_match_lists(struct names *names_head,
                              struct device_list *dev_head);
  #endif
  
@@ -106,8 +112,9 @@
 +static list_t mntinfo = { &mntinfo, &mntinfo };
  static void clear_mntinfo(void) __attribute__ ((__destructor__));
  static void init_mntinfo(void) __attribute__ ((__constructor__));
-+static int get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info);
++static int get_fdinfo(const pid_t pid, const char *fd, struct fdinfo *info, 
const ino_t ns);
 +#if defined(HAS_NAME_TO_HANDLE_AT)
++static ino_t get_namespace(const pid_t pid);
 +static int get_mountid(const char *path);
 +#endif
 +static int find_mountpoint(const char *path, mntinfo_t **mountinfo);
@@ -115,7 +122,7 @@
  static int mntstat(const char *path, struct stat *buf);
  #endif
  static stat_t thestat = stat;
-@@ -210,6 +218,7 @@ scan_procs(struct names *names_head, struct inode_list 
*ino_head,
+@@ -210,6 +219,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;
@@ -123,7 +130,7 @@
  
                if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > 
'9')     /* Not a process */
                        continue;
-@@ -219,9 +228,9 @@ scan_procs(struct names *names_head, struct inode_list 
*ino_head,
+@@ -219,9 +229,9 @@ scan_procs(struct names *names_head, struct inode_list 
*ino_head,
                        continue;
                uid = getpiduid(pid);
  
@@ -136,7 +143,7 @@
                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;
-@@ -229,39 +238,51 @@ scan_procs(struct names *names_head, struct inode_list 
*ino_head,
+@@ -229,39 +239,51 @@ 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) {
@@ -203,7 +210,7 @@
                                if (cwd_stat
                                    && cwd_stat->st_dev == ino_tmp->device
                                    && cwd_stat->st_ino == ino_tmp->inode)
-@@ -302,18 +323,42 @@ add_inode(struct inode_list **ino_list, struct names 
*this_name,
+@@ -302,18 +324,42 @@ add_inode(struct inode_list **ino_list, struct names 
*this_name,
        ino_tmp->name = this_name;
        ino_tmp->device = device;
        ino_tmp->inode = inode;
@@ -247,7 +254,7 @@
  
        if ((dev_tmp =
             (struct device_list *)malloc(sizeof(struct device_list))) == NULL)
-@@ -321,6 +366,10 @@ add_device(struct device_list **dev_list, struct names 
*this_name, dev_t device)
+@@ -321,6 +367,10 @@ 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;
@@ -258,7 +265,7 @@
        dev_tmp->next = dev_head;
        *dev_list = dev_tmp;
  }
-@@ -462,13 +511,15 @@ add_special_proc(struct names *name_list, const char 
ptype, const uid_t uid,
+@@ -462,13 +512,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)
  {
@@ -275,7 +282,7 @@
                if (errno == ENOENT)
                        fprintf(stderr,
                                _("Specified filename %s does not exist.\n"),
-@@ -478,10 +529,12 @@ int parse_file(struct names *this_name, struct 
inode_list **ino_list,
+@@ -478,10 +530,12 @@ int parse_file(struct names *this_name, struct 
inode_list **ino_list,
                                this_name->filename, strerror(errno));
                return -1;
        }
@@ -290,7 +297,7 @@
  #endif                                /* DEBUG */
        add_inode(ino_list, this_name, this_name->st.st_dev,
                  this_name->st.st_ino);
-@@ -513,12 +566,43 @@ parse_mounts(struct names *this_name, struct device_list 
**dev_list,
+@@ -513,12 +567,43 @@ parse_mounts(struct names *this_name, struct device_list 
**dev_list,
             const opt_type opts)
  {
        dev_t match_device;
@@ -335,7 +342,7 @@
        return 0;
  }
  
-@@ -695,10 +779,12 @@ int parse_inet(struct names *this_name, struct 
ip_connections **ip_list)
+@@ -695,10 +780,12 @@ int parse_inet(struct names *this_name, struct 
ip_connections **ip_list)
                                        break;
  #endif
                                }
@@ -351,7 +358,7 @@
        }
        return 1;
  }
-@@ -965,6 +1051,21 @@ free_inodes(struct inode_list **match_inodes)
+@@ -965,6 +1052,21 @@ free_inodes(struct inode_list **match_inodes)
  /*
   * Free up structures allocated in add_device
   */
@@ -373,7 +380,7 @@
  static void
  free_devices(struct device_list **match_devices)
  {
-@@ -972,6 +1073,8 @@ free_devices(struct device_list **match_devices)
+@@ -972,6 +1074,8 @@ free_devices(struct device_list **match_devices)
  
        device_tmp = *match_devices;
        while(device_tmp != NULL) {
@@ -382,7 +389,7 @@
                device_next = device_tmp->next;
                free(device_tmp);
                device_tmp = device_next;
-@@ -1174,16 +1277,11 @@ int main(int argc, char *argv[])
+@@ -1174,16 +1278,11 @@ int main(int argc, char *argv[])
                                        skip_argv = 1;
                                        //while(option != '\0') option++;
                                        if (strcmp(argv[argc_cnt], "tcp") == 0)
@@ -404,7 +411,7 @@
                                        else
                                                usage(_
                                                      ("Invalid namespace 
name"));
-@@ -1223,7 +1321,7 @@ int main(int argc, char *argv[])
+@@ -1223,7 +1322,7 @@ int main(int argc, char *argv[])
                }
  
  #if defined(WITH_MOUNTINFO_LIST)
@@ -413,7 +420,7 @@
                        thestat = mntstat;
  #endif
                /* an option */
-@@ -1537,7 +1635,7 @@ print_matches(struct names *names_head, const opt_type 
opts,
+@@ -1537,7 +1636,7 @@ print_matches(struct names *names_head, const opt_type 
opts,
  
  }
  
@@ -422,7 +429,7 @@
  {
        char pathname[PATH_MAX];
        struct stat *st;
-@@ -1549,6 +1647,15 @@ static struct stat *get_pidstat(const pid_t pid, const 
char *filename)
+@@ -1549,6 +1648,15 @@ static struct stat *get_pidstat(const pid_t pid, const 
char *filename)
                free(st);
                return NULL;
        }
@@ -438,7 +445,7 @@
        return st;
  }
  
-@@ -1563,7 +1670,7 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1563,10 +1671,11 @@ 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;
@@ -447,7 +454,24 @@
        char *dirpath;
        char filepath[PATH_MAX];
        char real_filepath[PATH_MAX];
-@@ -1589,6 +1696,9 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
++      ino_t ns;
+ 
+       if (asprintf(&dirpath, "/proc/%d/%s", pid, dirname) < 0)
+         return;
+@@ -1576,6 +1685,12 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+     }
+     free(dirpath);
+ 
++#if defined(HAS_NAME_TO_HANDLE_AT)
++      ns = get_namespace(pid);
++#else
++      ns = -1;
++#endif
++
+       while ((direntry = readdir(dirp)) != NULL) {
+               if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9')
+                       continue;
+@@ -1589,6 +1704,9 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
                                        filepath, strerror(errno));
                        }
                } else {
@@ -457,13 +481,13 @@
                        thedev = st.st_dev;
                        if (thedev == netdev) {
                                for (sock_tmp = sockets; sock_tmp != NULL;
-@@ -1601,10 +1711,29 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1601,10 +1719,29 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
                                        }
                                }
                        }
 +
 +                      memset(&fd, 0, sizeof(struct fdinfo));
-+                      fdret = get_fdinfo(pid, direntry->d_name, &fd);
++                      fdret = get_fdinfo(pid, direntry->d_name, &fd, ns);
 +
                        for (dev_tmp = dev_head; dev_tmp != NULL;
                             dev_tmp = dev_tmp->next) {
@@ -489,7 +513,7 @@
  
                                /* check the paths match if it is not a block 
device */
                                if (! S_ISBLK(dev_tmp->name->st.st_mode)) {
-@@ -1616,9 +1745,14 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1616,9 +1753,14 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
                                            continue;
                                    }
                                }
@@ -506,7 +530,7 @@
                                        add_matched_proc(dev_tmp->name,
                                                         pid, uid,
                                                         ACCESS_FILEWR |
-@@ -1640,9 +1774,10 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1640,9 +1782,10 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
                                        continue;
                                }
                                if (st.st_ino == ino_tmp->inode) {
@@ -519,7 +543,7 @@
                                                add_matched_proc(ino_tmp->name,
                                                                 pid, uid,
                                                                 ACCESS_FILEWR |
-@@ -1671,31 +1806,54 @@ check_map(const pid_t pid, const char *filename,
+@@ -1671,31 +1814,54 @@ check_map(const pid_t pid, const char *filename,
        FILE *fp;
        unsigned long long tmp_inode;
        unsigned int tmp_maj, tmp_min;
@@ -584,7 +608,7 @@
        }
        fclose(fp);
  }
-@@ -1719,6 +1877,7 @@ static uid_t getpiduid(const pid_t pid)
+@@ -1719,6 +1885,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
   */
@@ -592,7 +616,7 @@
  void fill_unix_cache(struct unixsocket_list **unixsocket_head)
  {
        FILE *fp;
-@@ -1735,6 +1894,8 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
+@@ -1735,6 +1902,8 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
        while (fgets(line, BUFSIZ, fp) != NULL) {
                char *path;
                char *scanned_path = NULL;
@@ -601,7 +625,7 @@
                if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %llu %ms",
                           &scanned_inode, &scanned_path) != 2) {
                        if (scanned_path)
-@@ -1750,6 +1911,8 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
+@@ -1750,6 +1919,8 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
                        free(path);
                        continue;
                }
@@ -610,7 +634,7 @@
                if ((newsocket = (struct unixsocket_list *)
                     malloc(sizeof(struct unixsocket_list))) == NULL) {
                        free(path);
-@@ -1758,6 +1921,7 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
+@@ -1758,6 +1929,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;
@@ -618,7 +642,7 @@
                newsocket->net_inode = scanned_inode;
                newsocket->next = *unixsocket_head;
                *unixsocket_head = newsocket;
-@@ -1770,6 +1934,7 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
+@@ -1770,6 +1942,7 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
  /*
   * Free up the list of Unix sockets
   */
@@ -626,7 +650,7 @@
  void clear_unix_cache(struct unixsocket_list **unixsocket_head)
  {
        while(*unixsocket_head != NULL) {
-@@ -1941,34 +2106,21 @@ scan_mounts(struct names *names_head, struct 
inode_list *ino_head,
+@@ -1941,34 +2114,21 @@ scan_mounts(struct names *names_head, struct 
inode_list *ino_head,
  {
        struct device_list *dev_tmp;
        struct inode_list *ino_tmp;
@@ -653,11 +677,11 @@
 -                      continue;
 -              find_mountp++;
 -              if ((find_space = strchr(find_mountp, ' ')) == NULL)
--                      continue;
--              *find_space = '\0';
--              if (timeout(thestat, find_mountp, &st, 5) != 0) {
 +              if (timeout(thestat, find_mountp, &st, 5) != 0)
                        continue;
+-              *find_space = '\0';
+-              if (timeout(thestat, find_mountp, &st, 5) != 0) {
+-                      continue;
 -              }
 +
                /* Scan the devices */
@@ -669,7 +693,7 @@
                                add_special_proc(dev_tmp->name, PTYPE_MOUNT, 0,
                                                 find_mountp);
                }
-@@ -1980,7 +2132,6 @@ scan_mounts(struct names *names_head, struct inode_list 
*ino_head,
+@@ -1980,7 +2140,6 @@ scan_mounts(struct names *names_head, struct inode_list 
*ino_head,
                                                 find_mountp);
                }
        }
@@ -677,7 +701,7 @@
  }
  
  static void
-@@ -2033,16 +2184,44 @@ scan_swaps(struct names *names_head, struct inode_list 
*ino_head,
+@@ -2033,16 +2192,44 @@ scan_swaps(struct names *names_head, struct inode_list 
*ino_head,
        fclose(fp);
  }
  
@@ -726,7 +750,7 @@
  {
        list_t *ptr, *tmp;
  
-@@ -2053,72 +2232,276 @@ static void clear_mntinfo(void)
+@@ -2053,72 +2240,319 @@ static void clear_mntinfo(void)
        }
  }
  
@@ -780,8 +804,17 @@
 +                              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);
+-              strcpy(mnt->mpoint, mpoint);
+-              mnt->nlen = nlen;
+-              mnt->parid = parid;
+-              mnt->dev = makedev(maj, min);
+-              mnt->id = mid;
+-              if (mid > max)
+-                      max = mid;
+       }
 +#else
 +      if ((mnt = fopen(PROC_MOUNTS, "r")) == (FILE *) 0)
 +              return;
@@ -801,26 +834,17 @@
 +              if (mntinf && strncmp(devname, "/dev/", 5) == 0 && 
stat(devname, &st) == 0) {
 +                      if (st.st_rdev != 0 && mntinf->dev != 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
        fclose(mnt);
 +}
 +
 +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, const ino_t 
ns)
 +{
 +      int ret = 0;
-+      char pathname[256];
++      char pathname[512];
 +      int mnt_id = 0, flags = 0;
 +#if defined(HAS_FDINFO)                                       /* Here we get 
the private namespace as well */
 +      const static char delimiters[] = ": \t\n";
@@ -839,7 +863,7 @@
 +              mynamespace = st.st_ino;
 +      }
 +# endif
-+      snprintf(pathname, 256, "/proc/%d/fdinfo/%s", pid, fd);
++      snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fdinfo/%s", pid, fd);
 +      if ((fp = fopen(pathname, "r")) == NULL)
 +               goto out;                              /* forbidden 
namesspace, try our own namespace */
 +      while (fgets(line, BUFSIZ, fp) && ret < 2) {
@@ -865,10 +889,9 @@
 +      fclose(fp);
 +out:
 +# if defined(HAS_NAME_TO_HANDLE_AT)
-+      snprintf(pathname, 256, "/proc/%d/ns/mnt", pid);
-+      if (stat(pathname, &st) == 0 && mynamespace != st.st_ino) {
++      if (mynamespace != ns) {
 +              char *realname;
-+              snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
++              snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, 
fd);
 +              realname = expandpath(pathname);
 +              if (realname) {                         /* Use our namespace 
for mount ID <sigh> */
 +                      info->mnt_id = get_mountid(realname);
@@ -880,7 +903,7 @@
 +      if (!flags || !mnt_id) {
 +              struct stat lst;
 +
-+              snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
++              snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, 
fd);
 +              if (!flags && lstat(pathname, &lst) == 0) {
 +                      if (lst.st_mode & S_IWUSR)
 +                              info->flags |= O_WRONLY;
@@ -907,6 +930,17 @@
 -              list_t *ptr, *tmp;
 -              list_for_each_safe(ptr, tmp, &mntinfo) {
 +#if defined(HAS_NAME_TO_HANDLE_AT)
++static ino_t
++get_namespace(const pid_t pid)
++{
++      char pathname[512];
++      struct stat st;
++      snprintf(pathname, sizeof(pathname)-1, "/proc/%d/ns/mnt", pid);
++      if (stat(pathname, &st) == 0)
++              return st.st_ino;
++      return -1;
++}
++
 +static int
 +get_mountid(const char *path)
 +{
@@ -917,8 +951,41 @@
 +      int mnt_id = -1;
 +
 +      errno = 0;
-+      if (name_to_handle_at(0, path, &fh.handle, &mnt_id, 0) == -1)
-+              mnt_id = -1;
++      if (name_to_handle_at(0, path, &fh.handle, &mnt_id, 0) == -1) {
++              const static char delimiters[] = ": \t\n";
++              char fdinfo[PATH_MAX+1];
++              char line[BUFSIZ];
++              FILE* fp;
++              int fd;
++
++              if (errno != EOPNOTSUPP)
++                      return -1;
++              fd = open(path, O_PATH);
++              if (fd < 0)
++                      return -1;
++
++              snprintf(fdinfo, PATH_MAX, "/proc/self/fdinfo/%d", fd);
++              if ((fp = fopen(fdinfo, "r")) == NULL) {
++                      close(fd);
++                      return -1;
++              }
++              while (fgets(line, BUFSIZ, fp)) {
++                      char *xp, *vp, *ep;
++                      unsigned long ul;
++                      xp = strtok(&line[0], delimiters);
++                      if (!xp || *xp == 0)
++                              continue;
++                      vp = strtok(NULL, delimiters);
++                      if (!vp || *vp == 0)
++                              continue;
++                      if (strcmp(xp, "mnt_id") == 0 && (ul = strtoul(vp, &ep, 
0)) != ULONG_MAX && ep && *ep == 0) {
++                              mnt_id = (int)ul;
++                              break;
++                      }
++              }
++              fclose(fp);
++              close(fd);
++      }
 +      return mnt_id;
 +}
 +#endif
@@ -1047,7 +1114,7 @@
  /*
   * Determine device of links below /proc/
   */
-@@ -2126,8 +2509,7 @@ static int mntstat(const char *path, struct stat *buf)
+@@ -2126,8 +2560,7 @@ static int mntstat(const char *path, struct stat *buf)
  {
        char name[PATH_MAX + 1];
        const char *use;
@@ -1057,7 +1124,7 @@
  
        if ((use = realpath(path, name)) == NULL || *use != '/')
        {
-@@ -2139,27 +2521,26 @@ static int mntstat(const char *path, struct stat *buf)
+@@ -2139,27 +2572,26 @@ static int mntstat(const char *path, struct stat *buf)
                errno = 0;
                return stat(path, buf);
        }

++++++ 0002-Use-new-statx-2-system-call-to-avoid-hangs-on-NFS.patch ++++++
--- /var/tmp/diff_new_pack.4kloir/_old  2022-02-24 18:18:40.662734855 +0100
+++ /var/tmp/diff_new_pack.4kloir/_new  2022-02-24 18:18:40.666734854 +0100
@@ -1,6 +1,6 @@
-From f2ada8ea7939bc8f607d88a10c92d5bb96a700b8 Mon Sep 17 00:00:00 2001
+From ab950c00ff36acf1731330f3b55863b3102cfe6a Mon Sep 17 00:00:00 2001
 From: Werner Fink <wer...@suse.de>
-Date: Fri, 7 May 2021 16:36:28 +0200
+Date: Tue, 1 Feb 2022 13:34:41 +0100
 Subject: [PATCH] Use new statx(2) system call to avoid hangs on NFS
 
 Signed-off-by: Werner Fink <wer...@suse.de>
@@ -90,7 +90,7 @@
  # Enable hardened compile and link flags
  AC_ARG_ENABLE([harden_flags],
 diff --git src/fuser.c src/fuser.c
-index dd928d2..d08f7a9 100644
+index 79d44ef..21b4695 100644
 --- src/fuser.c
 +++ src/fuser.c
 @@ -65,7 +65,7 @@
@@ -102,7 +102,7 @@
  #include "comm.h"
  
  //#define DEBUG 1
-@@ -127,10 +127,6 @@ static int get_fdinfo(const pid_t pid, const char *fd, 
struct fdinfo *info);
+@@ -128,10 +128,6 @@ static ino_t get_namespace(const pid_t pid);
  static int get_mountid(const char *path);
  #endif
  static int find_mountpoint(const char *path, mntinfo_t **mountinfo);
@@ -113,7 +113,7 @@
  static char *expandpath(const char *path);
  static struct unixsocket_list *unixsockets = NULL;
  static struct names *names_head = NULL, *names_tail = NULL;
-@@ -518,7 +514,7 @@ int parse_file(struct names *this_name, struct inode_list 
**ino_list,
+@@ -519,7 +515,7 @@ int parse_file(struct names *this_name, struct inode_list 
**ino_list,
                        free(this_name->filename);
                this_name->filename = strdup(new);
        }
@@ -122,7 +122,7 @@
            find_mountpoint(this_name->filename, &mountinfo) != 0) {
                if (errno == ENOENT)
                        fprintf(stderr,
-@@ -1252,9 +1248,7 @@ int main(int argc, char *argv[])
+@@ -1253,9 +1249,7 @@ int main(int argc, char *argv[])
                                        opts |= OPT_INTERACTIVE;
                                        break;
                                case 'I':
@@ -132,7 +132,7 @@
                                        break;
                                case 'k':
                                        opts |= OPT_KILL;
-@@ -1320,10 +1314,11 @@ int main(int argc, char *argv[])
+@@ -1321,10 +1315,11 @@ int main(int argc, char *argv[])
                        continue;
                }
  
@@ -147,7 +147,7 @@
                /* an option */
                /* Not an option, must be a file specification */
                if ((this_name = malloc(sizeof(struct names))) == NULL)
-@@ -1643,7 +1638,7 @@ static struct stat *get_pidstat(const pid_t pid, const 
char *filename, int *id)
+@@ -1644,7 +1639,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, PATH_MAX-1, "/proc/%d/%s", pid, filename);
@@ -156,7 +156,7 @@
                free(st);
                return NULL;
        }
-@@ -1690,7 +1685,7 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1698,7 +1693,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);
  
@@ -165,7 +165,7 @@
                        if (errno != ENOENT && errno != ENOTDIR) {
                                fprintf(stderr, _("Cannot stat file %s: %s\n"),
                                        filepath, strerror(errno));
-@@ -1767,7 +1762,7 @@ check_dir(const pid_t pid, const char *dirname, struct 
device_list *dev_head,
+@@ -1775,7 +1770,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
@@ -174,7 +174,7 @@
                                        fprintf(stderr,
                                                _("Cannot stat file %s: %s\n"),
                                                filepath, strerror(errno));
-@@ -1865,11 +1860,11 @@ static uid_t getpiduid(const pid_t pid)
+@@ -1873,11 +1868,11 @@ static uid_t getpiduid(const pid_t pid)
  
        if (asprintf(&pathname, "/proc/%d", pid) < 0)
                return 0;
@@ -190,7 +190,7 @@
        return st.st_uid;
  }
  
-@@ -1907,7 +1902,7 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
+@@ -1915,7 +1910,7 @@ void fill_unix_cache(struct unixsocket_list 
**unixsocket_head)
                path = scanned_path;
                if (*scanned_path == '@')
                        scanned_path++;
@@ -199,7 +199,7 @@
                        free(path);
                        continue;
                }
-@@ -2042,7 +2037,7 @@ static dev_t find_net_dev(void)
+@@ -2050,7 +2045,7 @@ static dev_t find_net_dev(void)
                fprintf(stderr, _("Cannot open a network socket.\n"));
                return -1;
        }
@@ -208,7 +208,7 @@
                fprintf(stderr, _("Cannot find socket's device number.\n"));
                close(skt);
                return -1;
-@@ -2079,7 +2074,7 @@ scan_knfsd(struct names *names_head, struct inode_list 
*ino_head,
+@@ -2087,7 +2082,7 @@ scan_knfsd(struct names *names_head, struct inode_list 
*ino_head,
                if ((find_space = strpbrk(line, " \t")) == NULL)
                        continue;
                *find_space = '\0';
@@ -217,7 +217,7 @@
                        continue;
                }
                /* Scan the devices */
-@@ -2113,7 +2108,7 @@ scan_mounts(struct names *names_head, struct inode_list 
*ino_head,
+@@ -2121,7 +2116,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;
  
@@ -226,7 +226,7 @@
                        continue;
  
                /* Scan the devices */
-@@ -2163,7 +2158,7 @@ scan_swaps(struct names *names_head, struct inode_list 
*ino_head,
+@@ -2171,7 +2166,7 @@ scan_swaps(struct names *names_head, struct inode_list 
*ino_head,
                        if (*find_space == '\0')
                                continue;
                }
@@ -235,7 +235,7 @@
                        continue;
                }
                /* Scan the devices */
-@@ -2260,10 +2255,10 @@ init_mntinfo(void)
+@@ -2268,10 +2263,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));
@@ -248,7 +248,7 @@
                                mntinf->dev = st.st_dev;        /* stat(2) on 
binary does not see subvol dev */
                        }
                }
-@@ -2275,7 +2270,7 @@ init_mntinfo(void)
+@@ -2283,7 +2278,7 @@ init_mntinfo(void)
        parid = -1;
        while (fscanf (mnt, "%s %s %s %*[^\n]", &devname[0], &mpoint[0], 
&type[0]) == 3) {
                struct stat st;
@@ -257,7 +257,7 @@
                        if (errno != EACCES) {
                                fprintf(stderr, _("Cannot stat %s: %s\n"),
                                        mpoint, strerror(errno));
-@@ -2284,7 +2279,7 @@ init_mntinfo(void)
+@@ -2292,7 +2287,7 @@ init_mntinfo(void)
                        st.st_dev = (dev_t)-1;
                }
                mntinf = add_mntinfo(mpoint, type, mid++, parid, st.st_dev);
@@ -266,7 +266,7 @@
                        if (st.st_rdev != 0 && mntinf->dev != st.st_rdev)
                                mntinf->vol = st.st_rdev;
                }
-@@ -2308,7 +2303,7 @@ get_fdinfo(const pid_t pid, const char *fd, struct 
fdinfo *info)
+@@ -2316,7 +2311,7 @@ get_fdinfo(const pid_t pid, const char *fd, struct 
fdinfo *info, const ino_t ns)
        struct stat st;
   
        if (!mynamespace) {
@@ -275,25 +275,25 @@
                        fprintf(stderr, _("Cannot stat %s: %s\n"),
                                "/proc/self/ns/mnt", strerror(errno));
                        exit(1);
-@@ -2343,7 +2338,7 @@ get_fdinfo(const pid_t pid, const char *fd, struct 
fdinfo *info)
- out:
- # if defined(HAS_NAME_TO_HANDLE_AT)
-       snprintf(pathname, 256, "/proc/%d/ns/mnt", pid);
--      if (stat(pathname, &st) == 0 && mynamespace != st.st_ino) {
-+      if (statn(pathname, STATX_INO, &st) == 0 && mynamespace != st.st_ino) {
-               char *realname;
-               snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
-               realname = expandpath(pathname);
-@@ -2358,7 +2353,7 @@ out:
+@@ -2365,7 +2360,7 @@ out:
                struct stat lst;
  
-               snprintf(pathname, 256, "/proc/%d/fd/%s", pid, fd);
+               snprintf(pathname, sizeof(pathname)-1, "/proc/%d/fd/%s", pid, 
fd);
 -              if (!flags && lstat(pathname, &lst) == 0) {
 +              if (!flags && lstatn(pathname, STATX_MODE, &lst) == 0) {
                        if (lst.st_mode & S_IWUSR)
                                info->flags |= O_WRONLY;
                        ret++;
-@@ -2431,7 +2426,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
+@@ -2392,7 +2387,7 @@ get_namespace(const pid_t pid)
+       char pathname[512];
+       struct stat st;
+       snprintf(pathname, sizeof(pathname)-1, "/proc/%d/ns/mnt", pid);
+-      if (stat(pathname, &st) == 0)
++      if (statn(pathname, STATX_INO, &st) == 0)
+               return st.st_ino;
+       return -1;
+ }
+@@ -2449,7 +2444,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
  
                        /* could be a chroot or a container */
  
@@ -302,7 +302,7 @@
                                if (errno != EACCES) {
                                        fprintf(stderr, _("Cannot stat %s: 
%s\n"),
                                                path, strerror(errno));
-@@ -2463,7 +2458,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
+@@ -2481,7 +2476,7 @@ find_mountpoint(const char *path, mntinfo_t **mountinfo)
  
                                        /* could be a chroot or a container */
  
@@ -311,7 +311,7 @@
                                                if (errno != EACCES) {
                                                        fprintf(stderr, 
_("Cannot stat %s: %s\n"),
                                                                use, 
strerror(errno));
-@@ -2501,49 +2496,6 @@ out:
+@@ -2519,49 +2514,6 @@ out:
        return ret;
  }
  

Reply via email to