xref: /titanic_44/usr/src/uts/common/sys/pathname.h (revision e272e4c8df90e762ecb6a6564503bb2cb1e2027d)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 /*
30  * Portions of this source code were derived from Berkeley 4.3 BSD
31  * under license from the Regents of the University of California.
32  */
33 
34 #ifndef _SYS_PATHNAME_H
35 #define	_SYS_PATHNAME_H
36 
37 #include <sys/vnode.h>
38 #include <sys/cred.h>
39 #include <sys/uio.h>
40 #include <sys/dirent.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * Pathname structure.
48  * System calls that operate on path names gather the path name
49  * from the system call into this structure and reduce it by
50  * peeling off translated components.  If a symbolic link is
51  * encountered the new path name to be translated is also
52  * assembled in this structure.
53  *
54  * By convention pn_buf is not changed once it's been set to point
55  * to the underlying storage; routines which manipulate the pathname
56  * do so by changing pn_path and pn_pathlen.  pn_pathlen is redundant
57  * since the path name is null-terminated, but is provided to make
58  * some computations faster.
59  */
60 typedef struct pathname {
61 	char	*pn_buf;		/* underlying storage */
62 	char	*pn_path;		/* remaining pathname */
63 	size_t	pn_pathlen;		/* remaining length */
64 	size_t	pn_bufsize;		/* total size of pn_buf */
65 } pathname_t;
66 
67 #define	pn_pathleft(pnp)	((pnp)->pn_pathlen)
68 
69 extern void	pn_alloc(struct pathname *);
70 extern int	pn_get(char *, enum uio_seg, struct pathname *);
71 extern int	pn_get_buf(char *, enum uio_seg, struct pathname *,
72 			void *, size_t);
73 extern int	pn_set(struct pathname *, char *);
74 extern int	pn_insert(struct pathname *, struct pathname *, size_t);
75 extern int	pn_getsymlink(vnode_t *, struct pathname *, cred_t *);
76 extern int	pn_getcomponent(struct pathname *, char *);
77 extern void	pn_setlast(struct pathname *);
78 extern void	pn_skipslash(struct pathname *);
79 extern int	pn_fixslash(struct pathname *);
80 extern int	pn_addslash(struct pathname *);
81 extern void	pn_free(struct pathname *);
82 
83 extern int lookupname(char *, enum uio_seg, enum symfollow,
84 		vnode_t **, vnode_t **);
85 extern int lookupnameat(char *, enum uio_seg, enum symfollow,
86 		vnode_t **, vnode_t **, vnode_t *);
87 extern int lookupnameatcred(char *, enum uio_seg, enum symfollow,
88 		vnode_t **, vnode_t **, vnode_t *, cred_t *);
89 extern int lookuppn(struct pathname *, struct pathname *, enum symfollow,
90 		vnode_t **, vnode_t **);
91 extern int lookuppnat(struct pathname *, struct pathname *, enum symfollow,
92 		vnode_t **, vnode_t **, vnode_t *);
93 extern int lookuppnatcred(struct pathname *, struct pathname *, enum symfollow,
94 		vnode_t **, vnode_t **, vnode_t *, cred_t *);
95 
96 extern int lookuppnvp(struct pathname *, struct pathname *, int follow,
97 		vnode_t **, vnode_t **, vnode_t *, vnode_t *, cred_t *);
98 extern int traverse(vnode_t **);
99 
100 extern int vnodetopath(vnode_t *, vnode_t *, char *, size_t, cred_t *);
101 extern int dogetcwd(char *, size_t);
102 extern int dirfindvp(vnode_t *, vnode_t *, vnode_t *, cred_t *, char *,
103 		size_t, dirent64_t **);
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif	/* _SYS_PATHNAME_H */
110