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 February 26, 2022
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 m Ar mode
40.Op Pa path \&...
41.Nm
42.Ar rm
43.Op Pa path \&...
44.Nm
45.Ar ls
46.Op Fl h
47.Op Fl n
48.Op Fl j Ar jail
49.Nm
50.Ar dump
51.Op Pa path \&...
52.Nm
53.Ar stat
54.Op Fl h
55.Op Fl n
56.Op Pa path \&...
57.Nm
58.Ar truncate
59.Op Fl s Ar length
60.Op Pa path \&...
61.Sh DESCRIPTION
62The
63.Nm
64command manipulates the named POSIX shared memory segments.
65It allows inspecting existing segments, dumping their metadata or contents,
66and unlinking them.
67.Pp
68Unlinking removes the name from the system and, when the last process
69unmaps the segment and closes file descriptor pointing to the segment,
70frees underlying memory.
71.Pp
72The number of hard links as displayed by the
73.Ic stat
74subcommand, is equal to the number of references to the underlying VM
75object.
76It is almost always equal to the number of mappings +1, except
77for transient references.
78.Pp
79The following subcommands are provided:
80.Bl -tag -width truncate
81.It Ic create
82Create segments with the specified paths, if not exist.
83The
84.Ar mode
85optional numerical argument specifies initial access mode.
86.It Ic rm
87Unlink the paths specified.
88.It Ic ls
89List all linked named shared memory segments visible to the caller.
90For each segment, the user and group owner, size, and path are displayed.
91The
92.Fl j
93option limits the output to segments within the specified
94.Ar jail
95name or id.
96.It Ic dump
97Output raw bytes values from the segment to standard output.
98.It Ic stat
99Print metadata for the specified path, in the format similar to the
100.Xr stat 1
101utility.
102.It Ic truncate
103Change the length of the segments.
104Argument to the
105.Fl s
106option specifies new length.
107The human-friendly 'k', 'm', 'g' suffixes can be used, see
108.Xr expand_number 3 .
109If the option is not specified, assumed length is zero.
110.El
111.Pp
112For some commands, the following options may be provided:
113.Bl -tag -width XXX
114.It Fl h
115If specified, requests human-readable display of size, see
116.Xr humanize_number 3 .
117.It Fl n
118Prevent translation of owner and group into symbolic names
119using name-switch services, instead the raw numeric values are printed.
120.El
121.Sh EXIT STATUS
122.Ex -std
123.Sh EXAMPLES
124.Bl -bullet
125.It
126To show content of the shared memory segment with the path
127.Pa /1 ,
128use the command
129.Dl "posixshmcontrol dump /1 | hexdump -C"
130.It
131To create a segment with the path
132.Pa /2
133and then enlarge it to 1M, use the sequence of commands
134.Dl "posixshmcontrol create /2"
135.Dl "posixshmcontrol truncate -s 1m /2"
136.El
137.Sh SEE ALSO
138.Xr hexdump 1 ,
139.Xr stat 1 ,
140.Xr ftruncate 2 ,
141.Xr read 2 ,
142.Xr shm_open 2 ,
143.Xr shm_unlink 2 ,
144.Xr stat 2 ,
145.Xr expand_number 3 ,
146.Xr humanize_number 3 ,
147.Xr sysctl 3
148.Sh HISTORY
149The
150.Nm
151command appeared in
152.Fx 12.1 .
153.Sh AUTHORS
154The
155.Nm
156command and this manual page were written by
157.An Konstantin Belousov Aq Mt kib@freebsd.org
158under sponsorship from The
159.Fx
160Foundation.
161