summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinnav999@users.sourceforge.net>2012-05-19 18:54:35 +1000
committerCraig Small <csmall@users.sourceforge.net>2012-05-19 18:54:35 +1000
commitf046053911fb2cafa36453114f5dce740fb86326 (patch)
treec0aee27a7a192824865d475fb2b61ff28764f555
parent26f9b6c1553d021c0bf9dd85f0647dc6e210948d (diff)
3 fixes for Cygwin
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.
-rw-r--r--ChangeLog1
-rw-r--r--src/fuser.c9
-rw-r--r--src/fuser.h2
3 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 36b68fb..1ac7dec 100644
--- 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
================
diff --git a/src/fuser.c b/src/fuser.c
index 5a09cf2..27cb934 100644
--- a/src/fuser.c
+++ b/src/fuser.c
@@ -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) {
diff --git a/src/fuser.h b/src/fuser.h
index 21eb720..242ce19 100644
--- a/src/fuser.h
+++ b/src/fuser.h
@@ -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;