mirror of
https://repo.or.cz/socat.git
synced 2025-01-15 00:06:46 +00:00
Filan for Solaris: /proc/<pid>/path/
This commit is contained in:
parent
e52675faed
commit
c4281baabb
4 changed files with 27 additions and 7 deletions
3
CHANGES
3
CHANGES
|
@ -69,6 +69,9 @@ Porting:
|
||||||
|
|
||||||
Fixed ancillary messages on Solaris.
|
Fixed ancillary messages on Solaris.
|
||||||
|
|
||||||
|
Filan: Solaris has the open file path infos in /proc/<pid>/path/
|
||||||
|
Thanks to Andy Fiddaman to directing me to the patch.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
Filan prints target of symlink when appropriate
|
Filan prints target of symlink when appropriate
|
||||||
Test: FILANSYMLINK
|
Test: FILANSYMLINK
|
||||||
|
|
|
@ -652,6 +652,7 @@
|
||||||
|
|
||||||
/* Define if you have the /proc/$$/fd directories */
|
/* Define if you have the /proc/$$/fd directories */
|
||||||
#undef HAVE_PROC_DIR_FD
|
#undef HAVE_PROC_DIR_FD
|
||||||
|
#undef HAVE_PROC_DIR_PATH
|
||||||
|
|
||||||
#undef HAVE_SETGRENT
|
#undef HAVE_SETGRENT
|
||||||
#undef HAVE_GETGRENT
|
#undef HAVE_GETGRENT
|
||||||
|
|
10
configure.ac
10
configure.ac
|
@ -1985,6 +1985,16 @@ else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
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"
|
dnl "tcpd" "tcpwrappers"
|
||||||
# on some platforms, raw linking with libwrap fails because allow_severity and
|
# 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
|
# deny_severity are not explicitely defined. Thus we put the libwrap part to
|
||||||
|
|
20
fdname.c
20
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 int procgetfdname(int fd, char *filepath, size_t pathsize) {
|
||||||
static pid_t pid = -1;
|
static pid_t pid = -1;
|
||||||
char procpath[PATH_MAX];
|
char procpath[PATH_MAX];
|
||||||
|
@ -91,30 +91,36 @@ static int procgetfdname(int fd, char *filepath, size_t pathsize) {
|
||||||
#endif /* !HAVE_STAT64 */
|
#endif /* !HAVE_STAT64 */
|
||||||
|
|
||||||
if (pid < 0) pid = Getpid();
|
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) {
|
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));
|
procpath, filepath, pathsize, strerror(errno));
|
||||||
return -1;
|
len = 0;
|
||||||
}
|
}
|
||||||
filepath[len] = '\0';
|
filepath[len] = '\0';
|
||||||
return 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,
|
int statname(const char *file, int fd, int filetype, FILE *outfile,
|
||||||
char style) {
|
char style) {
|
||||||
char filepath[PATH_MAX];
|
char filepath[PATH_MAX];
|
||||||
|
|
||||||
filepath[0] = '\0';
|
filepath[0] = '\0';
|
||||||
#if HAVE_PROC_DIR_FD
|
#if HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
procgetfdname(fd, filepath, sizeof(filepath));
|
procgetfdname(fd, filepath, sizeof(filepath));
|
||||||
if (filepath[0] == '/') {
|
if (filepath[0] == '/') {
|
||||||
file = filepath;
|
file = filepath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_PROC_DIR_FD */
|
#endif /* HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH */
|
||||||
/* now see for type specific infos */
|
/* now see for type specific infos */
|
||||||
switch (filetype) {
|
switch (filetype) {
|
||||||
case (S_IFIFO>>12): /* 1, FIFO */
|
case (S_IFIFO>>12): /* 1, FIFO */
|
||||||
|
|
Loading…
Reference in a new issue