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 */ 21*794f0adbSRoger A. Faulkner 227c478bd9Sstevel@tonic-gate /* 23*794f0adbSRoger 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 */ 277c478bd9Sstevel@tonic-gate /* 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 *); 707c478bd9Sstevel@tonic-gate extern int pn_get(char *, enum uio_seg, struct pathname *); 717c478bd9Sstevel@tonic-gate extern int pn_get_buf(char *, enum uio_seg, struct pathname *, 727c478bd9Sstevel@tonic-gate void *, size_t); 737c478bd9Sstevel@tonic-gate extern int pn_set(struct pathname *, char *); 747c478bd9Sstevel@tonic-gate extern int pn_insert(struct pathname *, struct pathname *, size_t); 757c478bd9Sstevel@tonic-gate extern int pn_getsymlink(vnode_t *, struct pathname *, cred_t *); 767c478bd9Sstevel@tonic-gate extern int pn_getcomponent(struct pathname *, char *); 777c478bd9Sstevel@tonic-gate extern void pn_setlast(struct pathname *); 787c478bd9Sstevel@tonic-gate extern void pn_skipslash(struct pathname *); 797c478bd9Sstevel@tonic-gate extern int pn_fixslash(struct pathname *); 807c478bd9Sstevel@tonic-gate extern int pn_addslash(struct pathname *); 817c478bd9Sstevel@tonic-gate extern void pn_free(struct pathname *); 827c478bd9Sstevel@tonic-gate 83*794f0adbSRoger A. Faulkner extern int lookupname(char *, enum uio_seg, int follow, 847c478bd9Sstevel@tonic-gate vnode_t **, vnode_t **); 85*794f0adbSRoger A. Faulkner extern int lookupnameat(char *, enum uio_seg, int follow, 867c478bd9Sstevel@tonic-gate vnode_t **, vnode_t **, vnode_t *); 87*794f0adbSRoger A. Faulkner extern int lookupnameatcred(char *, enum uio_seg, int follow, 887a142be9SCasper H.S. Dik vnode_t **, vnode_t **, vnode_t *, cred_t *); 89*794f0adbSRoger A. Faulkner extern int lookuppn(struct pathname *, struct pathname *, int follow, 907c478bd9Sstevel@tonic-gate vnode_t **, vnode_t **); 91*794f0adbSRoger A. Faulkner extern int lookuppnat(struct pathname *, struct pathname *, int follow, 927c478bd9Sstevel@tonic-gate vnode_t **, vnode_t **, vnode_t *); 93*794f0adbSRoger A. Faulkner extern int lookuppnatcred(struct pathname *, struct pathname *, int follow, 947a142be9SCasper H.S. Dik vnode_t **, vnode_t **, vnode_t *, cred_t *); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate extern int lookuppnvp(struct pathname *, struct pathname *, int follow, 977c478bd9Sstevel@tonic-gate vnode_t **, vnode_t **, vnode_t *, vnode_t *, cred_t *); 987c478bd9Sstevel@tonic-gate extern int traverse(vnode_t **); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern int vnodetopath(vnode_t *, vnode_t *, char *, size_t, cred_t *); 1017c478bd9Sstevel@tonic-gate extern int dogetcwd(char *, size_t); 1027c478bd9Sstevel@tonic-gate extern int dirfindvp(vnode_t *, vnode_t *, vnode_t *, cred_t *, char *, 1037c478bd9Sstevel@tonic-gate size_t, dirent64_t **); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate #endif 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #endif /* _SYS_PATHNAME_H */ 110