1.\" Copyright (c) 2019 The FreeBSD Foundation, Inc. 2.\" 3.\" This documentation was written by 4.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship 5.\" from the FreeBSD Foundation. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" $FreeBSD$ 29.\" 30.Dd May 25, 2023 31.Dt POSIXSHMCONTROL 1 32.Os 33.Sh NAME 34.Nm posixshmcontrol 35.Nd Control POSIX shared memory segments 36.Sh SYNOPSIS 37.Nm 38.Ar create 39.Op Fl l Ar pagesize 40.Op Fl m Ar mode 41.Op Pa path \&... 42.Nm 43.Ar rm 44.Op Pa path \&... 45.Nm 46.Ar ls 47.Op Fl h 48.Op Fl n 49.Op Fl j Ar jail 50.Nm 51.Ar dump 52.Op Pa path \&... 53.Nm 54.Ar stat 55.Op Fl h 56.Op Fl n 57.Op Pa path \&... 58.Nm 59.Ar truncate 60.Op Fl s Ar length 61.Op Pa path \&... 62.Sh DESCRIPTION 63The 64.Nm 65command manipulates the named POSIX shared memory segments. 66It allows inspecting existing segments, dumping their metadata or contents, 67and unlinking them. 68.Pp 69Unlinking removes the name from the system and, when the last process 70unmaps the segment and closes file descriptor pointing to the segment, 71frees underlying memory. 72.Pp 73The number of hard links as displayed by the 74.Ic stat 75subcommand, is equal to the number of references to the underlying VM 76object. 77It is almost always equal to the number of mappings +1, except 78for transient references. 79.Pp 80The following subcommands are provided: 81.Bl -tag -width truncate 82.It Ic create 83Create segments with the specified paths, if they do not already exist. 84.Pp 85The optional 86.Ar pagesize 87argument specifies the size of the virtual pages used to map the 88object with 89.Xr mmap 2 . 90By default, the system page size is used, but on some platforms a 91larger page size can be specified. 92The size of an object backed by large pages must be a multiple of the 93specified page size. 94The 95.Va hw.pagesizes 96sysctl variable lists the available page sizes. 97.Pp 98The optional numerical 99.Ar mode 100argument specifies the initial access mode. 101.It Ic rm 102Unlink the paths specified. 103.It Ic ls 104List all linked named shared memory segments visible to the caller. 105For each segment, the user and group owner, size, and path are displayed. 106The 107.Fl j 108option limits the output to segments within the specified 109.Ar jail 110name or id. 111.It Ic dump 112Output raw bytes values from the segment to standard output. 113.It Ic stat 114Print metadata for the specified path, in the format similar to the 115.Xr stat 1 116utility. 117.It Ic truncate 118Change the length of the segments. 119Argument to the 120.Fl s 121option specifies new length. 122The human-friendly 'k', 'm', 'g' suffixes can be used, see 123.Xr expand_number 3 . 124If the option is not specified, assumed length is zero. 125.El 126.Pp 127For some commands, the following options may be provided: 128.Bl -tag -width XXX 129.It Fl h 130If specified, requests human-readable display of size, see 131.Xr humanize_number 3 . 132.It Fl n 133Prevent translation of owner and group into symbolic names 134using name-switch services, instead the raw numeric values are printed. 135.El 136.Sh EXIT STATUS 137.Ex -std 138.Sh EXAMPLES 139.Bl -bullet 140.It 141To show content of the shared memory segment with the path 142.Pa /1 , 143use the command 144.Dl "posixshmcontrol dump /1 | hexdump -C" 145.It 146To create a segment with the path 147.Pa /2 148and then enlarge it to 1M, use the sequence of commands 149.Dl "posixshmcontrol create /2" 150.Dl "posixshmcontrol truncate -s 1m /2" 151.El 152.Sh SEE ALSO 153.Xr hexdump 1 , 154.Xr stat 1 , 155.Xr ftruncate 2 , 156.Xr mmap 2 , 157.Xr read 2 , 158.Xr shm_open 2 , 159.Xr shm_unlink 2 , 160.Xr stat 2 , 161.Xr expand_number 3 , 162.Xr humanize_number 3 , 163.Xr shm_create_largepage 3 , 164.Xr sysctl 3 165.Sh HISTORY 166The 167.Nm 168command appeared in 169.Fx 12.1 . 170.Sh AUTHORS 171The 172.Nm 173command and this manual page were written by 174.An Konstantin Belousov Aq Mt kib@freebsd.org 175under sponsorship from The 176.Fx 177Foundation. 178