../sys-utils/lsns.c:360:8: warning: comparison of integers of different signs: '__u32' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (!(NLMSG_OK(nlh, reslen)
^~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:90:24: note: expanded from macro 'NLMSG_OK'
(nlh)->nlmsg_len <= (len))
~~~~~~~~~~~~~~~~ ^ ~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Let's make it possible to use debug.h without environment variables.
Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing
* use __UL_DEBUG_FL_NOADDR when SUID
* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
to provide access to the current mask from ul_debugobj(). It's better
than modify all ul_debugobj() calls and use the global mask as
argument.
* remove never used UL_DEBUG_DEFINE_FLAG
Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsns.c:683:2: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘ino_t’ [-Werror=format=]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* don't use booleans
* use is_ prefix for boolean-like functions
* make nsfs_xasputs() more readable
* enable 'nowrap' together with 'raw' and don't test for "nowrap || raw"
* add missing 'W' to getopt_long()
Signed-off-by: Karel Zak <kzak@redhat.com>
This option forces lsns command not use
multi-line presentation when printing a cell.
Currently, it affects only NSFS column.
Implementing this option is suggested by Karl Zak.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
nsfs provides kernel level interface for assigning
logical name to a namespace. Following message is quoted
from git log of linux kernel:
commit 0226f4923f6c9b40cfa1c1c1b19a6ac6b3924ead
Author: Al Viro <viro@zeniv.linux.org.uk>
Date: Tue Dec 6 12:21:54 2011 -0500
vfs: take /proc/*/mounts and friends to fs/proc_namespace.c
rationale: that stuff is far tighter bound to fs/namespace.c than to
the guts of procfs proper.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
/proc/self/mountinfo lists the logical names for namespaces:
...
652 81 0:3 net:[4026532579] /tmp/XYZ rw shared:192 - nsfs nsfs rw,seclabel
...
In the lines /tmp/XYZ is a logical name for 4026532579 of net
namespace.
This patch adds nsfs column. It seems that the logical name is
used only in "ip netns" now. So the column is disabled by default.
Use '--type=net' or '-o NSFS' options to enable it.
This feature and the way to implementation using multi lines in a column
is Suggested by Karel Zak.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Linux network subsystem assigns an unique integer to a network
namespace.
term0# ip netns add UTIL-LINUX-LSNS-TEST-NS
term0# ip netns list
UTIL-LINUX-LSNS-TEST-NS
term0# ip link add name lsns-vetha type veth peer name lsns-vethb
term0 # ip link set lsns-vethb netns UTIL-LINUX-LSNS-TEST-NS
term0# ip netns list
UTIL-LINUX-LSNS-TEST-NS (id: 0)
term0# ip link show dev lsns-vetha
230: lsns-vetha@if229: <BROADCAST,MULTICAST> mtu 1500 qdisc noop ...
link/ether 3e:27:68:ba:b3:95 brd ff:ff:ff:ff:ff:ff link-netnsid 0
In this example 0 is assigned to UTIL-LINUX-LSNS-TEST-NS net namespace.
The name, UTIL-LINUX-LSNS-TEST-NS, and it semantics is given and defined
by iproute2 in userland; and nothing to do with util-linux.
However, the id, 0, is managed in linux kernel. If lsns can show
the ids, it helps users understand the state of network namespaces.
This commit adds NETNSID column to the output.
Here is an example of session:
term0# ip netns exec UTIL-LINUX-LSNS-TEST-NS cat
(Open another terminal)
term1# ./lsns --type net
NS TYPE NPROCS PID USER NETNSID COMMAND
4026531993 net 383 1 root unassigned /usr/lib/systemd/...
4026532433 net 1 1219 rtkit unassigned /usr/libexec/rtkit-daemon
4026532562 net 1 18201 root 0 cat
0 is shown as NETNSID for the cat process.
For the initial name space, "unassigned" is printed.
For the namespaces other type than net, "n/a" is printed.
If an error occurred during getting the id, "n/a" is printed.
Changes in V2:
* Remove wrongly used & operators.
* Make netnsid field empty if value for the column is not available.
Suggested by Karel Zak.
* Remove redundant condtion for checking the avaiablebility of netlink
socket. Suggested by Karel Zak.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
For example, child process of spamd has
32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ...
fscanf("%d %*s %c %d*[^\n]") in read_process() can't parse above as we
expected, because %s only skips non-whitespace. I.e. it parses like
following,
32031 (spamd child) S 32026 32026 32026 0 -1 4210752 338 0 0 0 ...
+---+ +----+ +
%d %*s %c
and returns 2 (pid=32031, state=c).
This fixes it by skipping task->comm part manually.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
For example user namespace is optional it does not make sense to
ignore process completely if the ns/user file is missing.
Reported-by: Michał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Still a few printf warnings found on i386 Linux:
libfdisk/src/alignment.c: In function 'fdisk_align_lba':
libfdisk/src/alignment.c:115:3: warning: format '%ju' expects argument of type 'uintmax_t', but argument 6 has type 'long unsigned int' [-Wformat]
sys-utils/lsns.c: In function ‘add_namespace’:
sys-utils/lsns.c:346:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘ino_t’ [-Wformat]
sys-utils/lsns.c: In function ‘add_process_to_namespace’:
sys-utils/lsns.c:362:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘ino_t’ [-Wformat]
sys-utils/lsns.c: In function ‘add_scols_line’:
sys-utils/lsns.c:440:4: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘ino_t’ [-Wformat]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The process-selection logic is in add_process_to_namespace:
if (!ns->proc || ns->proc->pid > proc->pid)
ns->proc = proc;
so it's just selecting the lowest PID.
Signed-off-by: W. Trevor King <wking@tremily.us>