diff --git a/CHANGES b/CHANGES index d692c35..ea64984 100644 --- a/CHANGES +++ b/CHANGES @@ -69,6 +69,9 @@ Porting: Fixed ancillary messages on Solaris. + Filan: Solaris has the open file path infos in /proc//path/ + Thanks to Andy Fiddaman to directing me to the patch. + Features: Filan prints target of symlink when appropriate Test: FILANSYMLINK diff --git a/config.h.in b/config.h.in index 62f10d3..be3cee9 100644 --- a/config.h.in +++ b/config.h.in @@ -652,6 +652,7 @@ /* Define if you have the /proc/$$/fd directories */ #undef HAVE_PROC_DIR_FD +#undef HAVE_PROC_DIR_PATH #undef HAVE_SETGRENT #undef HAVE_GETGRENT diff --git a/configure.ac b/configure.ac index 973a7f2..f32ff86 100644 --- a/configure.ac +++ b/configure.ac @@ -1985,6 +1985,16 @@ else AC_MSG_RESULT(no) fi +# On Solaris family, we have to use /proc/$$/path/N +AC_MSG_CHECKING(for /proc/*/path) +if test -d /proc/$$/path; then + AC_DEFINE(HAVE_PROC_DIR_PATH, 1) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + + dnl "tcpd" "tcpwrappers" # on some platforms, raw linking with libwrap fails because allow_severity and # deny_severity are not explicitely defined. Thus we put the libwrap part to diff --git a/fdname.c b/fdname.c index c7931a0..0083b9e 100644 --- a/fdname.c +++ b/fdname.c @@ -60,7 +60,7 @@ int fdname(const char *file, int fd, FILE *outfile, const char *numform, } } -#if HAVE_PROC_DIR_FD +#if HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH static int procgetfdname(int fd, char *filepath, size_t pathsize) { static pid_t pid = -1; char procpath[PATH_MAX]; @@ -91,30 +91,36 @@ static int procgetfdname(int fd, char *filepath, size_t pathsize) { #endif /* !HAVE_STAT64 */ if (pid < 0) pid = Getpid(); - snprintf(procpath, sizeof(procpath), "/proc/"F_pid"/fd/%d", pid, fd); + snprintf(procpath, sizeof(procpath), "/proc/"F_pid"/" +#if HAVE_PROC_DIR_PATH + "path" +#else + "fd" +#endif + "/%d", pid, fd); if ((len = Readlink(procpath, filepath, pathsize-1)) < 0) { - Error4("readlink(\"%s\", %p, "F_Zu"): %s", + Warn4("readlink(\"%s\", %p, "F_Zu"): %s", procpath, filepath, pathsize, strerror(errno)); - return -1; + len = 0; } filepath[len] = '\0'; return 0; } -#endif /* HAVE_PROC_DIR_FD */ +#endif /* HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH */ int statname(const char *file, int fd, int filetype, FILE *outfile, char style) { char filepath[PATH_MAX]; filepath[0] = '\0'; -#if HAVE_PROC_DIR_FD +#if HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH if (fd >= 0) { procgetfdname(fd, filepath, sizeof(filepath)); if (filepath[0] == '/') { file = filepath; } } -#endif /* HAVE_PROC_DIR_FD */ +#endif /* HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH */ /* now see for type specific infos */ switch (filetype) { case (S_IFIFO>>12): /* 1, FIFO */