xref: /illumos-gate/usr/src/uts/common/sys/pathname.h (revision 5f61829a)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57a142be9SCasper H.S. Dik  * Common Development and Distribution License (the "License").
67a142be9SCasper H.S. Dik  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21794f0adbSRoger A. Faulkner 
227c478bd9Sstevel@tonic-gate /*
23794f0adbSRoger A. Faulkner  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27b4203d75SMarcel Telka /*	  All Rights Reserved	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
317c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifndef _SYS_PATHNAME_H
357c478bd9Sstevel@tonic-gate #define	_SYS_PATHNAME_H
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
387c478bd9Sstevel@tonic-gate #include <sys/cred.h>
397c478bd9Sstevel@tonic-gate #include <sys/uio.h>
407c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Pathname structure.
487c478bd9Sstevel@tonic-gate  * System calls that operate on path names gather the path name
497c478bd9Sstevel@tonic-gate  * from the system call into this structure and reduce it by
507c478bd9Sstevel@tonic-gate  * peeling off translated components.  If a symbolic link is
517c478bd9Sstevel@tonic-gate  * encountered the new path name to be translated is also
527c478bd9Sstevel@tonic-gate  * assembled in this structure.
537c478bd9Sstevel@tonic-gate  *
547c478bd9Sstevel@tonic-gate  * By convention pn_buf is not changed once it's been set to point
557c478bd9Sstevel@tonic-gate  * to the underlying storage; routines which manipulate the pathname
567c478bd9Sstevel@tonic-gate  * do so by changing pn_path and pn_pathlen.  pn_pathlen is redundant
577c478bd9Sstevel@tonic-gate  * since the path name is null-terminated, but is provided to make
587c478bd9Sstevel@tonic-gate  * some computations faster.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate typedef struct pathname {
617c478bd9Sstevel@tonic-gate 	char	*pn_buf;		/* underlying storage */
627c478bd9Sstevel@tonic-gate 	char	*pn_path;		/* remaining pathname */
637c478bd9Sstevel@tonic-gate 	size_t	pn_pathlen;		/* remaining length */
647c478bd9Sstevel@tonic-gate 	size_t	pn_bufsize;		/* total size of pn_buf */
657c478bd9Sstevel@tonic-gate } pathname_t;
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	pn_pathleft(pnp)	((pnp)->pn_pathlen)
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate extern void	pn_alloc(struct pathname *);
70b24e356bSPeer Dampmann extern void	pn_alloc_sz(struct pathname *, size_t);
71*5f61829aSRobert Mustacchi extern int	pn_get(const char *, enum uio_seg, struct pathname *);
72*5f61829aSRobert Mustacchi extern int	pn_get_buf(const char *, enum uio_seg, struct pathname *,
737c478bd9Sstevel@tonic-gate 			void *, size_t);
74*5f61829aSRobert Mustacchi extern int	pn_set(struct pathname *, const char *);
757c478bd9Sstevel@tonic-gate extern int	pn_insert(struct pathname *, struct pathname *, size_t);
767c478bd9Sstevel@tonic-gate extern int	pn_getsymlink(vnode_t *, struct pathname *, cred_t *);
777c478bd9Sstevel@tonic-gate extern int	pn_getcomponent(struct pathname *, char *);
787c478bd9Sstevel@tonic-gate extern void	pn_setlast(struct pathname *);
797c478bd9Sstevel@tonic-gate extern void	pn_skipslash(struct pathname *);
807c478bd9Sstevel@tonic-gate extern int	pn_fixslash(struct pathname *);
817c478bd9Sstevel@tonic-gate extern int	pn_addslash(struct pathname *);
827c478bd9Sstevel@tonic-gate extern void	pn_free(struct pathname *);
837c478bd9Sstevel@tonic-gate 
84*5f61829aSRobert Mustacchi extern int lookupname(const char *, enum uio_seg, int follow,
857c478bd9Sstevel@tonic-gate 		vnode_t **, vnode_t **);
86*5f61829aSRobert Mustacchi extern int lookupnameat(const char *, enum uio_seg, int follow,
877c478bd9Sstevel@tonic-gate 		vnode_t **, vnode_t **, vnode_t *);
88*5f61829aSRobert Mustacchi extern int lookupnameatcred(const char *, enum uio_seg, int follow,
897a142be9SCasper H.S. Dik 		vnode_t **, vnode_t **, vnode_t *, cred_t *);
90794f0adbSRoger A. Faulkner extern int lookuppn(struct pathname *, struct pathname *, int follow,
917c478bd9Sstevel@tonic-gate 		vnode_t **, vnode_t **);
92794f0adbSRoger A. Faulkner extern int lookuppnat(struct pathname *, struct pathname *, int follow,
937c478bd9Sstevel@tonic-gate 		vnode_t **, vnode_t **, vnode_t *);
94794f0adbSRoger A. Faulkner extern int lookuppnatcred(struct pathname *, struct pathname *, int follow,
957a142be9SCasper H.S. Dik 		vnode_t **, vnode_t **, vnode_t *, cred_t *);
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate extern int lookuppnvp(struct pathname *, struct pathname *, int follow,
987c478bd9Sstevel@tonic-gate 		vnode_t **, vnode_t **, vnode_t *, vnode_t *, cred_t *);
997c478bd9Sstevel@tonic-gate extern int traverse(vnode_t **);
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate extern int vnodetopath(vnode_t *, vnode_t *, char *, size_t, cred_t *);
1027c478bd9Sstevel@tonic-gate extern int dogetcwd(char *, size_t);
1037c478bd9Sstevel@tonic-gate extern int dirfindvp(vnode_t *, vnode_t *, vnode_t *, cred_t *, char *,
1047c478bd9Sstevel@tonic-gate 		size_t, dirent64_t **);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate #endif
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #endif	/* _SYS_PATHNAME_H */
111