namenode.h revision 9521:b061a79d3d1a
1226031Sstas/* 2226031Sstas * CDDL HEADER START 3226031Sstas * 4226031Sstas * The contents of this file are subject to the terms of the 5226031Sstas * Common Development and Distribution License, Version 1.0 only 6226031Sstas * (the "License"). You may not use this file except in compliance 7226031Sstas * with the License. 8226031Sstas * 9226031Sstas * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10226031Sstas * or http://www.opensolaris.org/os/licensing. 11226031Sstas * See the License for the specific language governing permissions 12226031Sstas * and limitations under the License. 13226031Sstas * 14226031Sstas * When distributing Covered Code, include this CDDL HEADER in each 15226031Sstas * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16226031Sstas * If applicable, add the following below this CDDL HEADER, with the 17226031Sstas * fields enclosed by brackets "[]" replaced with your own identifying 18226031Sstas * information: Portions Copyright [yyyy] [name of copyright owner] 19226031Sstas * 20226031Sstas * CDDL HEADER END 21226031Sstas */ 22226031Sstas/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23226031Sstas/* All Rights Reserved */ 24226031Sstas 25226031Sstas/* 26226031Sstas * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 27226031Sstas * Use is subject to license terms. 28226031Sstas */ 29226031Sstas 30226031Sstas#ifndef _SYS_FS_NAMENODE_H 31226031Sstas#define _SYS_FS_NAMENODE_H 32226031Sstas 33226031Sstas#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ 34226031Sstas 35226031Sstas#if defined(_KERNEL) 36226031Sstas#include <sys/vnode.h> 37226031Sstas#endif 38226031Sstas 39226031Sstas#ifdef __cplusplus 40226031Sstasextern "C" { 41226031Sstas#endif 42226031Sstas 43226031Sstas/* 44226031Sstas * This structure is used to pass a file descriptor from user 45226031Sstas * level to the kernel. It is first used by fattach() and then 46226031Sstas * be NAMEFS. 47226031Sstas */ 48226031Sstasstruct namefd { 49226031Sstas int fd; 50226031Sstas}; 51226031Sstas 52226031Sstas#if defined(_KERNEL) 53226031Sstas/* 54226031Sstas * Each NAMEFS object is identified by a struct namenode/vnode pair. 55226031Sstas */ 56226031Sstasstruct namenode { 57226031Sstas struct vnode *nm_vnode; /* represents mounted file desc. */ 58226031Sstas int nm_flag; /* flags defined below */ 59226031Sstas struct vattr nm_vattr; /* attributes of mounted file desc. */ 60226031Sstas struct vnode *nm_filevp; /* file desc. prior to mounting */ 61226031Sstas struct file *nm_filep; /* file pointer of nm_filevp */ 62226031Sstas struct vnode *nm_mountpt; /* mount point prior to mounting */ 63226031Sstas struct namenode *nm_nextp; /* next link in the linked list */ 64226031Sstas kmutex_t nm_lock; /* protects nm_vattr */ 65226031Sstas}; 66226031Sstas 67226031Sstas/* 68226031Sstas * Valid flags for namenodes. 69226031Sstas */ 70226031Sstas#define NMNMNT 0x01 /* namenode not mounted */ 71226031Sstas 72226031Sstas/* 73226031Sstas * Macros to convert a vnode to a namenode, and vice versa. 74226031Sstas */ 75226031Sstas#define VTONM(vp) ((struct namenode *)((vp)->v_data)) 76226031Sstas#define NMTOV(nm) ((nm)->nm_vnode) 77226031Sstas 78226031Sstas#define NM_FILEVP_HASH_SIZE 64 79226031Sstas#define NM_FILEVP_HASH_MASK (NM_FILEVP_HASH_SIZE - 1) 80226031Sstas#define NM_FILEVP_HASH_SHIFT 7 81226031Sstas#define NM_FILEVP_HASH(vp) (&nm_filevp_hash[(((uintptr_t)vp) >> \ 82226031Sstas NM_FILEVP_HASH_SHIFT) & NM_FILEVP_HASH_MASK]) 83226031Sstas 84226031Sstasextern struct namenode *nm_filevp_hash[NM_FILEVP_HASH_SIZE]; 85226031Sstasextern struct vfs namevfs; 86226031Sstas 87226031Sstasextern int nameinit(int, char *); 88226031Sstasextern int nm_unmountall(struct vnode *, struct cred *); 89226031Sstasextern void nameinsert(struct namenode *); 90226031Sstasextern void nameremove(struct namenode *); 91226031Sstasextern struct namenode *namefind(struct vnode *, struct vnode *); 92226031Sstasextern uint64_t namenodeno_alloc(void); 93226031Sstasextern void namenodeno_free(uint64_t); 94226031Sstasextern struct vnodeops *nm_vnodeops; 95226031Sstasextern const struct fs_operation_def nm_vnodeops_template[]; 96226031Sstasextern kmutex_t ntable_lock; 97226031Sstas 98226031Sstas#endif /* _KERNEL */ 99226031Sstas 100226031Sstas#ifdef __cplusplus 101226031Sstas} 102226031Sstas#endif 103226031Sstas 104226031Sstas#endif /* _SYS_FS_NAMENODE_H */ 105226031Sstas