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 5*d67944fbSScott Rotondo * Common Development and Distribution License (the "License"). 6*d67944fbSScott Rotondo * 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 */ 217c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 227c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate /* 25*d67944fbSScott Rotondo * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_FS_NAMENODE_H 307c478bd9Sstevel@tonic-gate #define _SYS_FS_NAMENODE_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 337c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 34*d67944fbSScott Rotondo #include <sys/vfs_opreg.h> 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * This structure is used to pass a file descriptor from user 437c478bd9Sstevel@tonic-gate * level to the kernel. It is first used by fattach() and then 447c478bd9Sstevel@tonic-gate * be NAMEFS. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate struct namefd { 477c478bd9Sstevel@tonic-gate int fd; 487c478bd9Sstevel@tonic-gate }; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Each NAMEFS object is identified by a struct namenode/vnode pair. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate struct namenode { 557c478bd9Sstevel@tonic-gate struct vnode *nm_vnode; /* represents mounted file desc. */ 567c478bd9Sstevel@tonic-gate int nm_flag; /* flags defined below */ 577c478bd9Sstevel@tonic-gate struct vattr nm_vattr; /* attributes of mounted file desc. */ 587c478bd9Sstevel@tonic-gate struct vnode *nm_filevp; /* file desc. prior to mounting */ 597c478bd9Sstevel@tonic-gate struct file *nm_filep; /* file pointer of nm_filevp */ 607c478bd9Sstevel@tonic-gate struct vnode *nm_mountpt; /* mount point prior to mounting */ 617c478bd9Sstevel@tonic-gate struct namenode *nm_nextp; /* next link in the linked list */ 627c478bd9Sstevel@tonic-gate kmutex_t nm_lock; /* protects nm_vattr */ 637c478bd9Sstevel@tonic-gate }; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Valid flags for namenodes. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #define NMNMNT 0x01 /* namenode not mounted */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * Macros to convert a vnode to a namenode, and vice versa. 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate #define VTONM(vp) ((struct namenode *)((vp)->v_data)) 747c478bd9Sstevel@tonic-gate #define NMTOV(nm) ((nm)->nm_vnode) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate #define NM_FILEVP_HASH_SIZE 64 777c478bd9Sstevel@tonic-gate #define NM_FILEVP_HASH_MASK (NM_FILEVP_HASH_SIZE - 1) 787c478bd9Sstevel@tonic-gate #define NM_FILEVP_HASH_SHIFT 7 797c478bd9Sstevel@tonic-gate #define NM_FILEVP_HASH(vp) (&nm_filevp_hash[(((uintptr_t)vp) >> \ 807c478bd9Sstevel@tonic-gate NM_FILEVP_HASH_SHIFT) & NM_FILEVP_HASH_MASK]) 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate extern struct namenode *nm_filevp_hash[NM_FILEVP_HASH_SIZE]; 837c478bd9Sstevel@tonic-gate extern struct vfs namevfs; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate extern int nameinit(int, char *); 867c478bd9Sstevel@tonic-gate extern int nm_unmountall(struct vnode *, struct cred *); 877c478bd9Sstevel@tonic-gate extern void nameinsert(struct namenode *); 887c478bd9Sstevel@tonic-gate extern void nameremove(struct namenode *); 897c478bd9Sstevel@tonic-gate extern struct namenode *namefind(struct vnode *, struct vnode *); 907c478bd9Sstevel@tonic-gate extern uint64_t namenodeno_alloc(void); 917c478bd9Sstevel@tonic-gate extern void namenodeno_free(uint64_t); 927c478bd9Sstevel@tonic-gate extern struct vnodeops *nm_vnodeops; 937c478bd9Sstevel@tonic-gate extern const struct fs_operation_def nm_vnodeops_template[]; 947c478bd9Sstevel@tonic-gate extern kmutex_t ntable_lock; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #ifdef __cplusplus 997c478bd9Sstevel@tonic-gate } 1007c478bd9Sstevel@tonic-gate #endif 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #endif /* _SYS_FS_NAMENODE_H */ 103