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

NAME

6       fattach  - attach a STREAMS-based file descriptor to a file in the file
7       system name space (STREAMS)
8

SYNOPSIS

10       #include <stropts.h>
11
12       int fattach(int fildes, const char *path);
13
14

DESCRIPTION

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

RETURN VALUE

41       Upon successful completion, fattach() shall  return  0.  Otherwise,  -1
42       shall be returned and errno set to indicate the error.
43

ERRORS

45       The fattach() function shall fail if:
46
47       EACCES Search  permission is denied for a component of the path prefix,
48              or the process is the owner of path but does not have write per‐
49              missions on the file named by path.
50
51       EBADF  The fildes argument is not a valid open file descriptor.
52
53       EBUSY  The  file  named  by  path  is  currently a mount point or has a
54              STREAMS file attached to it.
55
56       ELOOP  A loop exists in symbolic links encountered during resolution of
57              the path argument.
58
59       ENAMETOOLONG
60              The  size  of  path exceeds {PATH_MAX} or a component of path is
61              longer than {NAME_MAX}.
62
63       ENOENT A component of path does not name an existing file or path is an
64              empty string.
65
66       ENOTDIR
67              A component of the path prefix is not a directory.
68
69       EPERM  The  effective  user  ID  of the process is not the owner of the
70              file named by path and the process  does  not  have  appropriate
71              privilege.
72
73
74       The fattach() function may fail if:
75
76       EINVAL The fildes argument does not refer to a STREAMS file.
77
78       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
79              resolution of the path argument.
80
81       ENAMETOOLONG
82              Pathname resolution of a symbolic link produced an  intermediate
83              result whose length exceeds {PATH_MAX}.
84
85       EXDEV  A link to a file on another file system was attempted.
86
87
88       The following sections are informative.
89

EXAMPLES

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

APPLICATION USAGE

109       The  fattach()  function  behaves  similarly to the traditional mount()
110       function in the way a file is temporarily replaced by the  root  direc‐
111       tory of the mounted file system. In the case of fattach(), the replaced
112       file need not be a directory and the replacing file is a STREAMS file.
113

RATIONALE

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

FUTURE DIRECTIONS

126       None.
127

SEE ALSO

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