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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * Portions of this source code were derived from Berkeley 4.3 BSD 32 * under license from the Regents of the University of California. 33 */ 34 35 #ifndef _SYS_PATHNAME_H 36 #define _SYS_PATHNAME_H 37 38 #pragma ident "%Z%%M% %I% %E% SMI" 39 40 #include <sys/vnode.h> 41 #include <sys/cred.h> 42 #include <sys/uio.h> 43 #include <sys/dirent.h> 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /* 50 * Pathname structure. 51 * System calls that operate on path names gather the path name 52 * from the system call into this structure and reduce it by 53 * peeling off translated components. If a symbolic link is 54 * encountered the new path name to be translated is also 55 * assembled in this structure. 56 * 57 * By convention pn_buf is not changed once it's been set to point 58 * to the underlying storage; routines which manipulate the pathname 59 * do so by changing pn_path and pn_pathlen. pn_pathlen is redundant 60 * since the path name is null-terminated, but is provided to make 61 * some computations faster. 62 */ 63 typedef struct pathname { 64 char *pn_buf; /* underlying storage */ 65 char *pn_path; /* remaining pathname */ 66 size_t pn_pathlen; /* remaining length */ 67 size_t pn_bufsize; /* total size of pn_buf */ 68 } pathname_t; 69 70 #define pn_pathleft(pnp) ((pnp)->pn_pathlen) 71 72 extern void pn_alloc(struct pathname *); 73 extern int pn_get(char *, enum uio_seg, struct pathname *); 74 extern int pn_get_buf(char *, enum uio_seg, struct pathname *, 75 void *, size_t); 76 extern int pn_set(struct pathname *, char *); 77 extern int pn_insert(struct pathname *, struct pathname *, size_t); 78 extern int pn_getsymlink(vnode_t *, struct pathname *, cred_t *); 79 extern int pn_getcomponent(struct pathname *, char *); 80 extern void pn_setlast(struct pathname *); 81 extern void pn_skipslash(struct pathname *); 82 extern int pn_fixslash(struct pathname *); 83 extern int pn_addslash(struct pathname *); 84 extern void pn_free(struct pathname *); 85 86 extern int lookupname(char *, enum uio_seg, enum symfollow, 87 vnode_t **, vnode_t **); 88 extern int lookupnameat(char *, enum uio_seg, enum symfollow, 89 vnode_t **, vnode_t **, vnode_t *); 90 extern int lookuppn(struct pathname *, struct pathname *, enum symfollow, 91 vnode_t **, vnode_t **); 92 extern int lookuppnat(struct pathname *, struct pathname *, enum symfollow, 93 vnode_t **, vnode_t **, vnode_t *); 94 95 extern int lookuppnvp(struct pathname *, struct pathname *, int follow, 96 vnode_t **, vnode_t **, vnode_t *, vnode_t *, cred_t *); 97 extern int traverse(vnode_t **); 98 99 extern int vnodetopath(vnode_t *, vnode_t *, char *, size_t, cred_t *); 100 extern int dogetcwd(char *, size_t); 101 extern int dirfindvp(vnode_t *, vnode_t *, vnode_t *, cred_t *, char *, 102 size_t, dirent64_t **); 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* _SYS_PATHNAME_H */ 109