On Wed, 24 Apr 2024 11:52:40 +0200, Karel Zak wrote: > On Wed, Apr 24, 2024 at 04:10:48AM +0530, Prasanna Paithankar wrote: >> The 'ipcs' (and 'ipcrm') command provides information on (or removes >> some) System V IPC resources. I'd like to know why no similar utility >> for POSIX IPC has existed for a long time. I would like to know if >> such a tool exists in case I missed it. If not, I will provide patches >> to ipcs and ipcrm (or should I separate the functionality into a new >> utility). > > I would suggest improving 'lsipc' instead of using the old 'ipcs'. > > The question is where to find information about POSIX IPC. For System > V, there is /proc/sysvipc, but there is no equivalent for POSIX (or I > am not aware of it). It seems that the only way to gather this > information is by scanning all processes' memory maps for /dev/shm. > This could be achieved by using lsfd. I read the related man pages: shm_overview(7) says shm_open(3) may make a file at /dev/shm. With the following test prgram, I saw it created /dev/shm/X. #include <sys/mman.h> #include <sys/stat.h> /* For mode constants */ #include <fcntl.h> /* For O_* constants */ int main(void) { int fd = shm_open("X", O_CREAT | O_EXCL | O_RDWR, 0600); while (1); return 0; } sem_overview(7) says: On Linux, named semaphores are created in a virtual filesystem, nor‐ mally mounted under /dev/shm, with names of the form sem.somename. As Karel wrote, lsfd can list them if a process do-mmap them. lsfd doesn't distinguish shm and sem. mq_overview(7) doesn't say the defatil about the visibility. I inspected the visibility of mq when addng mq support to lsfd. The list of mqueue is available if "mqueue" file systems is mounted. See mqueue_fs_type in ipc/mqueue.c of Linux. On Fedora, the filesystem is mounted to /dev/mqueue by default. However, some platforms may not mount it by default. Here is my idea for listing mqueue: for mnt_ns in $all_mnt_ns; do if mqueue_fs_is_found_in /proc/mounts; then ls the_mount_point else for p in $all_processes; do for fd in $all_fd_in_$p; do if is_mqueue_fd $fd echo the_information_about $fd fi done done | uniq fi done lsfd can list mqueues as far as they are opened by processes. We can use get_minor_for_mqueue and is_mqueue_dev in lsfd-cmd/file.c when implementing of is_mqueue_fd. Mounting temporarily the mqueue file system in lsipc is an alternative way. Masatake YAMATO > Karel > >> >> Yours sincerely >> Prasanna Paithankar >> > > -- > Karel Zak <kzak@xxxxxxxxxx> > http://karelzak.blogspot.com > >