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
20

DESCRIPTION

22       The  fattach() function shall attach a STREAMS-based file descriptor to
23       a file, effectively associating a pathname with fildes. The application
24       shall  ensure  that the fildes argument is a valid open file descriptor
25       associated with a STREAMS file. The path argument points to a  pathname
26       of  an existing file. The application shall have the appropriate privi‐
27       leges or be the owner of the file named by path and have write  permis‐
28       sion.  A  successful  call  to fattach() shall cause all pathnames that
29       name the file named by path to name the STREAMS  file  associated  with
30       fildes,  until  the  STREAMS  file is detached from the file. A STREAMS
31       file can be attached to more than one file and can have  several  path‐
32       names 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 size of path exceeds {PATH_MAX} or a component  of  path  is
67              longer than {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 is not a directory.
74
75       EPERM  The effective user ID of the process is not  the  owner  of  the
76              file  named  by  path  and the process does not have appropriate
77              privilege.
78
79
80       The fattach() function may fail if:
81
82       EINVAL The fildes argument does not refer to a STREAMS file.
83
84       ELOOP  More than {SYMLOOP_MAX} symbolic links were  encountered  during
85              resolution of the path argument.
86
87       ENAMETOOLONG
88              Pathname  resolution of a symbolic link produced an intermediate
89              result whose length exceeds {PATH_MAX}.
90
91       EXDEV  A link to a file on another file system was attempted.
92
93
94       The following sections are informative.
95

EXAMPLES

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

SEE ALSO

135       fdetach(),    isastream(),    the    Base    Definitions    volume   of
136       IEEE Std 1003.1-2001, <stropts.h>
137
139       Portions of this text are reprinted and reproduced in  electronic  form
140       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
141       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
142       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
143       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
144       event of any discrepancy between this version and the original IEEE and
145       The Open Group Standard, the original IEEE and The Open Group  Standard
146       is  the  referee document. The original Standard can be obtained online
147       at http://www.opengroup.org/unix/online.html .
148
149
150
151IEEE/The Open Group                  2003                          FATTACH(3P)
Impressum