From 916b44a59a6d9cc2128ac378106da63b1c544ef7 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 22 Mar 2023 01:22:18 +0900 Subject: [PATCH] lsfd: add "nsfs" to the nodev_table to fill SOURCE column for nsfs files Signed-off-by: Masatake YAMATO --- misc-utils/lsfd-sock-xinfo.c | 4 ++ .../lsfd/column-source-namespace-ASSOC | 7 +++ tests/ts/lsfd/column-source | 51 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/expected/lsfd/column-source-namespace-ASSOC create mode 100755 tests/ts/lsfd/column-source diff --git a/misc-utils/lsfd-sock-xinfo.c b/misc-utils/lsfd-sock-xinfo.c index 3a11b75f00..5869828324 100644 --- a/misc-utils/lsfd-sock-xinfo.c +++ b/misc-utils/lsfd-sock-xinfo.c @@ -212,8 +212,12 @@ void initialize_sock_xinfos(void) load_sock_xinfo_no_nsswitch(NULL); else { if (fstat(self_netns_fd, &self_netns_sb) == 0) { + unsigned long m; struct netns *nsobj = mark_sock_xinfo_loaded(self_netns_sb.st_ino); load_sock_xinfo_no_nsswitch(nsobj); + + m = minor(self_netns_sb.st_dev); + add_nodev(m, "nsfs"); } } diff --git a/tests/expected/lsfd/column-source-namespace-ASSOC b/tests/expected/lsfd/column-source-namespace-ASSOC new file mode 100644 index 0000000000..8b26e3251d --- /dev/null +++ b/tests/expected/lsfd/column-source-namespace-ASSOC @@ -0,0 +1,7 @@ + ipc nsfs + mnt nsfs + net nsfs + pid nsfs +pid4c nsfs + user nsfs + uts nsfs diff --git a/tests/ts/lsfd/column-source b/tests/ts/lsfd/column-source new file mode 100755 index 0000000000..a74f9defaf --- /dev/null +++ b/tests/ts/lsfd/column-source @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Copyright (C) 2023 Masatake YAMATO +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +TS_TOPDIR="${0%/*}/../.." +TS_DESC="SOURCE column" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +. "$TS_SELF/lsfd-functions.bash" +ts_check_test_command "$TS_CMD_LSFD" + +ts_cd "$TS_OUTDIR" + +declare -a NAMESPACES=( + cgorup + ipc + mnt + net + pid + pid4c + # older kernel doesn't support time namespace. + # time + # time4c + user + uts +) +ts_init_subtest namespace-ASSOC +{ + EXPR="false" + for ns in "${NAMESPACES[@]}"; do + EXPR=${EXPR}' || (ASSOC == "'"$ns"'")' + done + ${TS_CMD_LSFD} -p $$ -n -o ASSOC,SOURCE -Q "$EXPR" +} > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest + +ts_finalize -- 2.47.3