1FATTACH(3P)                POSIX Programmer's Manual               FATTACH(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fattach — attach a STREAMS-based file descriptor to a file in the  file
13       system name space (STREAMS)
14

SYNOPSIS

16       #include <stropts.h>
17
18       int fattach(int fildes, const char *path);
19

DESCRIPTION

21       The  fattach() function shall attach a STREAMS-based file descriptor to
22       a file, effectively associating a pathname with fildes.   The  applica‐
23       tion  shall  ensure  that  the  fildes  argument  is  a valid open file
24       descriptor associated with a STREAMS file. The path argument points  to
25       a  pathname of an existing file. The application shall have appropriate
26       privileges or be the owner of the file named by  path  and  have  write
27       permission.  A  successful  call to fattach() shall cause all pathnames
28       that name the file named by path to name the  STREAMS  file  associated
29       with  fildes,  until  the  STREAMS  file  is  detached from the file. A
30       STREAMS file can be attached to more than one file and can have several
31       pathnames associated with it.
32
33       The  attributes  of the named STREAMS file shall be initialized as fol‐
34       lows: the permissions, user ID, group ID, and times are set to those of
35       the  file  named by path, the number of links is set to 1, and the size
36       and device identifier are set to those of the STREAMS  file  associated
37       with  fildes.   If  any attributes of the named STREAMS file are subse‐
38       quently changed (for example, by chmod()), neither  the  attributes  of
39       the  underlying  file  nor  the attributes of the STREAMS file to which
40       fildes refers shall be affected.
41
42       File descriptors referring to the underlying file, opened prior  to  an
43       fattach() call, shall continue to refer to the underlying file.
44

RETURN VALUE

46       Upon  successful  completion,  fattach()  shall return 0. Otherwise, -1
47       shall be returned and errno set to indicate the error.
48

ERRORS

50       The fattach() function shall fail if:
51
52       EACCES Search permission is denied for a component of the path  prefix,
53              or the process is the owner of path but does not have write per‐
54              missions on the file named by path.
55
56       EBADF  The fildes argument is not a valid open file descriptor.
57
58       EBUSY  The file named by path is currently  a  mount  point  or  has  a
59              STREAMS file attached to it.
60
61       ELOOP  A loop exists in symbolic links encountered during resolution of
62              the path argument.
63
64       ENAMETOOLONG
65              The  length  of  a  component  of  a  pathname  is  longer  than
66              {NAME_MAX}.
67
68       ENOENT A component of path does not name an existing file or path is an
69              empty string.
70
71       ENOTDIR
72              A component of the path prefix names an existing  file  that  is
73              neither  a  directory nor a symbolic link to a directory, or the
74              path argument contains at least one  non-<slash>  character  and
75              ends with one or more trailing <slash> characters.
76
77       EPERM  The  effective  user  ID  of the process is not the owner of the
78              file named by path and the process  does  not  have  appropriate
79              privileges.
80
81       The fattach() function may fail if:
82
83       EINVAL The fildes argument does not refer to a STREAMS file.
84
85       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
86              resolution of the path argument.
87
88       ENAMETOOLONG
89              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
90              tion  of  a symbolic link produced an intermediate result with a
91              length that exceeds {PATH_MAX}.
92
93       EXDEV  A link to a file on another file system was attempted.
94
95       The following sections are informative.
96

EXAMPLES

98   Attaching a File Descriptor to a File
99       In the following example, fd refers to an open STREAMS file.  The  call
100       to  fattach()  associates  this STREAM with the file /tmp/named-STREAM,
101       such that any future calls to open /tmp/named-STREAM, prior to breaking
102       the  attachment via a call to fdetach(), will instead create a new file
103       handle referring to the STREAMS file associated with fd.
104
105
106           #include <stropts.h>
107           ...
108               int fd;
109               char *pathname = "/tmp/named-STREAM";
110               int ret;
111
112               ret = fattach(fd, pathname);
113

APPLICATION USAGE

115       The fattach() function behaves similarly  to  the  traditional  mount()
116       function  in  the way a file is temporarily replaced by the root direc‐
117       tory of the mounted file system. In the case of fattach(), the replaced
118       file need not be a directory and the replacing file is a STREAMS file.
119

RATIONALE

121       The  file  attributes  of  a file which has been the subject of an fat‐
122       tach() call are specifically set because of an artifact of the original
123       implementation.  The internal mechanism was the same as for the mount()
124       function. Since mount() is typically only applied to  directories,  the
125       effects  when  applied to a regular file are a little surprising, espe‐
126       cially as regards the link count which rigidly  remains  one,  even  if
127       there were several links originally and despite the fact that all orig‐
128       inal links refer to the STREAM as long  as  the  fattach()  remains  in
129       effect.
130

FUTURE DIRECTIONS

132       The fattach() function may be removed in a future version.
133

SEE ALSO

135       fdetach(), isastream()
136
137       The Base Definitions volume of POSIX.1‐2017, <stropts.h>
138
140       Portions  of  this text are reprinted and reproduced in electronic form
141       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
142       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
143       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
144       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
145       event of any discrepancy between this version and the original IEEE and
146       The  Open Group Standard, the original IEEE and The Open Group Standard
147       is the referee document. The original Standard can be  obtained  online
148       at http://www.opengroup.org/unix/online.html .
149
150       Any  typographical  or  formatting  errors that appear in this page are
151       most likely to have been introduced during the conversion of the source
152       files  to  man page format. To report such errors, see https://www.ker
153       nel.org/doc/man-pages/reporting_bugs.html .
154
155
156
157IEEE/The Open Group                  2017                          FATTACH(3P)
Impressum