Util-Linux Archive mirror
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: kzak@redhat.com
Cc: paithankarprasanna@gmail.com, util-linux@vger.kernel.org
Subject: Re: [RFC] ipcs for POSIX IPC
Date: Wed, 24 Apr 2024 22:15:17 +0900 (JST)	[thread overview]
Message-ID: <20240424.221517.2073047999286647720.yamato@redhat.com> (raw)
In-Reply-To: <20240424095240.l2fzrswgtvaqpv2o@ws.net.home>

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@redhat.com>
>  http://karelzak.blogspot.com
> 
> 


      reply	other threads:[~2024-04-24 13:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 22:40 [RFC] ipcs for POSIX IPC Prasanna Paithankar
2024-04-24  9:52 ` Karel Zak
2024-04-24 13:15   ` Masatake YAMATO [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424.221517.2073047999286647720.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=kzak@redhat.com \
    --cc=paithankarprasanna@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).