Add mkfifo{,at}(2) mode in mknod{,at}(2) as requested by POSIX mknod with mode & S_IFIFO and dev=0 shall behave like mkfifo. Update the documentation to reflect this state. Add ATF tests. This is an in-kernel implementation as typically user-space programs use mkfifo(2) directly, however whenever there is need to bypass libc (like in valgrind) then portable POSIX software calls the mknod syscall. Noted on tech-kern@ by Greg Troxel.diff -r1.29 -r1.30 src/lib/libc/sys/mknod.2
(kamil)
--- src/lib/libc/sys/mknod.2 2017/11/20 17:03:31 1.29
+++ src/lib/libc/sys/mknod.2 2019/06/20 03:31:54 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: mknod.2,v 1.29 2017/11/20 17:03:31 uwe Exp $ | 1 | .\" $NetBSD: mknod.2,v 1.30 2019/06/20 03:31:54 kamil Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 1980, 1991, 1993 | 3 | .\" Copyright (c) 1980, 1991, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. Neither the name of the University nor the names of its contributors | 14 | .\" 3. Neither the name of the University nor the names of its contributors | |
@@ -19,45 +19,66 @@ | @@ -19,45 +19,66 @@ | |||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. | |
29 | .\" | 29 | .\" | |
30 | .\" @(#)mknod.2 8.1 (Berkeley) 6/4/93 | 30 | .\" @(#)mknod.2 8.1 (Berkeley) 6/4/93 | |
31 | .\" | 31 | .\" | |
32 | .Dd July 29, 2013 | 32 | .Dd June 20, 2019 | |
33 | .Dt MKNOD 2 | 33 | .Dt MKNOD 2 | |
34 | .Os | 34 | .Os | |
35 | .Sh NAME | 35 | .Sh NAME | |
36 | .Nm mknod , | 36 | .Nm mknod , | |
37 | .Nm mknodat | 37 | .Nm mknodat | |
38 | .Nd make a special file node | 38 | .Nd make a special file node | |
39 | .Sh LIBRARY | 39 | .Sh LIBRARY | |
40 | .Lb libc | 40 | .Lb libc | |
41 | .Sh SYNOPSIS | 41 | .Sh SYNOPSIS | |
42 | .In sys/stat.h | 42 | .In sys/stat.h | |
43 | .Ft int | 43 | .Ft int | |
44 | .Fn mknod "const char *path" "mode_t mode" "dev_t dev" | 44 | .Fn mknod "const char *path" "mode_t mode" "dev_t dev" | |
45 | .In sys/stat.h | 45 | .In sys/stat.h | |
46 | .In fcntl.h | 46 | .In fcntl.h | |
47 | .Ft int | 47 | .Ft int | |
48 | .Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev" | 48 | .Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev" | |
49 | .Sh DESCRIPTION | 49 | .Sh DESCRIPTION | |
50 | The device special file | 50 | .Nm | |
51 | with | |||
52 | .Dv S_IFIFO | |||
53 | specified in | |||
54 | .Fa mode | |||
55 | and 0 in | |||
56 | .Fa dev | |||
57 | makes a fifo file. | |||
58 | This call is respectively a portable alias for | |||
59 | .Xr mkfifo 2 | |||
60 | and | |||
61 | .Xr mkfifoat 2 . | |||
62 | .Pp | |||
63 | .Nm | |||
64 | with | |||
65 | .Dv S_IFCHR | |||
66 | or | |||
67 | .Dv S_IFBLK | |||
68 | in | |||
69 | .Fa mode | |||
70 | makes a device special file. | |||
71 | The file | |||
51 | .Fa path | 72 | .Fa path | |
52 | is created with the major and minor | 73 | is created with the major and minor | |
53 | device numbers specified by | 74 | device numbers specified by | |
54 | .Fa dev . | 75 | .Fa dev . | |
55 | The access permissions of | 76 | The access permissions of | |
56 | .Fa path | 77 | .Fa path | |
57 | are extracted from | 78 | are extracted from | |
58 | .Fa mode , | 79 | .Fa mode , | |
59 | modified by the | 80 | modified by the | |
60 | .Xr umask 2 | 81 | .Xr umask 2 | |
61 | of the parent process. | 82 | of the parent process. | |
62 | .Pp | 83 | .Pp | |
63 | .Fn mknodat | 84 | .Fn mknodat | |
@@ -77,27 +98,27 @@ Search permission is required on this di | @@ -77,27 +98,27 @@ Search permission is required on this di | |||
77 | .\" was opened with the | 98 | .\" was opened with the | |
78 | .\" .Dv O_SEARCH | 99 | .\" .Dv O_SEARCH | |
79 | .\" flag. | 100 | .\" flag. | |
80 | .\" - or - | 101 | .\" - or - | |
81 | .\" This file descriptor must have been opened with the | 102 | .\" This file descriptor must have been opened with the | |
82 | .\" .Dv O_SEARCH | 103 | .\" .Dv O_SEARCH | |
83 | .\" flag. | 104 | .\" flag. | |
84 | .Fa fd | 105 | .Fa fd | |
85 | can be set to | 106 | can be set to | |
86 | .Dv AT_FDCWD | 107 | .Dv AT_FDCWD | |
87 | in order to specify the current directory. | 108 | in order to specify the current directory. | |
88 | .Pp | 109 | .Pp | |
89 | .Fn mknod | 110 | .Fn mknod | |
90 | requires super-user privileges. | 111 | requires super-user privileges for creating device special files. | |
91 | .Sh RETURN VALUES | 112 | .Sh RETURN VALUES | |
92 | .Rv -std mknod mknodat | 113 | .Rv -std mknod mknodat | |
93 | .Sh ERRORS | 114 | .Sh ERRORS | |
94 | .Fn mknod | 115 | .Fn mknod | |
95 | and | 116 | and | |
96 | .Fn mknodat | 117 | .Fn mknodat | |
97 | will fail and the file will be not created if: | 118 | will fail and the file will be not created if: | |
98 | .Bl -tag -width Er | 119 | .Bl -tag -width Er | |
99 | .It Bq Er EACCES | 120 | .It Bq Er EACCES | |
100 | Search permission is denied for a component of the path prefix. | 121 | Search permission is denied for a component of the path prefix. | |
101 | .It Bq Er EDQUOT | 122 | .It Bq Er EDQUOT | |
102 | The directory in which the entry for the new node | 123 | The directory in which the entry for the new node | |
103 | is being placed cannot be extended because the | 124 | is being placed cannot be extended because the | |
@@ -128,26 +149,28 @@ characters, or an entire path name excee | @@ -128,26 +149,28 @@ characters, or an entire path name excee | |||
128 | characters. | 149 | characters. | |
129 | .It Bq Er ENOENT | 150 | .It Bq Er ENOENT | |
130 | A component of the path prefix does not exist. | 151 | A component of the path prefix does not exist. | |
131 | .It Bq Er ENOSPC | 152 | .It Bq Er ENOSPC | |
132 | The directory in which the entry for the new node is being placed | 153 | The directory in which the entry for the new node is being placed | |
133 | cannot be extended because there is no space left on the file | 154 | cannot be extended because there is no space left on the file | |
134 | system containing the directory; or | 155 | system containing the directory; or | |
135 | there are no free inodes on the file system on which the | 156 | there are no free inodes on the file system on which the | |
136 | node is being created. | 157 | node is being created. | |
137 | .It Bq Er ENOTDIR | 158 | .It Bq Er ENOTDIR | |
138 | A component of the path prefix is not a directory. | 159 | A component of the path prefix is not a directory. | |
139 | .It Bq Er EPERM | 160 | .It Bq Er EPERM | |
140 | The process's effective user ID is not super-user. | 161 | The process's effective user ID is not super-user. | |
162 | .It Bq Er EOPNOTSUPP | |||
163 | The kernel has not been configured to support fifo's. | |||
141 | .It Bq Er EROFS | 164 | .It Bq Er EROFS | |
142 | The named file resides on a read-only file system. | 165 | The named file resides on a read-only file system. | |
143 | .El | 166 | .El | |
144 | .Pp | 167 | .Pp | |
145 | In addition, | 168 | In addition, | |
146 | .Fn mknodat | 169 | .Fn mknodat | |
147 | will fail if: | 170 | will fail if: | |
148 | .Bl -tag -width Er | 171 | .Bl -tag -width Er | |
149 | .It Bq Er EBADF | 172 | .It Bq Er EBADF | |
150 | .Fa path | 173 | .Fa path | |
151 | does not specify an absolute path and | 174 | does not specify an absolute path and | |
152 | .Fa fd | 175 | .Fa fd | |
153 | is neither | 176 | is neither | |
@@ -168,13 +191,20 @@ is a file descriptor associated with a n | @@ -168,13 +191,20 @@ is a file descriptor associated with a n | |||
168 | .Sh STANDARDS | 191 | .Sh STANDARDS | |
169 | The | 192 | The | |
170 | .Fn mknod | 193 | .Fn mknod | |
171 | function conforms to | 194 | function conforms to | |
172 | .St -p1003.1-90 . | 195 | .St -p1003.1-90 . | |
173 | .Fn mknodat | 196 | .Fn mknodat | |
174 | conforms to | 197 | conforms to | |
175 | .St -p1003.1-2008 . | 198 | .St -p1003.1-2008 . | |
176 | .Sh HISTORY | 199 | .Sh HISTORY | |
177 | A | 200 | A | |
178 | .Fn mknod | 201 | .Fn mknod | |
179 | function call appeared in | 202 | function call appeared in | |
180 | .At v6 . | 203 | .At v6 . | |
204 | .Pp | |||
205 | The alias mode for | |||
206 | .Xr mkfifo 2 | |||
207 | and | |||
208 | .Xr mkfifoat 2 | |||
209 | first appeared in | |||
210 | .Nx 9 . |
--- src/sys/compat/netbsd32/netbsd32_netbsd.c 2019/06/18 22:34:25 1.227
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c 2019/06/20 03:31:54 1.228
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: netbsd32_netbsd.c,v 1.227 2019/06/18 22:34:25 kamil Exp $ */ | 1 | /* $NetBSD: netbsd32_netbsd.c,v 1.228 2019/06/20 03:31:54 kamil Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green | 4 | * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * 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 | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.227 2019/06/18 22:34:25 kamil Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.228 2019/06/20 03:31:54 kamil Exp $"); | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * below are all the standard NetBSD system calls, in the 32bit | 33 | * below are all the standard NetBSD system calls, in the 32bit | |
34 | * environment, with the necessary conversions to 64bit before calling | 34 | * environment, with the necessary conversions to 64bit before calling | |
35 | * the real syscall. anything that needs special attention is handled | 35 | * the real syscall. anything that needs special attention is handled | |
36 | * elsewhere - this file should only contain structure assignment and | 36 | * elsewhere - this file should only contain structure assignment and | |
37 | * calls to the original function. | 37 | * calls to the original function. | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | /* | 40 | /* | |
41 | * below are all the standard NetBSD system calls, in the 32bit | 41 | * below are all the standard NetBSD system calls, in the 32bit | |
42 | * environment, with the necessary conversions to 64bit before calling | 42 | * environment, with the necessary conversions to 64bit before calling | |
43 | * the real syscall. anything that needs special attention is handled | 43 | * the real syscall. anything that needs special attention is handled | |
@@ -287,28 +287,28 @@ netbsd32_fchdir(struct lwp *l, const str | @@ -287,28 +287,28 @@ netbsd32_fchdir(struct lwp *l, const str | |||
287 | 287 | |||
288 | return sys_fchdir(l, &ua, retval); | 288 | return sys_fchdir(l, &ua, retval); | |
289 | } | 289 | } | |
290 | 290 | |||
291 | int | 291 | int | |
292 | netbsd32___mknod50(struct lwp *l, const struct netbsd32___mknod50_args *uap, register_t *retval) | 292 | netbsd32___mknod50(struct lwp *l, const struct netbsd32___mknod50_args *uap, register_t *retval) | |
293 | { | 293 | { | |
294 | /* { | 294 | /* { | |
295 | syscallarg(const netbsd32_charp) path; | 295 | syscallarg(const netbsd32_charp) path; | |
296 | syscallarg(mode_t) mode; | 296 | syscallarg(mode_t) mode; | |
297 | syscallarg(netbsd32_dev_t) dev; | 297 | syscallarg(netbsd32_dev_t) dev; | |
298 | } */ | 298 | } */ | |
299 | 299 | |||
300 | return do_sys_mknod(l, SCARG_P32(uap, path), SCARG(uap, mode), | 300 | return do_posix_mknodat(l, AT_FDCWD, SCARG_P32(uap, path), | |
301 | SCARG(uap, dev), UIO_USERSPACE); | 301 | SCARG(uap, mode), SCARG(uap, dev)); | |
302 | } | 302 | } | |
303 | 303 | |||
304 | int | 304 | int | |
305 | netbsd32_chmod(struct lwp *l, const struct netbsd32_chmod_args *uap, register_t *retval) | 305 | netbsd32_chmod(struct lwp *l, const struct netbsd32_chmod_args *uap, register_t *retval) | |
306 | { | 306 | { | |
307 | /* { | 307 | /* { | |
308 | syscallarg(const netbsd32_charp) path; | 308 | syscallarg(const netbsd32_charp) path; | |
309 | syscallarg(mode_t) mode; | 309 | syscallarg(mode_t) mode; | |
310 | } */ | 310 | } */ | |
311 | struct sys_chmod_args ua; | 311 | struct sys_chmod_args ua; | |
312 | 312 | |||
313 | NETBSD32TOP_UAP(path, const char); | 313 | NETBSD32TOP_UAP(path, const char); | |
314 | NETBSD32TO64_UAP(mode); | 314 | NETBSD32TO64_UAP(mode); |
--- src/sys/kern/vfs_syscalls.c 2019/06/19 14:16:06 1.530
+++ src/sys/kern/vfs_syscalls.c 2019/06/20 03:31:54 1.531
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_syscalls.c,v 1.530 2019/06/19 14:16:06 kamil Exp $ */ | 1 | /* $NetBSD: vfs_syscalls.c,v 1.531 2019/06/20 03:31:54 kamil Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -60,27 +60,27 @@ | @@ -60,27 +60,27 @@ | |||
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
63 | * SUCH DAMAGE. | 63 | * SUCH DAMAGE. | |
64 | * | 64 | * | |
65 | * @(#)vfs_syscalls.c 8.42 (Berkeley) 7/31/95 | 65 | * @(#)vfs_syscalls.c 8.42 (Berkeley) 7/31/95 | |
66 | */ | 66 | */ | |
67 | 67 | |||
68 | /* | 68 | /* | |
69 | * Virtual File System System Calls | 69 | * Virtual File System System Calls | |
70 | */ | 70 | */ | |
71 | 71 | |||
72 | #include <sys/cdefs.h> | 72 | #include <sys/cdefs.h> | |
73 | __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.530 2019/06/19 14:16:06 kamil Exp $"); | 73 | __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.531 2019/06/20 03:31:54 kamil Exp $"); | |
74 | 74 | |||
75 | #ifdef _KERNEL_OPT | 75 | #ifdef _KERNEL_OPT | |
76 | #include "opt_fileassoc.h" | 76 | #include "opt_fileassoc.h" | |
77 | #include "veriexec.h" | 77 | #include "veriexec.h" | |
78 | #endif | 78 | #endif | |
79 | 79 | |||
80 | #include <sys/param.h> | 80 | #include <sys/param.h> | |
81 | #include <sys/systm.h> | 81 | #include <sys/systm.h> | |
82 | #include <sys/namei.h> | 82 | #include <sys/namei.h> | |
83 | #include <sys/filedesc.h> | 83 | #include <sys/filedesc.h> | |
84 | #include <sys/kernel.h> | 84 | #include <sys/kernel.h> | |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> | |
86 | #include <sys/fcntl.h> | 86 | #include <sys/fcntl.h> | |
@@ -2141,57 +2141,71 @@ sys___fhstatvfs140(struct lwp *l, const | @@ -2141,57 +2141,71 @@ sys___fhstatvfs140(struct lwp *l, const | |||
2141 | syscallarg(int) flags; | 2141 | syscallarg(int) flags; | |
2142 | } */ | 2142 | } */ | |
2143 | struct statvfs *sb = STATVFSBUF_GET(); | 2143 | struct statvfs *sb = STATVFSBUF_GET(); | |
2144 | int error; | 2144 | int error; | |
2145 | 2145 | |||
2146 | error = do_fhstatvfs(l, SCARG(uap, fhp), SCARG(uap, fh_size), sb, | 2146 | error = do_fhstatvfs(l, SCARG(uap, fhp), SCARG(uap, fh_size), sb, | |
2147 | SCARG(uap, flags)); | 2147 | SCARG(uap, flags)); | |
2148 | if (error == 0) | 2148 | if (error == 0) | |
2149 | error = copyout(sb, SCARG(uap, buf), sizeof(*sb)); | 2149 | error = copyout(sb, SCARG(uap, buf), sizeof(*sb)); | |
2150 | STATVFSBUF_PUT(sb); | 2150 | STATVFSBUF_PUT(sb); | |
2151 | return error; | 2151 | return error; | |
2152 | } | 2152 | } | |
2153 | 2153 | |||
2154 | int | |||
2155 | do_posix_mknodat(struct lwp *l, int fdat, const char *pathname, mode_t mode, | |||
2156 | dev_t dev) | |||
2157 | { | |||
2158 | ||||
2159 | if ((mode & S_IFIFO) && dev == 0) | |||
2160 | return do_sys_mkfifoat(l, fdat, pathname, mode); | |||
2161 | else if (mode & (S_IFCHR | S_IFBLK)) | |||
2162 | return do_sys_mknodat(l, fdat, pathname, mode, dev, | |||
2163 | UIO_USERSPACE); | |||
2164 | else | |||
2165 | return EINVAL; | |||
2166 | } | |||
2167 | ||||
2154 | /* | 2168 | /* | |
2155 | * Create a special file. | 2169 | * Create a special file. | |
2156 | */ | 2170 | */ | |
2157 | /* ARGSUSED */ | 2171 | /* ARGSUSED */ | |
2158 | int | 2172 | int | |
2159 | sys___mknod50(struct lwp *l, const struct sys___mknod50_args *uap, | 2173 | sys___mknod50(struct lwp *l, const struct sys___mknod50_args *uap, | |
2160 | register_t *retval) | 2174 | register_t *retval) | |
2161 | { | 2175 | { | |
2162 | /* { | 2176 | /* { | |
2163 | syscallarg(const char *) path; | 2177 | syscallarg(const char *) path; | |
2164 | syscallarg(mode_t) mode; | 2178 | syscallarg(mode_t) mode; | |
2165 | syscallarg(dev_t) dev; | 2179 | syscallarg(dev_t) dev; | |
2166 | } */ | 2180 | } */ | |
2167 | return do_sys_mknodat(l, AT_FDCWD, SCARG(uap, path), | 2181 | return do_posix_mknodat(l, AT_FDCWD, SCARG(uap, path), | |
2168 | SCARG(uap, mode), SCARG(uap, dev), UIO_USERSPACE); | 2182 | SCARG(uap, mode), SCARG(uap, dev)); | |
2169 | } | 2183 | } | |
2170 | 2184 | |||
2171 | int | 2185 | int | |
2172 | sys_mknodat(struct lwp *l, const struct sys_mknodat_args *uap, | 2186 | sys_mknodat(struct lwp *l, const struct sys_mknodat_args *uap, | |
2173 | register_t *retval) | 2187 | register_t *retval) | |
2174 | { | 2188 | { | |
2175 | /* { | 2189 | /* { | |
2176 | syscallarg(int) fd; | 2190 | syscallarg(int) fd; | |
2177 | syscallarg(const char *) path; | 2191 | syscallarg(const char *) path; | |
2178 | syscallarg(mode_t) mode; | 2192 | syscallarg(mode_t) mode; | |
2179 | syscallarg(int) pad; | 2193 | syscallarg(int) pad; | |
2180 | syscallarg(dev_t) dev; | 2194 | syscallarg(dev_t) dev; | |
2181 | } */ | 2195 | } */ | |
2182 | 2196 | |||
2183 | return do_sys_mknodat(l, SCARG(uap, fd), SCARG(uap, path), | 2197 | return do_posix_mknodat(l, SCARG(uap, fd), SCARG(uap, path), | |
2184 | SCARG(uap, mode), SCARG(uap, dev), UIO_USERSPACE); | 2198 | SCARG(uap, mode), SCARG(uap, dev)); | |
2185 | } | 2199 | } | |
2186 | 2200 | |||
2187 | int | 2201 | int | |
2188 | do_sys_mknod(struct lwp *l, const char *pathname, mode_t mode, dev_t dev, | 2202 | do_sys_mknod(struct lwp *l, const char *pathname, mode_t mode, dev_t dev, | |
2189 | enum uio_seg seg) | 2203 | enum uio_seg seg) | |
2190 | { | 2204 | { | |
2191 | return do_sys_mknodat(l, AT_FDCWD, pathname, mode, dev, seg); | 2205 | return do_sys_mknodat(l, AT_FDCWD, pathname, mode, dev, seg); | |
2192 | } | 2206 | } | |
2193 | 2207 | |||
2194 | int | 2208 | int | |
2195 | do_sys_mknodat(struct lwp *l, int fdat, const char *pathname, mode_t mode, | 2209 | do_sys_mknodat(struct lwp *l, int fdat, const char *pathname, mode_t mode, | |
2196 | dev_t dev, enum uio_seg seg) | 2210 | dev_t dev, enum uio_seg seg) | |
2197 | { | 2211 | { |
--- src/sys/sys/vfs_syscalls.h 2019/06/18 22:34:26 1.24
+++ src/sys/sys/vfs_syscalls.h 2019/06/20 03:31:54 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vfs_syscalls.h,v 1.24 2019/06/18 22:34:26 kamil Exp $ */ | 1 | /* $NetBSD: vfs_syscalls.h,v 1.25 2019/06/20 03:31:54 kamil Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -60,26 +60,27 @@ int do_sys_utimensat(struct lwp *, int, | @@ -60,26 +60,27 @@ int do_sys_utimensat(struct lwp *, int, | |||
60 | const struct timespec *, enum uio_seg); | 60 | const struct timespec *, enum uio_seg); | |
61 | 61 | |||
62 | struct pathbuf; | 62 | struct pathbuf; | |
63 | int do_open(struct lwp *, struct vnode *, struct pathbuf *, int, int, int *); | 63 | int do_open(struct lwp *, struct vnode *, struct pathbuf *, int, int, int *); | |
64 | 64 | |||
65 | int vfs_copyinfh_alloc(const void *, size_t, fhandle_t **); | 65 | int vfs_copyinfh_alloc(const void *, size_t, fhandle_t **); | |
66 | void vfs_copyinfh_free(fhandle_t *); | 66 | void vfs_copyinfh_free(fhandle_t *); | |
67 | 67 | |||
68 | int dofhopen(struct lwp *, const void *, size_t, int, register_t *); | 68 | int dofhopen(struct lwp *, const void *, size_t, int, register_t *); | |
69 | 69 | |||
70 | int do_sys_linkat(struct lwp *, int, const char *, int, const char *, int, register_t *); | 70 | int do_sys_linkat(struct lwp *, int, const char *, int, const char *, int, register_t *); | |
71 | int do_sys_unlink(const char *, enum uio_seg); | 71 | int do_sys_unlink(const char *, enum uio_seg); | |
72 | int do_sys_rename(const char *, const char *, enum uio_seg, int); | 72 | int do_sys_rename(const char *, const char *, enum uio_seg, int); | |
73 | int do_posix_mknodat(struct lwp *, int, const char *, mode_t, dev_t); | |||
73 | int do_sys_mknod(struct lwp *, const char *, mode_t, dev_t, enum uio_seg); | 74 | int do_sys_mknod(struct lwp *, const char *, mode_t, dev_t, enum uio_seg); | |
74 | int do_sys_mknodat(struct lwp *, int, const char *, mode_t, dev_t, enum uio_seg); | 75 | int do_sys_mknodat(struct lwp *, int, const char *, mode_t, dev_t, enum uio_seg); | |
75 | int do_sys_chmodat(struct lwp *, int, const char *, int, int); | 76 | int do_sys_chmodat(struct lwp *, int, const char *, int, int); | |
76 | int do_sys_chownat(struct lwp *, int, const char *, uid_t, gid_t, int); | 77 | int do_sys_chownat(struct lwp *, int, const char *, uid_t, gid_t, int); | |
77 | int do_sys_accessat(struct lwp *, int, const char *, int ,int); | 78 | int do_sys_accessat(struct lwp *, int, const char *, int ,int); | |
78 | int do_sys_mkdir(const char *, mode_t, enum uio_seg); | 79 | int do_sys_mkdir(const char *, mode_t, enum uio_seg); | |
79 | int do_sys_symlink(const char *, const char *, enum uio_seg); | 80 | int do_sys_symlink(const char *, const char *, enum uio_seg); | |
80 | int do_sys_quotactl(const char *, const struct quotactl_args *); | 81 | int do_sys_quotactl(const char *, const struct quotactl_args *); | |
81 | void do_sys_sync(struct lwp *); | 82 | void do_sys_sync(struct lwp *); | |
82 | 83 | |||
83 | int chdir_lookup(const char *, int, struct vnode **, struct lwp *); | 84 | int chdir_lookup(const char *, int, struct vnode **, struct lwp *); | |
84 | void change_root(struct cwdinfo *, struct vnode *, struct lwp *); | 85 | void change_root(struct cwdinfo *, struct vnode *, struct lwp *); | |
85 | 86 |
--- src/tests/lib/libc/c063/t_mkfifoat.c 2017/01/14 20:55:26 1.4
+++ src/tests/lib/libc/c063/t_mkfifoat.c 2019/06/20 03:31:53 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */ | 1 | /* $NetBSD: t_mkfifoat.c,v 1.5 2019/06/20 03:31:53 kamil Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Emmanuel Dreyfus. | 8 | * by Emmanuel Dreyfus. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __RCSID("$NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $"); | 32 | __RCSID("$NetBSD: t_mkfifoat.c,v 1.5 2019/06/20 03:31:53 kamil Exp $"); | |
33 | 33 | |||
34 | #include <atf-c.h> | 34 | #include <atf-c.h> | |
35 | #include <errno.h> | 35 | #include <errno.h> | |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> | |
37 | #include <limits.h> | 37 | #include <limits.h> | |
38 | #include <paths.h> | 38 | #include <paths.h> | |
39 | #include <stdio.h> | 39 | #include <stdio.h> | |
40 | #include <string.h> | 40 | #include <string.h> | |
41 | #include <unistd.h> | 41 | #include <unistd.h> | |
42 | #include <sys/param.h> | 42 | #include <sys/param.h> | |
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> | |
44 | 44 | |||
45 | #define DIR "dir" | 45 | #define DIR "dir" | |
@@ -98,23 +98,50 @@ ATF_TC_HEAD(mkfifoat_fderr, tc) | @@ -98,23 +98,50 @@ ATF_TC_HEAD(mkfifoat_fderr, tc) | |||
98 | atf_tc_set_md_var(tc, "descr", "See that mkfifoat fails with fd as -1"); | 98 | atf_tc_set_md_var(tc, "descr", "See that mkfifoat fails with fd as -1"); | |
99 | } | 99 | } | |
100 | ATF_TC_BODY(mkfifoat_fderr, tc) | 100 | ATF_TC_BODY(mkfifoat_fderr, tc) | |
101 | { | 101 | { | |
102 | int fd; | 102 | int fd; | |
103 | mode_t mode = 0600; | 103 | mode_t mode = 0600; | |
104 | 104 | |||
105 | ATF_REQUIRE(mkdir(DIR, 0755) == 0); | 105 | ATF_REQUIRE(mkdir(DIR, 0755) == 0); | |
106 | ATF_REQUIRE((fd = open(FIFO, O_CREAT|O_RDWR, 0644)) != -1); | 106 | ATF_REQUIRE((fd = open(FIFO, O_CREAT|O_RDWR, 0644)) != -1); | |
107 | ATF_REQUIRE(close(fd) == 0); | 107 | ATF_REQUIRE(close(fd) == 0); | |
108 | ATF_REQUIRE(mkfifoat(-1, FIFO, mode) == -1); | 108 | ATF_REQUIRE(mkfifoat(-1, FIFO, mode) == -1); | |
109 | } | 109 | } | |
110 | 110 | |||
111 | ATF_TC(mknodat_s_ififo); | |||
112 | ATF_TC_HEAD(mknodat_s_ififo, tc) | |||
113 | { | |||
114 | atf_tc_set_md_var(tc, "descr", "Test mknodat(2) with S_IFIFO"); | |||
115 | } | |||
116 | ||||
117 | ATF_TC_BODY(mknodat_s_ififo, tc) | |||
118 | { | |||
119 | struct stat st; | |||
120 | int dfd; | |||
121 | mode_t mode = S_IFIFO | 0600; | |||
122 | ||||
123 | (void)memset(&st, 0, sizeof(struct stat)); | |||
124 | ||||
125 | ATF_REQUIRE(mkdir(DIR, 0755) == 0); | |||
126 | ATF_REQUIRE((dfd = open(DIR, O_RDONLY, 0)) != -1); | |||
127 | ATF_REQUIRE(mknodat(dfd, BASEFIFO, mode, 0) != -1); | |||
128 | ATF_REQUIRE(access(FIFO, F_OK) == 0); | |||
129 | ATF_REQUIRE(stat(FIFO, &st) == 0); | |||
130 | ||||
131 | if (S_ISFIFO(st.st_mode) == 0) | |||
132 | atf_tc_fail("invalid mode from mknodat(2) with S_IFIFO"); | |||
133 | ||||
134 | (void)close(dfd); | |||
135 | } | |||
136 | ||||
111 | ATF_TP_ADD_TCS(tp) | 137 | ATF_TP_ADD_TCS(tp) | |
112 | { | 138 | { | |
113 | 139 | |||
114 | ATF_TP_ADD_TC(tp, mkfifoat_fd); | 140 | ATF_TP_ADD_TC(tp, mkfifoat_fd); | |
115 | ATF_TP_ADD_TC(tp, mkfifoat_fdcwd); | 141 | ATF_TP_ADD_TC(tp, mkfifoat_fdcwd); | |
116 | ATF_TP_ADD_TC(tp, mkfifoat_fdcwderr); | 142 | ATF_TP_ADD_TC(tp, mkfifoat_fdcwderr); | |
117 | ATF_TP_ADD_TC(tp, mkfifoat_fderr); | 143 | ATF_TP_ADD_TC(tp, mkfifoat_fderr); | |
144 | ATF_TP_ADD_TC(tp, mknodat_s_ififo); | |||
118 | 145 | |||
119 | return atf_no_error(); | 146 | return atf_no_error(); | |
120 | } | 147 | } |
--- src/tests/lib/libc/sys/t_mkfifo.c 2011/11/02 06:04:48 1.2
+++ src/tests/lib/libc/sys/t_mkfifo.c 2019/06/20 03:31:54 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: t_mkfifo.c,v 1.2 2011/11/02 06:04:48 jruoho Exp $ */ | 1 | /* $NetBSD: t_mkfifo.c,v 1.3 2019/06/20 03:31:54 kamil Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jukka Ruohonen. | 8 | * by Jukka Ruohonen. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __RCSID("$NetBSD: t_mkfifo.c,v 1.2 2011/11/02 06:04:48 jruoho Exp $"); | 32 | __RCSID("$NetBSD: t_mkfifo.c,v 1.3 2019/06/20 03:31:54 kamil Exp $"); | |
33 | 33 | |||
34 | #include <sys/stat.h> | 34 | #include <sys/stat.h> | |
35 | #include <sys/wait.h> | 35 | #include <sys/wait.h> | |
36 | 36 | |||
37 | #include <atf-c.h> | 37 | #include <atf-c.h> | |
38 | #include <errno.h> | 38 | #include <errno.h> | |
39 | #include <fcntl.h> | 39 | #include <fcntl.h> | |
40 | #include <limits.h> | 40 | #include <limits.h> | |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> | |
42 | #include <signal.h> | 42 | #include <signal.h> | |
43 | #include <string.h> | 43 | #include <string.h> | |
44 | #include <unistd.h> | 44 | #include <unistd.h> | |
45 | 45 | |||
@@ -253,24 +253,53 @@ ATF_TC_BODY(mkfifo_stat, tc) | @@ -253,24 +253,53 @@ ATF_TC_BODY(mkfifo_stat, tc) | |||
253 | ATF_REQUIRE(stat(path, &st) == 0); | 253 | ATF_REQUIRE(stat(path, &st) == 0); | |
254 | 254 | |||
255 | if (S_ISFIFO(st.st_mode) == 0) | 255 | if (S_ISFIFO(st.st_mode) == 0) | |
256 | atf_tc_fail("invalid mode from mkfifo(2)"); | 256 | atf_tc_fail("invalid mode from mkfifo(2)"); | |
257 | 257 | |||
258 | ATF_REQUIRE(unlink(path) == 0); | 258 | ATF_REQUIRE(unlink(path) == 0); | |
259 | } | 259 | } | |
260 | 260 | |||
261 | ATF_TC_CLEANUP(mkfifo_stat, tc) | 261 | ATF_TC_CLEANUP(mkfifo_stat, tc) | |
262 | { | 262 | { | |
263 | (void)unlink(path); | 263 | (void)unlink(path); | |
264 | } | 264 | } | |
265 | 265 | |||
266 | ATF_TC_WITH_CLEANUP(mknod_s_ififo); | |||
267 | ATF_TC_HEAD(mknod_s_ififo, tc) | |||
268 | { | |||
269 | atf_tc_set_md_var(tc, "descr", "Test mknod(2) with S_IFIFO"); | |||
270 | } | |||
271 | ||||
272 | ATF_TC_BODY(mknod_s_ififo, tc) | |||
273 | { | |||
274 | struct stat st; | |||
275 | ||||
276 | support(); | |||
277 | ||||
278 | (void)memset(&st, 0, sizeof(struct stat)); | |||
279 | ||||
280 | ATF_REQUIRE(mknod(path, S_IFIFO | 0600, 0) == 0); | |||
281 | ATF_REQUIRE(stat(path, &st) == 0); | |||
282 | ||||
283 | if (S_ISFIFO(st.st_mode) == 0) | |||
284 | atf_tc_fail("invalid mode from mknod(2) with S_IFIFO"); | |||
285 | ||||
286 | ATF_REQUIRE(unlink(path) == 0); | |||
287 | } | |||
288 | ||||
289 | ATF_TC_CLEANUP(mknod_s_ififo, tc) | |||
290 | { | |||
291 | (void)unlink(path); | |||
292 | } | |||
293 | ||||
266 | ATF_TP_ADD_TCS(tp) | 294 | ATF_TP_ADD_TCS(tp) | |
267 | { | 295 | { | |
268 | 296 | |||
269 | ATF_TP_ADD_TC(tp, mkfifo_block); | 297 | ATF_TP_ADD_TC(tp, mkfifo_block); | |
270 | ATF_TP_ADD_TC(tp, mkfifo_err); | 298 | ATF_TP_ADD_TC(tp, mkfifo_err); | |
271 | ATF_TP_ADD_TC(tp, mkfifo_nonblock); | 299 | ATF_TP_ADD_TC(tp, mkfifo_nonblock); | |
272 | ATF_TP_ADD_TC(tp, mkfifo_perm); | 300 | ATF_TP_ADD_TC(tp, mkfifo_perm); | |
273 | ATF_TP_ADD_TC(tp, mkfifo_stat); | 301 | ATF_TP_ADD_TC(tp, mkfifo_stat); | |
302 | ATF_TP_ADD_TC(tp, mknod_s_ififo); | |||
274 | 303 | |||
275 | return atf_no_error(); | 304 | return atf_no_error(); | |
276 | } | 305 | } |