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