4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Attach a STREAMS or door based file descriptor to an object in the file
37 #pragma weak _fattach = fattach
40 #include <sys/types.h>
45 #include <sys/fs/namenode.h>
46 #include <sys/mount.h>
52 fattach(int fildes
, const char *path
)
54 struct namefd namefdp
;
55 struct door_info dinfo
;
59 /* Only STREAMS and doors allowed to be mounted */
60 if ((s
= isastream(fildes
)) == 1 || __door_info(fildes
, &dinfo
) == 0) {
62 if (path
== NULL
|| *path
== '\0') {
65 } else if (*path
!= '/') {
67 * The mount point must be an absolute path.
69 if (getcwd(buf
, sizeof (buf
)) == NULL
) {
70 /* errno already set */
74 * The kernel will truncate the path if it would have
75 * turned into something more than MAXPATHLEN bytes.
76 * So we do the same here.
78 if (strlcat(buf
, "/", sizeof (buf
)) >= sizeof (buf
) ||
79 strlcat(buf
, path
, sizeof (buf
)) >= sizeof (buf
)) {
85 return (mount(NULL
, path
, MS_DATA
|MS_NOMNTTAB
,
86 (const char *)"namefs", (char *)&namefdp
,
87 sizeof (struct namefd
), NULL
, 0));
93 /* errno already set */