vfs_subr.c (d98dc34f523c46cf3aa2c86a70166af88a26b2cb) | vfs_subr.c (a13234bb35c2671d47ec5b12eb613bb5d62121f2) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 59 unchanged lines hidden (view full) --- 68#include <sys/reboot.h> 69#include <sys/socket.h> 70#include <sys/stat.h> 71#include <sys/sysctl.h> 72#include <sys/vmmeter.h> 73#include <sys/vnode.h> 74 75#include <machine/limits.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 59 unchanged lines hidden (view full) --- 68#include <sys/reboot.h> 69#include <sys/socket.h> 70#include <sys/stat.h> 71#include <sys/sysctl.h> 72#include <sys/vmmeter.h> 73#include <sys/vnode.h> 74 75#include <machine/limits.h> |
76 | 76#include <net/radix.h> |
77#include <vm/vm.h> 78#include <vm/vm_object.h> 79#include <vm/vm_extern.h> 80#include <vm/pmap.h> 81#include <vm/vm_map.h> 82#include <vm/vm_page.h> 83#include <vm/vm_pager.h> 84#include <vm/vnode_pager.h> --- 169 unchanged lines hidden (view full) --- 254 &desiredvnodes, 0, "Maximum number of vnodes"); 255 256static void vfs_free_addrlist __P((struct netexport *nep)); 257static int vfs_free_netcred __P((struct radix_node *rn, void *w)); 258static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep, 259 struct export_args *argp)); 260 261/* | 77#include <vm/vm.h> 78#include <vm/vm_object.h> 79#include <vm/vm_extern.h> 80#include <vm/pmap.h> 81#include <vm/vm_map.h> 82#include <vm/vm_page.h> 83#include <vm/vm_pager.h> 84#include <vm/vnode_pager.h> --- 169 unchanged lines hidden (view full) --- 254 &desiredvnodes, 0, "Maximum number of vnodes"); 255 256static void vfs_free_addrlist __P((struct netexport *nep)); 257static int vfs_free_netcred __P((struct radix_node *rn, void *w)); 258static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep, 259 struct export_args *argp)); 260 261/* |
262 * Network address lookup element 263 */ 264struct netcred { 265 struct radix_node netc_rnodes[2]; 266 int netc_exflags; 267 struct ucred netc_anon; 268}; 269 270/* 271 * Network export information 272 */ 273struct netexport { 274 struct netcred ne_defexported; /* Default export */ 275 struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ 276}; 277 278/* |
|
262 * Initialize the vnode management data structures. 263 */ 264static void 265vntblinit(void *dummy __unused) 266{ 267 268 desiredvnodes = maxproc + cnt.v_page_count / 4; 269 mtx_init(&mountlist_mtx, "mountlist", MTX_DEF); --- 2173 unchanged lines hidden (view full) --- 2443 2444/* 2445 * High level function to manipulate export options on a mount point 2446 * and the passed in netexport. 2447 * Struct export_args *argp is the variable used to twiddle options, 2448 * the structure is described in sys/mount.h 2449 */ 2450int | 279 * Initialize the vnode management data structures. 280 */ 281static void 282vntblinit(void *dummy __unused) 283{ 284 285 desiredvnodes = maxproc + cnt.v_page_count / 4; 286 mtx_init(&mountlist_mtx, "mountlist", MTX_DEF); --- 2173 unchanged lines hidden (view full) --- 2460 2461/* 2462 * High level function to manipulate export options on a mount point 2463 * and the passed in netexport. 2464 * Struct export_args *argp is the variable used to twiddle options, 2465 * the structure is described in sys/mount.h 2466 */ 2467int |
2451vfs_export(mp, nep, argp) | 2468vfs_export(mp, argp) |
2452 struct mount *mp; | 2469 struct mount *mp; |
2453 struct netexport *nep; | |
2454 struct export_args *argp; 2455{ | 2470 struct export_args *argp; 2471{ |
2472 struct netexport *nep; |
|
2456 int error; 2457 | 2473 int error; 2474 |
2475 nep = mp->mnt_export; |
|
2458 if (argp->ex_flags & MNT_DELEXPORT) { | 2476 if (argp->ex_flags & MNT_DELEXPORT) { |
2477 if (nep == NULL) 2478 return (EINVAL); |
|
2459 if (mp->mnt_flag & MNT_EXPUBLIC) { 2460 vfs_setpublicfs(NULL, NULL, NULL); 2461 mp->mnt_flag &= ~MNT_EXPUBLIC; 2462 } 2463 vfs_free_addrlist(nep); | 2479 if (mp->mnt_flag & MNT_EXPUBLIC) { 2480 vfs_setpublicfs(NULL, NULL, NULL); 2481 mp->mnt_flag &= ~MNT_EXPUBLIC; 2482 } 2483 vfs_free_addrlist(nep); |
2484 mp->mnt_export = NULL; 2485 free(nep, M_MOUNT); |
|
2464 mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); 2465 } 2466 if (argp->ex_flags & MNT_EXPORTED) { | 2486 mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); 2487 } 2488 if (argp->ex_flags & MNT_EXPORTED) { |
2489 if (nep == NULL) { 2490 nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO); 2491 mp->mnt_export = nep; 2492 } |
|
2467 if (argp->ex_flags & MNT_EXPUBLIC) { 2468 if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) 2469 return (error); 2470 mp->mnt_flag |= MNT_EXPUBLIC; 2471 } 2472 if ((error = vfs_hang_addrlist(mp, nep, argp))) 2473 return (error); 2474 mp->mnt_flag |= MNT_EXPORTED; --- 83 unchanged lines hidden (view full) --- 2558 2559/* 2560 * Used by the filesystems to determine if a given network address 2561 * (passed in 'nam') is present in thier exports list, returns a pointer 2562 * to struct netcred so that the filesystem can examine it for 2563 * access rights (read/write/etc). 2564 */ 2565struct netcred * | 2493 if (argp->ex_flags & MNT_EXPUBLIC) { 2494 if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) 2495 return (error); 2496 mp->mnt_flag |= MNT_EXPUBLIC; 2497 } 2498 if ((error = vfs_hang_addrlist(mp, nep, argp))) 2499 return (error); 2500 mp->mnt_flag |= MNT_EXPORTED; --- 83 unchanged lines hidden (view full) --- 2584 2585/* 2586 * Used by the filesystems to determine if a given network address 2587 * (passed in 'nam') is present in thier exports list, returns a pointer 2588 * to struct netcred so that the filesystem can examine it for 2589 * access rights (read/write/etc). 2590 */ 2591struct netcred * |
2566vfs_export_lookup(mp, nep, nam) | 2592vfs_export_lookup(mp, nam) |
2567 register struct mount *mp; | 2593 register struct mount *mp; |
2568 struct netexport *nep; | |
2569 struct sockaddr *nam; 2570{ | 2594 struct sockaddr *nam; 2595{ |
2596 struct netexport *nep; |
|
2571 register struct netcred *np; 2572 register struct radix_node_head *rnh; 2573 struct sockaddr *saddr; 2574 | 2597 register struct netcred *np; 2598 register struct radix_node_head *rnh; 2599 struct sockaddr *saddr; 2600 |
2601 nep = mp->mnt_export; 2602 if (nep == NULL) 2603 return (NULL); |
|
2575 np = NULL; 2576 if (mp->mnt_flag & MNT_EXPORTED) { 2577 /* 2578 * Lookup in the export list first. 2579 */ 2580 if (nam != NULL) { 2581 saddr = nam; 2582 rnh = nep->ne_rtable[saddr->sa_family]; --- 588 unchanged lines hidden (view full) --- 3171 if (privused != NULL) 3172 *privused = 1; 3173 return (0); 3174 } 3175#endif 3176 3177 return ((acc_mode & VADMIN) ? EPERM : EACCES); 3178} | 2604 np = NULL; 2605 if (mp->mnt_flag & MNT_EXPORTED) { 2606 /* 2607 * Lookup in the export list first. 2608 */ 2609 if (nam != NULL) { 2610 saddr = nam; 2611 rnh = nep->ne_rtable[saddr->sa_family]; --- 588 unchanged lines hidden (view full) --- 3200 if (privused != NULL) 3201 *privused = 1; 3202 return (0); 3203 } 3204#endif 3205 3206 return ((acc_mode & VADMIN) ? EPERM : EACCES); 3207} |
3208 3209/* 3210 * XXX: This comment comes from the deprecated ufs_check_export() 3211 * XXX: and may not entirely apply, but lacking something better: 3212 * This is the generic part of fhtovp called after the underlying 3213 * filesystem has validated the file handle. 3214 * 3215 * Verify that a host should have access to a filesystem. 3216 */ 3217 3218int 3219vfs_stdcheckexp(mp, nam, extflagsp, credanonp) 3220 struct mount *mp; 3221 struct sockaddr *nam; 3222 int *extflagsp; 3223 struct ucred **credanonp; 3224{ 3225 struct netcred *np; 3226 3227 np = vfs_export_lookup(mp, nam); 3228 if (np == NULL) 3229 return (EACCES); 3230 *extflagsp = np->netc_exflags; 3231 *credanonp = &np->netc_anon; 3232 return (0); 3233} 3234 |
|