]> granicus.if.org Git - psmisc/commitdiff
3 fixes for Cygwin
authorCorinna Vinschen <corinnav999@users.sourceforge.net>
Sat, 19 May 2012 08:54:35 +0000 (18:54 +1000)
committerCraig Small <csmall@users.sourceforge.net>
Sat, 19 May 2012 08:54:35 +0000 (18:54 +1000)
The attached patch fixes three issues of fuser on Cygwin.:

- Cygwin does not support /proc/net/unix. The call to fill_unix_cache
  always generates an error message that /proc/net/unix couldn't be
  found, so the patch disables the call for Cygwin. An alternative
  fix would be to avoid the error message entirely.

- `ls /dev' on Cygwin only lists manually added entries to /dev, not the
  default files suported by Cygwin internally. Also,
  /proc/$PID/mountinfo doesn't exist up to Cygwin 1.7.11. This
  breaks fuser when using the _LISTS_H option.

- If you don't include lists.h, the code in check_dir doesn't work well.
  st.st_ino is never set to 0, so the timeout(stat, ...) is never
  called. Also, thedev never gets a valid value in this case, but it's
  used subsequently for comparisons.

ChangeLog
src/fuser.c
src/fuser.h

index 36b68fb5f339b9f9d449aa7a5165f538024483e7..1ac7decbe25d4de6f770c75e98069be376f0a136 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ Changes in 22.17 (unreleased)
        * fuser is not compiled on hurd-i386 Debian #673485
        * No TEXTRELS in src/lists built as PIE on x86
        * Fake pstree root for kernels with hidepid turned on
+       * More fixes for Cygwin SF Patch #3511920
 
 Changes in 22.16
 ================
index 5a09cf29bae665e3253224192172b5f5f544ea84..27cb93496c6c2217f6256dbb748823c5d4b35569 100644 (file)
@@ -265,7 +265,7 @@ scan_procs(struct names *names_head, struct inode_list *ino_head,
                if (root_stat) free(root_stat);
                if (cwd_stat)  free(cwd_stat);
                if (exe_stat)  free(exe_stat);
-#ifndef __linux__
+#if !defined (__linux__) && !defined (__CYGWIN__)
                check_dir(pid, "lib", dev_head, ino_head, uid, ACCESS_MMAP,
                          sockets, netdev);
                check_dir(pid, "mmap", dev_head, ino_head, uid, ACCESS_MMAP,
@@ -932,7 +932,9 @@ int main(int argc, char *argv[])
 #endif
 
        netdev = find_net_dev();
+#ifndef __CYGWIN__     /* Cygwin doesn't support /proc/net/unix */
        fill_unix_cache(&unixsockets);
+#endif
 
     for (argc_cnt = 1; argc_cnt < argc; argc_cnt++) {
       current_argv = argv[argc_cnt];
@@ -1375,7 +1377,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
                st.st_ino = 0;
                if ((thedev = device(filepath)) < 0)
 #else
-               if (!st.st_ino && timeout(stat, filepath, &st, 5) != 0)
+               if (timeout(stat, filepath, &st, 5) != 0)
 #endif
                {
             if (errno != ENOENT) {
@@ -1383,6 +1385,9 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
                                    filepath, strerror(errno));
             }
                } else {
+#ifndef _LISTS_H
+                       thedev = st.st_dev;
+#endif
                        if (thedev == netdev) {
                                for (sock_tmp = sockets; sock_tmp != NULL;
                                     sock_tmp = sock_tmp->next) {
index 21eb72048a7c9043bc5bd0a7e202d867f73d3b31..242ce19afb2fde8be23cf708bba5d460803511a9 100644 (file)
@@ -86,7 +86,7 @@ struct mount_list {
        struct mount_list *next;
 };
 
-#if defined (__GNUC__) && defined(__OPTIMIZE__)
+#if defined (__GNUC__) && defined(__OPTIMIZE__) && !defined (__CYGWIN__)
 # include "lists.h"
 typedef struct mntinfo_s {
     list_t   this;