[PATCH] Implement SysV shared memory for GNU/Hurd.
authorMarcus Brinkmann <marcus@gnu.org>
Wed, 18 Jun 2025 04:49:31 +0000 (06:49 +0200)
committerAurelien Jarno <aurel32@debian.org>
Wed, 18 Jun 2025 04:49:31 +0000 (06:49 +0200)
commit4d7750e0599f838b973c8dcbd7cd75793576897a
tree7f5484c7b6a7786af87b3de8938cb79aafdfc6f9
parentc91b9f70a1ee6b2cf7bad775a11e38a307fa6daf
[PATCH] Implement SysV shared memory for GNU/Hurd.

2005-07-11  Marcus Brinkmann  <marcus@gnu.org>

        * hurd/Makefile (routines): Add sysvshm.
        (distribute): Add sysvshm.h.
        * hurd/sysvshm.h: New file.
        * hurd/sysvshm.c: New file.
        * sysdeps/mach/hurd/bits/stat.h (S_IMMAP0): New macro.
        (S_ISPARE): Unset the S_IMMAP0 flag.
        * sysdeps/mach/hurd/ftok.c: New file.
        * sysdeps/mach/hurd/shmat.c: New file.
        * sysdeps/mach/hurd/shmctl.c: New file.
        * sysdeps/mach/hurd/shmdt.c: New file.
        * sysdeps/mach/hurd/bits/posix_opt.h: Define _XOPEN_SHM to 1.

TODO:

> +  char filename[sizeof (SHM_DIR) - 1 + SHM_NAMEMAX];
> +  struct stat statbuf;
> +
> +  sprintf (filename, SHM_DIR SHM_NAMEPRI, id);
> +  /* SysV requires read access for IPC_STAT.  */
> +  fd = __open (filename, O_NORW);
> +  if (fd < 0)
> +    {
> +      if (errno == ENOENT)
> +     errno = EINVAL;
> +      return -1;
> +    }

Since this is repeated in more than one function, put it into an
internal subroutine.  Then we have only one place doing the
name-generation logic.



> +    case IPC_RMID:
> +      res = __unlink (filename);
> +      /* FIXME: Check error (mapping ENOENT to EINVAL).  */

Fix it.


Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name tg-sysvshm.diff
hurd/Makefile
hurd/sysvshm.c [new file with mode: 0644]
hurd/sysvshm.h [new file with mode: 0644]
sysdeps/mach/hurd/bits/posix_opt.h
sysdeps/mach/hurd/ftok.c [new file with mode: 0644]
sysdeps/mach/hurd/shmat.c [new file with mode: 0644]
sysdeps/mach/hurd/shmctl.c [new file with mode: 0644]
sysdeps/mach/hurd/shmdt.c [new file with mode: 0644]
sysdeps/mach/hurd/shmget.c [new file with mode: 0644]