logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

mkfifo.3p (8226B)


  1. '\" et
  2. .TH MKFIFO "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. mkfifo, mkfifoat
  12. \(em make a FIFO special file
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/stat.h>
  17. .P
  18. int mkfifo(const char *\fIpath\fP, mode_t \fImode\fP);
  19. .P
  20. #include <fcntl.h>
  21. .P
  22. int mkfifoat(int \fIfd\fP, const char *\fIpath\fP, mode_t \fImode\fP);
  23. .fi
  24. .SH DESCRIPTION
  25. The
  26. \fImkfifo\fR()
  27. function shall create a new FIFO special file named by the pathname
  28. pointed to by
  29. .IR path .
  30. The file permission bits of the new FIFO shall be initialized from
  31. .IR mode .
  32. The file permission bits of the
  33. .IR mode
  34. argument shall be modified by the process' file creation mask.
  35. .P
  36. When bits in
  37. .IR mode
  38. other than the file permission bits are set, the effect is
  39. implementation-defined.
  40. .P
  41. If
  42. .IR path
  43. names a symbolic link,
  44. \fImkfifo\fR()
  45. shall fail and set
  46. .IR errno
  47. to
  48. .BR [EEXIST] .
  49. .P
  50. The FIFO's user ID shall be set to the process' effective user ID. The
  51. FIFO's group ID shall be set to the group ID of the parent directory or
  52. to the effective group ID of the process. Implementations shall provide
  53. a way to initialize the FIFO's group ID to the group ID of the parent
  54. directory. Implementations may, but need not, provide an
  55. implementation-defined way to initialize the FIFO's group ID to the
  56. effective group ID of the calling process.
  57. .P
  58. Upon successful completion,
  59. \fImkfifo\fR()
  60. shall mark for update the last data access, last data modification,
  61. and last file status change timestamps of the file. Also, the last
  62. data modification and last file status change timestamps of the directory
  63. that contains the new entry shall be marked for update.
  64. .P
  65. The
  66. \fImkfifoat\fR()
  67. function shall be equivalent to the
  68. \fImkfifo\fR()
  69. function except in the case where
  70. .IR path
  71. specifies a relative path. In this case the newly created FIFO is
  72. created relative to the directory associated with the file descriptor
  73. .IR fd
  74. instead of the current working directory. If the access mode of the
  75. open file description associated with the file descriptor is not
  76. O_SEARCH, the function shall check whether directory searches are
  77. permitted using the current permissions of the directory underlying
  78. the file descriptor. If the access mode is O_SEARCH, the function
  79. shall not perform the check.
  80. .P
  81. If
  82. \fImkfifoat\fR()
  83. is passed the special value AT_FDCWD in the
  84. .IR fd
  85. parameter, the current working directory shall be used and the behavior
  86. shall be identical to a call to
  87. \fImkfifo\fR().
  88. .SH "RETURN VALUE"
  89. Upon successful completion, these functions shall return 0.
  90. Otherwise, these functions shall return \-1 and set
  91. .IR errno
  92. to indicate the error. If \-1 is returned, no FIFO shall be created.
  93. .SH ERRORS
  94. These functions shall fail if:
  95. .TP
  96. .BR EACCES
  97. A component of the path prefix denies search permission, or write
  98. permission is denied on the parent directory of the FIFO to be
  99. created.
  100. .TP
  101. .BR EEXIST
  102. The named file already exists.
  103. .TP
  104. .BR ELOOP
  105. A loop exists in symbolic links encountered during resolution of the
  106. .IR path
  107. argument.
  108. .TP
  109. .BR ENAMETOOLONG
  110. .br
  111. The length of a component of a pathname is longer than
  112. {NAME_MAX}.
  113. .TP
  114. .BR ENOENT
  115. A component of the path prefix of
  116. .IR path
  117. does not name an existing file or
  118. .IR path
  119. is an empty string.
  120. .TP
  121. .BR ENOENT " or " ENOTDIR
  122. .br
  123. The
  124. .IR path
  125. argument contains at least one non-\c
  126. <slash>
  127. character and ends with one or more trailing
  128. <slash>
  129. characters. If
  130. .IR path
  131. without the trailing
  132. <slash>
  133. characters would name an existing file, an
  134. .BR [ENOENT]
  135. error shall not occur.
  136. .TP
  137. .BR ENOSPC
  138. The directory that would contain the new file cannot be extended or the
  139. file system is out of file-allocation resources.
  140. .TP
  141. .BR ENOTDIR
  142. A component of the path prefix names an existing file that is neither
  143. a directory nor a symbolic link to a directory.
  144. .TP
  145. .BR EROFS
  146. The named file resides on a read-only file system.
  147. .P
  148. The
  149. \fImkfifoat\fR()
  150. function shall fail if:
  151. .TP
  152. .BR EACCES
  153. The access mode of the open file description associated with
  154. .IR fd
  155. is not O_SEARCH and the permissions of the directory underlying
  156. .IR fd
  157. do not permit directory searches.
  158. .TP
  159. .BR EBADF
  160. The
  161. .IR path
  162. argument does not specify an absolute path and the
  163. .IR fd
  164. argument is neither AT_FDCWD nor a valid file descriptor open
  165. for reading or searching.
  166. .TP
  167. .BR ENOTDIR
  168. The
  169. .IR path
  170. argument is not an absolute path and
  171. .IR fd
  172. is a file descriptor associated with a non-directory file.
  173. .P
  174. These functions may fail if:
  175. .TP
  176. .BR ELOOP
  177. More than
  178. {SYMLOOP_MAX}
  179. symbolic links were encountered during resolution of the
  180. .IR path
  181. argument.
  182. .TP
  183. .BR ENAMETOOLONG
  184. .br
  185. The length of a pathname exceeds
  186. {PATH_MAX},
  187. or pathname resolution of a symbolic link produced an intermediate
  188. result with a length that exceeds
  189. {PATH_MAX}.
  190. .LP
  191. .IR "The following sections are informative."
  192. .SH EXAMPLES
  193. .SS "Creating a FIFO File"
  194. .P
  195. The following example shows how to create a FIFO file named
  196. .BR /home/cnd/mod_done ,
  197. with read/write permissions for owner, and with read permissions for
  198. group and others.
  199. .sp
  200. .RS 4
  201. .nf
  202. #include <sys/types.h>
  203. #include <sys/stat.h>
  204. .P
  205. int status;
  206. \&...
  207. status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR |
  208. S_IRGRP | S_IROTH);
  209. .fi
  210. .P
  211. .RE
  212. .SH "APPLICATION USAGE"
  213. None.
  214. .SH RATIONALE
  215. The syntax of this function is intended to maintain compatibility with
  216. historical implementations of
  217. \fImknod\fR().
  218. The latter function was included in the 1984 /usr/group standard but only for use in
  219. creating FIFO special files. The
  220. \fImknod\fR()
  221. function was originally excluded from the POSIX.1\(hy1988 standard as
  222. implementation-defined and replaced by
  223. \fImkdir\fR()
  224. and
  225. \fImkfifo\fR().
  226. The
  227. \fImknod\fR()
  228. function is now included for alignment with the Single UNIX Specification.
  229. .P
  230. The POSIX.1\(hy1990 standard required that the group ID of a newly created FIFO be
  231. set to the group ID of its parent directory or to the effective group
  232. ID of the creating process. FIPS 151\(hy2 required that implementations provide
  233. a way to have the group ID be set to the group ID of the containing
  234. directory, but did not prohibit implementations also supporting a way
  235. to set the group ID to the effective group ID of the creating process.
  236. Conforming applications should not assume which group ID will be used. If
  237. it matters, an application can use
  238. \fIchown\fR()
  239. to set the group ID after the FIFO is created, or determine under
  240. what conditions the implementation will set the desired group ID.
  241. .P
  242. The purpose of the
  243. \fImkfifoat\fR()
  244. function is to create a FIFO special file in directories other than
  245. the current working directory without exposure to race conditions. Any
  246. part of the path of a file could be changed in parallel to a call to
  247. \fImkfifo\fR(),
  248. resulting in unspecified behavior. By opening a file descriptor for
  249. the target directory and using the
  250. \fImkfifoat\fR()
  251. function it can be guaranteed that the newly created FIFO is located
  252. relative to the desired directory.
  253. .SH "FUTURE DIRECTIONS"
  254. None.
  255. .SH "SEE ALSO"
  256. .IR "\fIchmod\fR\^(\|)",
  257. .IR "\fImknod\fR\^(\|)",
  258. .IR "\fIumask\fR\^(\|)"
  259. .P
  260. The Base Definitions volume of POSIX.1\(hy2017,
  261. .IR "\fB<fcntl.h>\fP",
  262. .IR "\fB<sys_stat.h>\fP",
  263. .IR "\fB<sys_types.h>\fP"
  264. .\"
  265. .SH COPYRIGHT
  266. Portions of this text are reprinted and reproduced in electronic form
  267. from IEEE Std 1003.1-2017, Standard for Information Technology
  268. -- Portable Operating System Interface (POSIX), The Open Group Base
  269. Specifications Issue 7, 2018 Edition,
  270. Copyright (C) 2018 by the Institute of
  271. Electrical and Electronics Engineers, Inc and The Open Group.
  272. In the event of any discrepancy between this version and the original IEEE and
  273. The Open Group Standard, the original IEEE and The Open Group Standard
  274. is the referee document. The original Standard can be obtained online at
  275. http://www.opengroup.org/unix/online.html .
  276. .PP
  277. Any typographical or formatting errors that appear
  278. in this page are most likely
  279. to have been introduced during the conversion of the source files to
  280. man page format. To report such errors, see
  281. https://www.kernel.org/doc/man-pages/reporting_bugs.html .