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

fattach.3p (6455B)


  1. '\" et
  2. .TH FATTACH "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. fattach
  12. \(em attach a STREAMS-based file descriptor to a file in the
  13. file system name space (\fBSTREAMS\fP)
  14. .SH SYNOPSIS
  15. .LP
  16. .nf
  17. #include <stropts.h>
  18. .P
  19. int fattach(int \fIfildes\fP, const char *\fIpath\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The
  23. \fIfattach\fR()
  24. function shall attach a STREAMS-based file descriptor to a file,
  25. effectively associating a pathname with
  26. .IR fildes .
  27. The application shall ensure that the
  28. .IR fildes
  29. argument is a valid open file descriptor associated with a STREAMS
  30. file. The
  31. .IR path
  32. argument points to a pathname of an existing file. The application
  33. shall have appropriate privileges or be the owner of the file
  34. named by
  35. .IR path
  36. and have write permission. A successful call to
  37. \fIfattach\fR()
  38. shall cause all pathnames that name the file named by
  39. .IR path
  40. to name the STREAMS file associated with
  41. .IR fildes ,
  42. until the STREAMS file is detached from the file. A STREAMS file can be
  43. attached to more than one file and can have several pathnames
  44. associated with it.
  45. .P
  46. The attributes of the named STREAMS file shall be initialized as follows:
  47. the permissions, user ID, group ID, and times are set to those of the
  48. file named by
  49. .IR path ,
  50. the number of links is set to 1, and the size and device identifier are
  51. set to those of the STREAMS file associated with
  52. .IR fildes .
  53. If any attributes of the named STREAMS file are subsequently changed
  54. (for example, by
  55. \fIchmod\fR()),
  56. neither the attributes of the underlying file nor the attributes of the
  57. STREAMS file to which
  58. .IR fildes
  59. refers shall be affected.
  60. .P
  61. File descriptors referring to the underlying file, opened prior to an
  62. \fIfattach\fR()
  63. call, shall continue to refer to the underlying file.
  64. .SH "RETURN VALUE"
  65. Upon successful completion,
  66. \fIfattach\fR()
  67. shall return 0. Otherwise, \-1 shall be returned and
  68. .IR errno
  69. set to indicate the error.
  70. .SH ERRORS
  71. The
  72. \fIfattach\fR()
  73. function shall fail if:
  74. .TP
  75. .BR EACCES
  76. Search permission is denied for a component of the path prefix, or the
  77. process is the owner of
  78. .IR path
  79. but does not have write permissions on the file named by
  80. .IR path .
  81. .TP
  82. .BR EBADF
  83. The
  84. .IR fildes
  85. argument is not a valid open file descriptor.
  86. .TP
  87. .BR EBUSY
  88. The file named by
  89. .IR path
  90. is currently a mount point or has a STREAMS file attached to it.
  91. .TP
  92. .BR ELOOP
  93. A loop exists in symbolic links encountered during resolution of the
  94. .IR path
  95. argument.
  96. .TP
  97. .BR ENAMETOOLONG
  98. .br
  99. The length of a component of a pathname is longer than
  100. {NAME_MAX}.
  101. .TP
  102. .BR ENOENT
  103. A component of
  104. .IR path
  105. does not name an existing file or
  106. .IR path
  107. is an empty string.
  108. .TP
  109. .BR ENOTDIR
  110. A component of the path prefix names an existing file that is neither
  111. a directory nor a symbolic link to a directory, or the
  112. .IR path
  113. argument contains at least one non-\c
  114. <slash>
  115. character and ends with one or more trailing
  116. <slash>
  117. characters.
  118. .TP
  119. .BR EPERM
  120. The effective user ID of the process is not the owner of the file named
  121. by
  122. .IR path
  123. and the process does not have appropriate privileges.
  124. .br
  125. .P
  126. The
  127. \fIfattach\fR()
  128. function may fail if:
  129. .TP
  130. .BR EINVAL
  131. The
  132. .IR fildes
  133. argument does not refer to a STREAMS file.
  134. .TP
  135. .BR ELOOP
  136. More than
  137. {SYMLOOP_MAX}
  138. symbolic links were encountered during resolution of the
  139. .IR path
  140. argument.
  141. .TP
  142. .BR ENAMETOOLONG
  143. .br
  144. The length of a pathname exceeds
  145. {PATH_MAX},
  146. or pathname resolution of a symbolic link produced an intermediate
  147. result with a length that exceeds
  148. {PATH_MAX}.
  149. .TP
  150. .BR EXDEV
  151. A link to a file on another file system was attempted.
  152. .LP
  153. .IR "The following sections are informative."
  154. .SH EXAMPLES
  155. .SS "Attaching a File Descriptor to a File"
  156. .P
  157. In the following example,
  158. .IR fd
  159. refers to an open STREAMS file. The call to
  160. \fIfattach\fR()
  161. associates this STREAM with the file
  162. .BR /tmp/named-STREAM ,
  163. such that any future calls to open
  164. .BR /tmp/named-STREAM ,
  165. prior to breaking the attachment via a call to
  166. \fIfdetach\fR(),
  167. will instead create a new file handle referring to the STREAMS file
  168. associated with
  169. .IR fd .
  170. .sp
  171. .RS 4
  172. .nf
  173. #include <stropts.h>
  174. \&...
  175. int fd;
  176. char *pathname = "/tmp/named-STREAM";
  177. int ret;
  178. .P
  179. ret = fattach(fd, pathname);
  180. .fi
  181. .P
  182. .RE
  183. .SH "APPLICATION USAGE"
  184. The
  185. \fIfattach\fR()
  186. function behaves similarly to the traditional
  187. \fImount\fR()
  188. function in the way a file is temporarily replaced by the root
  189. directory of the mounted file system. In the case of
  190. \fIfattach\fR(),
  191. the replaced file need not be a directory and the replacing file is a
  192. STREAMS file.
  193. .SH RATIONALE
  194. The file attributes of a file which has been the subject of an
  195. \fIfattach\fR()
  196. call are specifically set because of an artifact of the original
  197. implementation. The internal mechanism was the same as for the
  198. \fImount\fR()
  199. function. Since
  200. \fImount\fR()
  201. is typically only applied to directories, the effects when applied to
  202. a regular file are a little surprising, especially as regards the link
  203. count which rigidly remains one, even if there were several links
  204. originally and despite the fact that all original links refer to the
  205. STREAM as long as the
  206. \fIfattach\fR()
  207. remains in effect.
  208. .SH "FUTURE DIRECTIONS"
  209. The
  210. \fIfattach\fR()
  211. function may be removed in a future version.
  212. .SH "SEE ALSO"
  213. .IR "\fIfdetach\fR\^(\|)",
  214. .IR "\fIisastream\fR\^(\|)"
  215. .P
  216. The Base Definitions volume of POSIX.1\(hy2017,
  217. .IR "\fB<stropts.h>\fP"
  218. .\"
  219. .SH COPYRIGHT
  220. Portions of this text are reprinted and reproduced in electronic form
  221. from IEEE Std 1003.1-2017, Standard for Information Technology
  222. -- Portable Operating System Interface (POSIX), The Open Group Base
  223. Specifications Issue 7, 2018 Edition,
  224. Copyright (C) 2018 by the Institute of
  225. Electrical and Electronics Engineers, Inc and The Open Group.
  226. In the event of any discrepancy between this version and the original IEEE and
  227. The Open Group Standard, the original IEEE and The Open Group Standard
  228. is the referee document. The original Standard can be obtained online at
  229. http://www.opengroup.org/unix/online.html .
  230. .PP
  231. Any typographical or formatting errors that appear
  232. in this page are most likely
  233. to have been introduced during the conversion of the source files to
  234. man page format. To report such errors, see
  235. https://www.kernel.org/doc/man-pages/reporting_bugs.html .