From: Masatake YAMATO Date: Mon, 10 May 2021 03:56:56 +0000 (+0900) Subject: lsfd: fill PROTONAME field of file for mmap'ed socket X-Git-Tag: v2.38-rc1~144^2~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e9880a85b5996c487895af24b16b3a1210bbe69;p=thirdparty%2Futil-linux.git lsfd: fill PROTONAME field of file for mmap'ed socket Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-sock.c b/misc-utils/lsfd-sock.c index bfbccaf4f3..da1aa59dfa 100644 --- a/misc-utils/lsfd-sock.c +++ b/misc-utils/lsfd-sock.c @@ -84,7 +84,7 @@ struct file *make_sock(const struct file_class *class, { struct file *file = make_file(class? class: &sock_class, sb, name, map_file_data, fd); - if (fd >= 0) { + if (fd >= 0 || fd == -ASSOC_MEM || fd == -ASSOC_SHM) { struct sock *sock = (struct sock *)file; char path[PATH_MAX]; @@ -92,7 +92,11 @@ struct file *make_sock(const struct file_class *class, ssize_t len; memset(path, 0, sizeof(path)); - sprintf(path, "/proc/%d/fd/%d", proc->pid, fd); + if (fd >= 0) + sprintf(path, "/proc/%d/fd/%d", proc->pid, fd); + else + sprintf(path, "/proc/%d/map_files/%lx-%lx", proc->pid, + map_file_data->start, map_file_data->end); len = getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1); if (len > 0) { buf[len] = '\0';