xref: /onnv-gate/usr/src/stand/lib/fs/nfs/st_pathname.h (revision 9694:78fafb281255)
1*9694SScott.Rotondo@Sun.COM /*
2*9694SScott.Rotondo@Sun.COM  * CDDL HEADER START
3*9694SScott.Rotondo@Sun.COM  *
4*9694SScott.Rotondo@Sun.COM  * The contents of this file are subject to the terms of the
5*9694SScott.Rotondo@Sun.COM  * Common Development and Distribution License (the "License").
6*9694SScott.Rotondo@Sun.COM  * You may not use this file except in compliance with the License.
7*9694SScott.Rotondo@Sun.COM  *
8*9694SScott.Rotondo@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9694SScott.Rotondo@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*9694SScott.Rotondo@Sun.COM  * See the License for the specific language governing permissions
11*9694SScott.Rotondo@Sun.COM  * and limitations under the License.
12*9694SScott.Rotondo@Sun.COM  *
13*9694SScott.Rotondo@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*9694SScott.Rotondo@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9694SScott.Rotondo@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*9694SScott.Rotondo@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*9694SScott.Rotondo@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*9694SScott.Rotondo@Sun.COM  *
19*9694SScott.Rotondo@Sun.COM  * CDDL HEADER END
20*9694SScott.Rotondo@Sun.COM  */
21*9694SScott.Rotondo@Sun.COM 
22*9694SScott.Rotondo@Sun.COM /*
23*9694SScott.Rotondo@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*9694SScott.Rotondo@Sun.COM  * Use is subject to license terms.
25*9694SScott.Rotondo@Sun.COM  */
26*9694SScott.Rotondo@Sun.COM 
27*9694SScott.Rotondo@Sun.COM #ifndef _ST_PATHNAME_H
28*9694SScott.Rotondo@Sun.COM #define	_ST_PATHNAME_H
29*9694SScott.Rotondo@Sun.COM 
30*9694SScott.Rotondo@Sun.COM #ifdef	__cplusplus
31*9694SScott.Rotondo@Sun.COM extern "C" {
32*9694SScott.Rotondo@Sun.COM #endif
33*9694SScott.Rotondo@Sun.COM 
34*9694SScott.Rotondo@Sun.COM /*
35*9694SScott.Rotondo@Sun.COM  * Pathname structure.
36*9694SScott.Rotondo@Sun.COM  * System calls which operate on path names gather the
37*9694SScott.Rotondo@Sun.COM  * pathname from system call into this structure and reduce
38*9694SScott.Rotondo@Sun.COM  * it by peeling off translated components.  If a symbolic
39*9694SScott.Rotondo@Sun.COM  * link is encountered the new pathname to be translated
40*9694SScott.Rotondo@Sun.COM  * is also assembled in this structure.
41*9694SScott.Rotondo@Sun.COM  */
42*9694SScott.Rotondo@Sun.COM 
43*9694SScott.Rotondo@Sun.COM struct st_pathname {
44*9694SScott.Rotondo@Sun.COM 	char	*pn_buf;		/* underlying storage */
45*9694SScott.Rotondo@Sun.COM 	char	*pn_path;		/* remaining pathname */
46*9694SScott.Rotondo@Sun.COM 	uint_t	pn_pathlen;		/* remaining length */
47*9694SScott.Rotondo@Sun.COM };
48*9694SScott.Rotondo@Sun.COM 
49*9694SScott.Rotondo@Sun.COM #define	PN_STRIP 0x00		/* Strip next component off pn */
50*9694SScott.Rotondo@Sun.COM #define	PN_PEEK	0x01  		/* Only peek at next pn component */
51*9694SScott.Rotondo@Sun.COM #define	stpn_peekcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_PEEK)
52*9694SScott.Rotondo@Sun.COM #define	stpn_stripcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_STRIP)
53*9694SScott.Rotondo@Sun.COM 
54*9694SScott.Rotondo@Sun.COM #define	stpn_peekchar(PNP) 	(((PNP)->pn_pathlen != 0) ? \
55*9694SScott.Rotondo@Sun.COM 				    *((PNP)->pn_path) : (char)0)
56*9694SScott.Rotondo@Sun.COM #define	stpn_pathleft(PNP)	((PNP)->pn_pathlen)
57*9694SScott.Rotondo@Sun.COM #define	stpn_getpath(PNP)		((PNP)->pn_path)
58*9694SScott.Rotondo@Sun.COM #define	stpn_copy(PNP1, PNP2)	(stpn_set(PNP2, stpn_getpath(PNP1)))
59*9694SScott.Rotondo@Sun.COM 
60*9694SScott.Rotondo@Sun.COM extern int	stpn_alloc();		/* allocate buffer for pathname */
61*9694SScott.Rotondo@Sun.COM extern int	stpn_get();		/* allocate buf and copy path into it */
62*9694SScott.Rotondo@Sun.COM extern int	stpn_set();		/* set pathname to string */
63*9694SScott.Rotondo@Sun.COM extern int	stpn_combine();		/* combine to pathnames (for symlink) */
64*9694SScott.Rotondo@Sun.COM extern int	stpn_getcomponent();	/* get next component of pathname */
65*9694SScott.Rotondo@Sun.COM extern void	stpn_skipslash();		/* skip over slashes */
66*9694SScott.Rotondo@Sun.COM extern void	stpn_free();		/* free pathname buffer */
67*9694SScott.Rotondo@Sun.COM 
68*9694SScott.Rotondo@Sun.COM #ifdef	__cplusplus
69*9694SScott.Rotondo@Sun.COM }
70*9694SScott.Rotondo@Sun.COM #endif
71*9694SScott.Rotondo@Sun.COM 
72*9694SScott.Rotondo@Sun.COM #endif /* _ST_PATHNAME_H */
73