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
11

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

99   Attaching a File Descriptor to a File
100       In the following example, fd refers to an open STREAMS file.  The  call
101       to  fattach()  associates  this STREAM with the file /tmp/named-STREAM,
102       such that any future calls to open /tmp/named-STREAM, prior to breaking
103       the  attachment via a call to fdetach(), will instead create a new file
104       handle referring to the STREAMS file associated with fd.
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‐2008, <stropts.h>
138
140       Portions  of  this text are reprinted and reproduced in electronic form
141       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
142       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
143       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
144       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
145       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
146       event of any discrepancy between this version and the original IEEE and
147       The Open Group Standard, the original IEEE and The Open Group  Standard
148       is  the  referee document. The original Standard can be obtained online
149       at http://www.unix.org/online.html .
150
151       Any typographical or formatting errors that appear  in  this  page  are
152       most likely to have been introduced during the conversion of the source
153       files to man page format. To report such errors,  see  https://www.ker
154       nel.org/doc/man-pages/reporting_bugs.html .
155
156
157
158IEEE/The Open Group                  2013                          FATTACH(3P)
Impressum