namevfs.c revision 8c81938120fb4fc785845e4215fd40d7242c8077
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * CDDL HEADER START
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * The contents of this file are subject to the terms of the
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Common Development and Distribution License (the "License").
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * You may not use this file except in compliance with the License.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * or http://www.opensolaris.org/os/licensing.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * See the License for the specific language governing permissions
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * and limitations under the License.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * When distributing Covered Code, include this CDDL HEADER in each
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * fields enclosed by brackets "[]" replaced with your own identifying
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * information: Portions Copyright [yyyy] [name of copyright owner]
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * CDDL HEADER END
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Use is subject to license terms.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews/* All Rights Reserved */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R4 1.28 */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * This file supports the vfs operations for the NAMEFS file system.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Define global data structures.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsstruct namenode *nm_filevp_hash[NM_FILEVP_HASH_SIZE];
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsstatic vmem_t *nm_inoarena; /* vmem arena to allocate inode no's from */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Functions to allocate node id's starting from 1. Based on vmem routines.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * The vmem arena is extended in NM_INOQUANT chunks.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews vmem_alloc(nm_inoarena, 1, VM_NOSLEEP + VM_FIRSTFIT);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews (void) vmem_add(nm_inoarena, (void *)(vmem_size(nm_inoarena,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews VMEM_ALLOC | VMEM_FREE) + 1), NM_INOQUANT, VM_SLEEP);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews vmem_alloc(nm_inoarena, 1, VM_SLEEP + VM_FIRSTFIT);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews nm_inoarena = vmem_create("namefs_inodes", (void *)1, NM_INOQUANT, 1,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews mutex_init(&nm_inolock, NULL, MUTEX_DEFAULT, NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Insert a namenode into the nm_filevp_hash table.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Each link has a unique namenode with a unique nm_mountvp field.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * The nm_filevp field of the namenode need not be unique, since a
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * file descriptor may be mounted to multiple nodes at the same time.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * We hash on nm_filevp since that's what discriminates the searches
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * in namefind() and nm_unmountall().
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Remove a namenode from the hash table, if present.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews for (npp = NM_FILEVP_HASH(nodep->nm_filevp); (np = *npp) != NULL;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Search for a namenode that has a nm_filevp == vp and nm_mountpt == mnt.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * If mnt is NULL, return the first link with nm_filevp of vp.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Returns namenode pointer on success, NULL on failure.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews for (np = *NM_FILEVP_HASH(vp); np != NULL; np = np->nm_nextp)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * Force the unmouting of a file descriptor from ALL of the nodes
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * that it was mounted to.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * At the present time, the only usage for this routine is in the
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * event one end of a pipe was mounted. At the time the unmounted
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * end gets closed down, the mounted end is forced to be unmounted.
int error = 0;
int realerr = 0;
while (nodep) {
return (realerr);
int error;
return (error);
char *resource_name;
char *resource_nodetype;
int error = 0;
return (EINVAL);
return (EFAULT);
return (EBADF);
return (EBUSY);
return (ENOTSUP);
return (EINVAL);
return (EINVAL);
return (EBUSY);
goto out;
goto out;
goto out;
goto out;
goto out;
if (error == 0) {
out:
return (error);
return (ENOTSUP);
return (EPERM);
int error;
int dev;
if (error != 0) {
return (error);
if (error != 0) {
return (error);
if (error != 0) {
return (error);
dev = 0;
NULL,
_init(void)
_fini(void)
return (EBUSY);