(sizeof(long long) * 3 * 2 + sizeof("{tv_sec=-, tv_nsec=}"))
extern void printfd(struct tcb *, int);
extern void print_sockaddr(struct tcb *tcp, const void *, int);
-extern bool print_sockaddr_by_inode(const unsigned long, const enum sock_proto);
-extern bool print_sockaddr_by_inode_cached(const unsigned long);
+extern bool print_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
extern void print_dirfd(struct tcb *, int);
extern int
return 1;
}
-bool
+static bool
print_sockaddr_by_inode_cached(const unsigned long inode)
{
const cache_entry *const e = &cache[inode & CACHE_MASK];
return SOCK_PROTO_UNKNOWN;
}
-/* Given an inode number of a socket, print out the details
- * of the ip address and port. */
-
-bool
-print_sockaddr_by_inode(const unsigned long inode, const enum sock_proto proto)
+static bool
+print_sockaddr_by_inode_uncached(const unsigned long inode,
+ const enum sock_proto proto)
{
if ((unsigned int) proto >= ARRAY_SIZE(protocols) ||
(proto != SOCK_PROTO_UNKNOWN && !protocols[proto].print))
close(fd);
return r;
}
+
+/* Given an inode number of a socket, print out its protocol details. */
+bool
+print_sockaddr_by_inode(struct tcb *const tcp, const int fd,
+ const unsigned long inode)
+{
+ return print_sockaddr_by_inode_cached(inode) ? true :
+ print_sockaddr_by_inode_uncached(inode, getfdproto(tcp, fd));
+}
unsigned long inode;
tprintf("%d<", fd);
- if (show_fd_path > 1
- && (str = STR_STRIP_PREFIX(path, "socket:[")) != path
- && (len = strlen(str)) && str[len - 1] == ']'
- && (inode = strtoul(str, NULL, 10))) {
- if (!print_sockaddr_by_inode_cached(inode)) {
- const enum sock_proto proto =
- getfdproto(tcp, fd);
- if (!print_sockaddr_by_inode(inode, proto))
- tprints(path);
- }
- } else {
+ if (show_fd_path <= 1
+ || (str = STR_STRIP_PREFIX(path, "socket:[")) == path
+ || !(len = strlen(str))
+ || str[len - 1] != ']'
+ || !(inode = strtoul(str, NULL, 10))
+ || !print_sockaddr_by_inode(tcp, fd, inode)) {
print_quoted_string(path, strlen(path),
QUOTE_OMIT_LEADING_TRAILING_QUOTES);
}