xref: /freebsd/lib/libsysdecode/sysdecode_mask.3 (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1.\"
2.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd March 3, 2022
26.Dt sysdecode_mask 3
27.Os
28.Sh NAME
29.Nm sysdecode_mask ,
30.Nm sysdecode_accessmode ,
31.Nm sysdecode_atflags ,
32.Nm sysdecode_capfcntlrights ,
33.Nm sysdecode_close_range_flags ,
34.Nm sysdecode_fcntl_fileflags ,
35.Nm sysdecode_fileflags ,
36.Nm sysdecode_filemode ,
37.Nm sysdecode_flock_operation ,
38.Nm sysdecode_mlockall_flags ,
39.Nm sysdecode_mmap_flags ,
40.Nm sysdecode_mmap_prot ,
41.Nm sysdecode_mount_flags ,
42.Nm sysdecode_msg_flags ,
43.Nm sysdecode_msync_flags ,
44.Nm sysdecode_open_flags ,
45.Nm sysdecode_pipe2_flags ,
46.Nm sysdecode_reboot_howto ,
47.Nm sysdecode_rfork_flags ,
48.Nm sysdecode_semget_flags ,
49.Nm sysdecode_sendfile_flags ,
50.Nm sysdecode_shmat_flags ,
51.Nm sysdecode_sctp_nxt_flags ,
52.Nm sysdecode_sctp_rcv_flags ,
53.Nm sysdecode_sctp_snd_flags ,
54.Nm sysdecode_socket_type ,
55.Nm sysdecode_thr_create_flags ,
56.Nm sysdecode_umtx_cvwait_flags ,
57.Nm sysdecode_umtx_rwlock_flags ,
58.Nm sysdecode_vmprot ,
59.Nm sysdecode_wait4_options ,
60.Nm sysdecode_wait6_options
61.Nd print name of various bitmask values
62.Sh LIBRARY
63.Lb libsysdecode
64.Sh SYNOPSIS
65.In sysdecode.h
66.Ft bool
67.Fn sysdecode_access_mode "FILE *fp" "int mode" "int *rem"
68.Ft bool
69.Fn sysdecode_atflags "FILE *fp" "int flags" "int *rem"
70.Ft bool
71.Fn sysdecode_cap_fcntlrights "FILE *fp" "uint32_t rights" "uint32_t *rem"
72.Ft bool
73.Fn sysdecode_close_range_flags "FILE *fp" "int flags" "int *rem"
74.Ft bool
75.Fn sysdecode_fcntl_fileflags "FILE *fp" "int flags" "int *rem"
76.Ft bool
77.Fn sysdecode_fileflags "FILE *fp" "fflags_t flags" "fflags_t *rem"
78.Ft bool
79.Fn sysdecode_filemode "FILE *fp" "int mode" "int *rem"
80.Ft bool
81.Fn sysdecode_flock_operation "FILE *fp" "int operation" "int *rem"
82.Ft bool
83.Fn sysdecode_mlockall_flags "FILE *fp" "int flags" "int *rem"
84.Ft bool
85.Fn sysdecode_mmap_flags "FILE *fp" "int flags" "int *rem"
86.Ft bool
87.Fn sysdecode_mmap_prot "FILE *fp" "int prot" "int *rem"
88.Ft bool
89.Fn sysdecode_mount_flags "FILE *fp" "int flags" "int *rem"
90.Ft bool
91.Fn sysdecode_msg_flags "FILE *fp" "int flags" "int *rem"
92.Ft bool
93.Fn sysdecode_msync_flags "FILE *fp" "int flags" "int *rem"
94.Ft bool
95.Fn sysdecode_open_flags "FILE *fp" "int flags" "int *rem"
96.Ft bool
97.Fn sysdecode_pipe2_flags "FILE *fp" "int flags" "int *rem"
98.Ft bool
99.Fn sysdecode_reboot_howto "FILE *fp" "int howto" "int *rem"
100.Ft bool
101.Fn sysdecode_rfork_flags "FILE *fp" "int flags" "int *rem"
102.Ft bool
103.Fn sysdecode_sctp_nxt_flags "FILE *fp" "int flags" "int *rem"
104.Ft bool
105.Fn sysdecode_sctp_rcv_flags "FILE *fp" "int flags" "int *rem"
106.Ft bool
107.Fn sysdecode_sctp_snd_flags "FILE *fp" "int flags" "int *rem"
108.Ft bool
109.Fn sysdecode_semget_flags "FILE *fp" "int flags" "int *rem"
110.Ft bool
111.Fn sysdecode_sendfile_flags "FILE *fp" "int flags" "int *rem"
112.Ft bool
113.Fn sysdecode_shmat_flags "FILE *fp" "int flags" "int *rem"
114.Ft bool
115.Fn sysdecode_socket_type "FILE *fp" "int type" "int *rem"
116.Ft bool
117.Fn sysdecode_thr_create_flags "FILE *fp" "int flags" "int *rem"
118.Ft bool
119.Fn sysdecode_umtx_cvwait_flags "FILE *fp" "u_long flags" "u_long *rem"
120.Ft bool
121.Fn sysdecode_umtx_rwlock_flags "FILE *fp" "u_long flags" "u_long *rem"
122.Ft bool
123.Fn sysdecode_vmprot "FILE *fp" "int type" "int *rem"
124.Ft bool
125.Fn sysdecode_wait4_options "FILE *fp" "int options" "int *rem"
126.Ft bool
127.Fn sysdecode_wait6_options "FILE *fp" "int options" "int *rem"
128.Sh DESCRIPTION
129The
130.Nm
131functions are used to generate a text description of an integer value
132built from a mask of bitfields.
133The text description lists the C macros for field values joined by pipe
134.Sq |
135characters matching the format used in C source code.
136Most of the values decoded by these functions are passed as arguments to
137system calls,
138though some of these values are used internally in the kernel.
139.Pp
140Each function writes the text description to
141.Fa fp .
142The second argument should contain the integer value to be decoded.
143The
144.Fa rem
145argument is set to the value of any bits that were not decoded
146.Pq bit fields that do not have a corresponding C macro .
147.Fa rem
148may be set to
149.Dv NULL
150if the caller does not need this value.
151Each function returns
152.Dv true
153if any bit fields in the value were decoded and
154.Dv false
155if no bit fields were decoded.
156.Pp
157Most of these functions decode an argument passed to a system call:
158.Bl -column "Fn sysdecode_flock_operation" "Xr cap_fcntls_limit 2"
159.It Sy Function Ta Sy System Call Ta Sy Argument
160.It Fn sysdecode_access_mode Ta Xr access 2 Ta Fa mode
161.It Fn sysdecode_atflags Ta Xr chflagsat 2 , Xr fstatat 2 Ta Fa atflag , Fa flag
162.It Fn sysdecode_cap_fcntlrights Ta Xr cap_fcntls_limit 2 Ta Fa fcntlrights
163.It Fn sysdecode_fileflags Ta Xr chflags 2 Ta Fa flags
164.It Fn sysdecode_filemode Ta Xr chmod 2 , Xr open 2 Ta mode
165.It Fn sysdecode_flock_operation Ta Xr flock 2 Ta Fa operation
166.It Fn sysdecode_mlockall_flags Ta Xr mlockall 2 Ta Fa flags
167.It Fn sysdecode_mmap_flags Ta Xr mmap 2 Ta Fa flags
168.It Fn sysdecode_mmap_prot Ta Xr mmap 2 Ta Fa prot
169.It Fn sysdecode_mount_flags Ta Xr mount 2 Ta Fa flags
170.It Fn sysdecode_msg_flags Ta Xr recv 2 , Xr send 2 Ta Fa flags
171.It Fn sysdecode_msync_flags Ta Xr msync 2 Ta Fa flags
172.It Fn sysdecode_open_flags Ta Xr open 2 Ta Fa flags
173.It Fn sysdecode_pipe2_flags Ta Xr pipe2 Ta Fa flags
174.It Fn sysdecode_reboot_howto Ta Xr reboot 2 Ta Fa howto
175.It Fn sysdecode_rfork_flags Ta Xr rfork 2 Ta Fa flags
176.It Fn sysdecode_semget_flags Ta Xr semget 2 Ta Fa flags
177.It Fn sysdecode_sendfile_flags Ta Xr sendfile 2 Ta Fa flags
178.It Fn sysdecode_shmat_flags Ta Xr shmat 2 Ta Fa flags
179.It Fn sysdecode_socket_type Ta Xr socket 2 Ta Fa type
180.It Fn sysdecode_thr_create_flags Ta Xr thr_create 2 Ta Fa flags
181.It Fn sysdecode_wait4_options Ta Xr wait4 2 Ta Fa options
182.It Fn sysdecode_wait6_options Ta Xr wait6 2 Ta Fa options
183.El
184.Pp
185Other functions decode the values described below:
186.Bl -tag -width ".Fn sysdecode_umtx_cvwait_flags"
187.It Fn sysdecode_fcntl_fileflags
188The file flags used with the
189.Dv F_GETFL
190and
191.Dv F_SETFL
192.Xr fcntl 2
193commands.
194.It Fn sysdecode_sctp_nxt_flags
195The
196.Fa nxt_flags
197member of a
198.Vt struct sctp_nxtinfo .
199.It Fn sysdecode_sctp_rcv_flags
200The
201.Fa rcv_flags
202member of a
203.Vt struct sctp_rcvinfo .
204.It Fn sysdecode_sctp_snd_flags
205The
206.Fa snd_flags
207member of a
208.Vt struct sctp_sndinfo .
209.It Fn sysdecode_umtx_cvwait_flags
210The
211.Fa val
212argument to
213.Xr _umtx_op 2
214for
215.Dv UMTX_OP_CV_WAIT
216operations.
217.It Fn sysdecode_umtx_rwlock_flags
218The
219.Fa val
220argument to
221.Xr _umtx_op 2
222for
223.Dv UMTX_OP_RW_RDLOCK
224operations.
225.It Fn sysdecode_vmprot
226The memory protection flags stored in
227.Vt vm_prot_t
228variables.
229.El
230.Sh RETURN VALUES
231The
232.Nm
233functions return
234.Dv true
235if any bit fields in the value were decoded and
236.Dv false
237if no bit fields were decoded.
238.Sh SEE ALSO
239.Xr sysdecode 3 ,
240.Xr sysdecode_enum 3
241