summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsfd-sock.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
commit8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch)
tree1fdda006866bca20d41cb206767ea5241e36852f /misc-utils/lsfd-sock.c
parentAdding debian version 2.39.3-11. (diff)
downloadutil-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz
util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc-utils/lsfd-sock.c')
-rw-r--r--misc-utils/lsfd-sock.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/misc-utils/lsfd-sock.c b/misc-utils/lsfd-sock.c
index 3264516..4c75e6e 100644
--- a/misc-utils/lsfd-sock.c
+++ b/misc-utils/lsfd-sock.c
@@ -22,17 +22,29 @@
#include <sys/types.h>
#include <sys/xattr.h>
-#include "xalloc.h"
-#include "nls.h"
-#include "libsmartcols.h"
-
#include "lsfd.h"
#include "lsfd-sock.h"
static void attach_sock_xinfo(struct file *file)
{
struct sock *sock = (struct sock *)file;
+
sock->xinfo = get_sock_xinfo(file->stat.st_ino);
+ if (sock->xinfo) {
+ struct ipc *ipc = get_ipc(file);
+ if (ipc)
+ add_endpoint(&sock->endpoint, ipc);
+ }
+}
+
+static const struct ipc_class *sock_get_ipc_class(struct file *file)
+{
+ struct sock *sock = (struct sock *)file;
+
+ if (sock->xinfo && sock->xinfo->class->get_ipc_class)
+ return sock->xinfo->class->get_ipc_class(sock->xinfo, sock);
+
+ return NULL;
}
static bool sock_fill_column(struct proc *proc __attribute__((__unused__)),
@@ -43,6 +55,15 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)),
{
char *str = NULL;
struct sock *sock = (struct sock *)file;
+
+ if (sock->xinfo && sock->xinfo->class
+ && sock->xinfo->class->fill_column) {
+ if (sock->xinfo->class->fill_column(proc, sock->xinfo, sock, ln,
+ column_id, column_index,
+ &str))
+ goto out;
+ }
+
switch(column_id) {
case COL_TYPE:
if (!sock->protoname)
@@ -99,17 +120,14 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)),
? "1"
: "0");
break;
+ case COL_SOCK_SHUTDOWN:
+ str = xstrdup("??");
+ break;
default:
- if (sock->xinfo && sock->xinfo->class
- && sock->xinfo->class->fill_column) {
- if (sock->xinfo->class->fill_column(proc, sock->xinfo, sock, ln,
- column_id, column_index,
- &str))
- break;
- }
return false;
}
+ out:
if (!str)
err(EXIT_FAILURE, _("failed to add output data"));
if (scols_line_refer_data(ln, column_index, str))
@@ -120,13 +138,13 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)),
static void init_sock_content(struct file *file)
{
int fd;
+ struct sock *sock = (struct sock *)file;
assert(file);
fd = file->association;
if (fd >= 0 || fd == -ASSOC_MEM || fd == -ASSOC_SHM) {
- struct sock *sock = (struct sock *)file;
char path[PATH_MAX] = {'\0'};
char buf[256];
ssize_t len;
@@ -147,6 +165,8 @@ static void init_sock_content(struct file *file)
sock->protoname = xstrdup(buf);
}
}
+
+ init_endpoint(&sock->endpoint);
}
static void free_sock_content(struct file *file)
@@ -177,4 +197,5 @@ const struct file_class sock_class = {
.free_content = free_sock_content,
.initialize_class = initialize_sock_class,
.finalize_class = finalize_sock_class,
+ .get_ipc_class = sock_get_ipc_class,
};