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