summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/defs.h10
-rw-r--r--src/util.c18
2 files changed, 20 insertions, 8 deletions
diff --git a/src/defs.h b/src/defs.h
index eb8675757..1b5f90e01 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -665,6 +665,7 @@ struct finfo {
FINFO_DEV_BLK,
FINFO_DEV_CHR,
} type;
+ bool deleted;
struct {
unsigned int major, minor;
} dev;
@@ -1224,7 +1225,14 @@ extern pid_t pidfd_get_pid(pid_t pid_of_fd, int fd);
* Print file descriptor fd owned by process with ID pid (from the PID NS
* of the tracer).
*/
-extern void printfd_pid(struct tcb *tcp, pid_t pid, int fd);
+extern void printfd_pid_with_finfo(struct tcb *tcp, pid_t pid, int fd,
+ const struct finfo *finfo);
+
+static inline void
+printfd_pid(struct tcb *tcp, pid_t pid, int fd)
+{
+ printfd_pid_with_finfo(tcp, pid, fd, NULL);
+}
static inline void
printfd(struct tcb *tcp, int fd)
diff --git a/src/util.c b/src/util.c
index 1d140fa91..06609ab24 100644
--- a/src/util.c
+++ b/src/util.c
@@ -654,6 +654,7 @@ get_finfo_for_dev(const char *path, struct finfo *finfo)
finfo->path = path;
finfo->type = FINFO_UNSET;
+ finfo->deleted = false;
if (path[0] != '/')
return finfo;
@@ -681,10 +682,11 @@ get_finfo_for_dev(const char *path, struct finfo *finfo)
}
static bool
-printdev(struct tcb *tcp, int fd, const char *path)
+printdev(struct tcb *tcp, int fd, const char *path, const struct finfo *finfo)
{
struct finfo finfo_buf;
- const struct finfo *finfo = get_finfo_for_dev(path, &finfo_buf);
+ if (!finfo)
+ finfo = get_finfo_for_dev(path, &finfo_buf);
switch (finfo->type) {
case FINFO_DEV_BLK:
@@ -779,25 +781,27 @@ print_quoted_string_in_angle_brackets(const char *str, const bool deleted)
}
void
-printfd_pid(struct tcb *tcp, pid_t pid, int fd)
+printfd_pid_with_finfo(struct tcb *tcp, pid_t pid, int fd, const struct finfo *finfo)
{
PRINT_VAL_D(fd);
- char path[PATH_MAX + 1];
+ char patha[PATH_MAX + 1];
bool deleted;
if (pid > 0 && !number_set_array_is_empty(decode_fd_set, 0)
- && getfdpath_pid(pid, fd, path, sizeof(path), &deleted) >= 0) {
+ && (finfo || (getfdpath_pid(pid, fd, patha, sizeof(patha), &deleted) >= 0))) {
+ const char *path = finfo? finfo->path: patha;
if (is_number_in_set(DECODE_FD_SOCKET, decode_fd_set) &&
printsocket(tcp, fd, path))
goto printed;
if (is_number_in_set(DECODE_FD_DEV, decode_fd_set) &&
- printdev(tcp, fd, path))
+ printdev(tcp, fd, path, finfo))
goto printed;
if (is_number_in_set(DECODE_FD_PIDFD, decode_fd_set) &&
printpidfd(pid, fd, path))
goto printed;
if (is_number_in_set(DECODE_FD_PATH, decode_fd_set))
- print_quoted_string_in_angle_brackets(path, deleted);
+ print_quoted_string_in_angle_brackets(path,
+ finfo? finfo->deleted: deleted);
printed: ;
}