|
Packit |
7cfc04 |
'\" et
|
|
Packit |
7cfc04 |
.TH FATTACH "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH PROLOG
|
|
Packit |
7cfc04 |
This manual page is part of the POSIX Programmer's Manual.
|
|
Packit |
7cfc04 |
The Linux implementation of this interface may differ (consult
|
|
Packit |
7cfc04 |
the corresponding Linux manual page for details of Linux behavior),
|
|
Packit |
7cfc04 |
or the interface may not be implemented on Linux.
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
fattach
|
|
Packit |
7cfc04 |
\(em attach a STREAMS-based file descriptor to a file in the
|
|
Packit |
7cfc04 |
file system name space (\fBSTREAMS\fP)
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
#include <stropts.h>
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
int fattach(int \fIfildes\fP, const char *\fIpath\fP);
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
function shall attach a STREAMS-based file descriptor to a file,
|
|
Packit |
7cfc04 |
effectively associating a pathname with
|
|
Packit |
7cfc04 |
.IR fildes .
|
|
Packit |
7cfc04 |
The application shall ensure that the
|
|
Packit |
7cfc04 |
.IR fildes
|
|
Packit |
7cfc04 |
argument is a valid open file descriptor associated with a STREAMS
|
|
Packit |
7cfc04 |
file. The
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument points to a pathname of an existing file. The application
|
|
Packit |
7cfc04 |
shall have appropriate privileges or be the owner of the file
|
|
Packit |
7cfc04 |
named by
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
and have write permission. A successful call to
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
shall cause all pathnames that name the file named by
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
to name the STREAMS file associated with
|
|
Packit |
7cfc04 |
.IR fildes ,
|
|
Packit |
7cfc04 |
until the STREAMS file is detached from the file. A STREAMS file can be
|
|
Packit |
7cfc04 |
attached to more than one file and can have several pathnames
|
|
Packit |
7cfc04 |
associated with it.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The attributes of the named STREAMS file shall be initialized as follows:
|
|
Packit |
7cfc04 |
the permissions, user ID, group ID, and times are set to those of the
|
|
Packit |
7cfc04 |
file named by
|
|
Packit |
7cfc04 |
.IR path ,
|
|
Packit |
7cfc04 |
the number of links is set to 1, and the size and device identifier are
|
|
Packit |
7cfc04 |
set to those of the STREAMS file associated with
|
|
Packit |
7cfc04 |
.IR fildes .
|
|
Packit |
7cfc04 |
If any attributes of the named STREAMS file are subsequently changed
|
|
Packit |
7cfc04 |
(for example, by
|
|
Packit |
7cfc04 |
\fIchmod\fR()),
|
|
Packit |
7cfc04 |
neither the attributes of the underlying file nor the attributes of the
|
|
Packit |
7cfc04 |
STREAMS file to which
|
|
Packit |
7cfc04 |
.IR fildes
|
|
Packit |
7cfc04 |
refers shall be affected.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
File descriptors referring to the underlying file, opened prior to an
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
call, shall continue to refer to the underlying file.
|
|
Packit |
7cfc04 |
.SH "RETURN VALUE"
|
|
Packit |
7cfc04 |
Upon successful completion,
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
shall return 0. Otherwise, \(mi1 shall be returned and
|
|
Packit |
7cfc04 |
.IR errno
|
|
Packit |
7cfc04 |
set to indicate the error.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
function shall fail if:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EACCES
|
|
Packit |
7cfc04 |
Search permission is denied for a component of the path prefix, or the
|
|
Packit |
7cfc04 |
process is the owner of
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
but does not have write permissions on the file named by
|
|
Packit |
7cfc04 |
.IR path .
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EBADF
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.IR fildes
|
|
Packit |
7cfc04 |
argument is not a valid open file descriptor.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EBUSY
|
|
Packit |
7cfc04 |
The file named by
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
is currently a mount point or has a STREAMS file attached to it.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ELOOP
|
|
Packit |
7cfc04 |
A loop exists in symbolic links encountered during resolution of the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENAMETOOLONG
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
The length of a component of a pathname is longer than
|
|
Packit |
7cfc04 |
{NAME_MAX}.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENOENT
|
|
Packit |
7cfc04 |
A component of
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
does not name an existing file or
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
is an empty string.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENOTDIR
|
|
Packit |
7cfc04 |
A component of the path prefix names an existing file that is neither
|
|
Packit |
7cfc04 |
a directory nor a symbolic link to a directory, or the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument contains at least one non-\c
|
|
Packit |
7cfc04 |
<slash>
|
|
Packit |
7cfc04 |
character and ends with one or more trailing
|
|
Packit |
7cfc04 |
<slash>
|
|
Packit |
7cfc04 |
characters.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EPERM
|
|
Packit |
7cfc04 |
The effective user ID of the process is not the owner of the file named
|
|
Packit |
7cfc04 |
by
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
and the process does not have appropriate privileges.
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
function may fail if:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EINVAL
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.IR fildes
|
|
Packit |
7cfc04 |
argument does not refer to a STREAMS file.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ELOOP
|
|
Packit |
7cfc04 |
More than
|
|
Packit |
7cfc04 |
{SYMLOOP_MAX}
|
|
Packit |
7cfc04 |
symbolic links were encountered during resolution of the
|
|
Packit |
7cfc04 |
.IR path
|
|
Packit |
7cfc04 |
argument.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR ENAMETOOLONG
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
The length of a pathname exceeds
|
|
Packit |
7cfc04 |
{PATH_MAX},
|
|
Packit |
7cfc04 |
or pathname resolution of a symbolic link produced an intermediate
|
|
Packit |
7cfc04 |
result with a length that exceeds
|
|
Packit |
7cfc04 |
{PATH_MAX}.
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EXDEV
|
|
Packit |
7cfc04 |
A link to a file on another file system was attempted.
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.IR "The following sections are informative."
|
|
Packit |
7cfc04 |
.SH EXAMPLES
|
|
Packit |
7cfc04 |
.SS "Attaching a File Descriptor to a File"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
In the following example,
|
|
Packit |
7cfc04 |
.IR fd
|
|
Packit |
7cfc04 |
refers to an open STREAMS file. The call to
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
associates this STREAM with the file
|
|
Packit |
7cfc04 |
.BR /tmp/named-STREAM ,
|
|
Packit |
7cfc04 |
such that any future calls to open
|
|
Packit |
7cfc04 |
.BR /tmp/named-STREAM ,
|
|
Packit |
7cfc04 |
prior to breaking the attachment via a call to
|
|
Packit |
7cfc04 |
\fIfdetach\fR(),
|
|
Packit |
7cfc04 |
will instead create a new file handle referring to the STREAMS file
|
|
Packit |
7cfc04 |
associated with
|
|
Packit |
7cfc04 |
.IR fd .
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
#include <stropts.h>
|
|
Packit |
7cfc04 |
\&...
|
|
Packit |
7cfc04 |
int fd;
|
|
Packit |
7cfc04 |
char *pathname = "/tmp/named-STREAM";
|
|
Packit |
7cfc04 |
int ret;
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
ret = fattach(fd, pathname);
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.SH "APPLICATION USAGE"
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
function behaves similarly to the traditional
|
|
Packit |
7cfc04 |
\fImount\fR()
|
|
Packit |
7cfc04 |
function in the way a file is temporarily replaced by the root
|
|
Packit |
7cfc04 |
directory of the mounted file system. In the case of
|
|
Packit |
7cfc04 |
\fIfattach\fR(),
|
|
Packit |
7cfc04 |
the replaced file need not be a directory and the replacing file is a
|
|
Packit |
7cfc04 |
STREAMS file.
|
|
Packit |
7cfc04 |
.SH RATIONALE
|
|
Packit |
7cfc04 |
The file attributes of a file which has been the subject of an
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
call are specifically set because of an artifact of the original
|
|
Packit |
7cfc04 |
implementation. The internal mechanism was the same as for the
|
|
Packit |
7cfc04 |
\fImount\fR()
|
|
Packit |
7cfc04 |
function. Since
|
|
Packit |
7cfc04 |
\fImount\fR()
|
|
Packit |
7cfc04 |
is typically only applied to directories, the effects when applied to
|
|
Packit |
7cfc04 |
a regular file are a little surprising, especially as regards the link
|
|
Packit |
7cfc04 |
count which rigidly remains one, even if there were several links
|
|
Packit |
7cfc04 |
originally and despite the fact that all original links refer to the
|
|
Packit |
7cfc04 |
STREAM as long as the
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
remains in effect.
|
|
Packit |
7cfc04 |
.SH "FUTURE DIRECTIONS"
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIfattach\fR()
|
|
Packit |
7cfc04 |
function may be removed in a future version.
|
|
Packit |
7cfc04 |
.SH "SEE ALSO"
|
|
Packit |
7cfc04 |
.IR "\fIfdetach\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIisastream\fR\^(\|)"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The Base Definitions volume of POSIX.1\(hy2008,
|
|
Packit |
7cfc04 |
.IR "\fB<stropts.h>\fP"
|
|
Packit |
7cfc04 |
.SH COPYRIGHT
|
|
Packit |
7cfc04 |
Portions of this text are reprinted and reproduced in electronic form
|
|
Packit |
7cfc04 |
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
|
|
Packit |
7cfc04 |
-- Portable Operating System Interface (POSIX), The Open Group Base
|
|
Packit |
7cfc04 |
Specifications Issue 7, Copyright (C) 2013 by the Institute of
|
|
Packit |
7cfc04 |
Electrical and Electronics Engineers, Inc and The Open Group.
|
|
Packit |
7cfc04 |
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
|
|
Packit |
7cfc04 |
event of any discrepancy between this version and the original IEEE and
|
|
Packit |
7cfc04 |
The Open Group Standard, the original IEEE and The Open Group Standard
|
|
Packit |
7cfc04 |
is the referee document. The original Standard can be obtained online at
|
|
Packit |
7cfc04 |
http://www.unix.org/online.html .
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
Any typographical or formatting errors that appear
|
|
Packit |
7cfc04 |
in this page are most likely
|
|
Packit |
7cfc04 |
to have been introduced during the conversion of the source files to
|
|
Packit |
7cfc04 |
man page format. To report such errors, see
|
|
Packit |
7cfc04 |
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|