xref: /titanic_50/usr/src/stand/lib/fs/nfs/st_pathname.h (revision d67944fbe3fa0b31893a7116a09b0718eecf6078)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _ST_PATHNAME_H
28 #define	_ST_PATHNAME_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Pathname structure.
36  * System calls which operate on path names gather the
37  * pathname from system call into this structure and reduce
38  * it by peeling off translated components.  If a symbolic
39  * link is encountered the new pathname to be translated
40  * is also assembled in this structure.
41  */
42 
43 struct st_pathname {
44 	char	*pn_buf;		/* underlying storage */
45 	char	*pn_path;		/* remaining pathname */
46 	uint_t	pn_pathlen;		/* remaining length */
47 };
48 
49 #define	PN_STRIP 0x00		/* Strip next component off pn */
50 #define	PN_PEEK	0x01  		/* Only peek at next pn component */
51 #define	stpn_peekcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_PEEK)
52 #define	stpn_stripcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_STRIP)
53 
54 #define	stpn_peekchar(PNP) 	(((PNP)->pn_pathlen != 0) ? \
55 				    *((PNP)->pn_path) : (char)0)
56 #define	stpn_pathleft(PNP)	((PNP)->pn_pathlen)
57 #define	stpn_getpath(PNP)		((PNP)->pn_path)
58 #define	stpn_copy(PNP1, PNP2)	(stpn_set(PNP2, stpn_getpath(PNP1)))
59 
60 extern int	stpn_alloc();		/* allocate buffer for pathname */
61 extern int	stpn_get();		/* allocate buf and copy path into it */
62 extern int	stpn_set();		/* set pathname to string */
63 extern int	stpn_combine();		/* combine to pathnames (for symlink) */
64 extern int	stpn_getcomponent();	/* get next component of pathname */
65 extern void	stpn_skipslash();		/* skip over slashes */
66 extern void	stpn_free();		/* free pathname buffer */
67 
68 #ifdef	__cplusplus
69 }
70 #endif
71 
72 #endif /* _ST_PATHNAME_H */
73