fdesc_vnops.c (138270) | fdesc_vnops.c (138290) |
---|---|
1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software donated to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 33 * | 1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software donated to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 33 * |
34 * $FreeBSD: head/sys/fs/fdescfs/fdesc_vnops.c 138270 2004-12-01 12:24:41Z phk $ | 34 * $FreeBSD: head/sys/fs/fdescfs/fdesc_vnops.c 138290 2004-12-01 23:16:38Z phk $ |
35 */ 36 37/* 38 * /dev/fd Filesystem 39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> --- 12 unchanged lines hidden (view full) --- 55#include <sys/vnode.h> 56 57#include <fs/fdescfs/fdesc.h> 58 59#define FDL_WANT 0x01 60#define FDL_LOCKED 0x02 61static int fdcache_lock; 62 | 35 */ 36 37/* 38 * /dev/fd Filesystem 39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> --- 12 unchanged lines hidden (view full) --- 55#include <sys/vnode.h> 56 57#include <fs/fdescfs/fdesc.h> 58 59#define FDL_WANT 0x01 60#define FDL_LOCKED 0x02 61static int fdcache_lock; 62 |
63static vop_t **fdesc_vnodeop_p; 64 | |
65#define NFDCACHE 4 66#define FD_NHASH(ix) \ 67 (&fdhashtbl[(ix) & fdhash]) 68static LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl; 69static u_long fdhash; 70 71static vop_getattr_t fdesc_getattr; 72static vop_inactive_t fdesc_inactive; 73static vop_lookup_t fdesc_lookup; 74static vop_open_t fdesc_open; 75static vop_readdir_t fdesc_readdir; 76static vop_reclaim_t fdesc_reclaim; 77static vop_setattr_t fdesc_setattr; 78 | 63#define NFDCACHE 4 64#define FD_NHASH(ix) \ 65 (&fdhashtbl[(ix) & fdhash]) 66static LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl; 67static u_long fdhash; 68 69static vop_getattr_t fdesc_getattr; 70static vop_inactive_t fdesc_inactive; 71static vop_lookup_t fdesc_lookup; 72static vop_open_t fdesc_open; 73static vop_readdir_t fdesc_readdir; 74static vop_reclaim_t fdesc_reclaim; 75static vop_setattr_t fdesc_setattr; 76 |
77extern struct vop_vector fdesc_vnodeops; 78 |
|
79/* 80 * Initialise cache headers 81 */ 82int 83fdesc_init(vfsp) 84 struct vfsconf *vfsp; 85{ 86 --- 37 unchanged lines hidden (view full) --- 124 125 /* 126 * Do the MALLOC before the getnewvnode since doing so afterward 127 * might cause a bogus v_data pointer to get dereferenced 128 * elsewhere if MALLOC should block. 129 */ 130 MALLOC(fd, struct fdescnode *, sizeof(struct fdescnode), M_TEMP, M_WAITOK); 131 | 79/* 80 * Initialise cache headers 81 */ 82int 83fdesc_init(vfsp) 84 struct vfsconf *vfsp; 85{ 86 --- 37 unchanged lines hidden (view full) --- 124 125 /* 126 * Do the MALLOC before the getnewvnode since doing so afterward 127 * might cause a bogus v_data pointer to get dereferenced 128 * elsewhere if MALLOC should block. 129 */ 130 MALLOC(fd, struct fdescnode *, sizeof(struct fdescnode), M_TEMP, M_WAITOK); 131 |
132 error = getnewvnode("fdesc", mp, fdesc_vnodeop_p, vpp); | 132 error = getnewvnode("fdesc", mp, &fdesc_vnodeops, vpp); |
133 if (error) { 134 FREE(fd, M_TEMP); 135 goto out; 136 } 137 (*vpp)->v_data = fd; 138 fd->fd_vnode = *vpp; 139 fd->fd_type = ftype; 140 fd->fd_fd = -1; --- 373 unchanged lines hidden (view full) --- 514 515 LIST_REMOVE(fd, fd_hash); 516 FREE(vp->v_data, M_TEMP); 517 vp->v_data = 0; 518 519 return (0); 520} 521 | 133 if (error) { 134 FREE(fd, M_TEMP); 135 goto out; 136 } 137 (*vpp)->v_data = fd; 138 fd->fd_vnode = *vpp; 139 fd->fd_type = ftype; 140 fd->fd_fd = -1; --- 373 unchanged lines hidden (view full) --- 514 515 LIST_REMOVE(fd, fd_hash); 516 FREE(vp->v_data, M_TEMP); 517 vp->v_data = 0; 518 519 return (0); 520} 521 |
522static struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = { 523 { &vop_default_desc, (vop_t *) vop_defaultop }, 524 { &vop_access_desc, (vop_t *) vop_null }, 525 { &vop_getattr_desc, (vop_t *) fdesc_getattr }, 526 { &vop_inactive_desc, (vop_t *) fdesc_inactive }, 527 { &vop_lookup_desc, (vop_t *) fdesc_lookup }, 528 { &vop_open_desc, (vop_t *) fdesc_open }, 529 { &vop_pathconf_desc, (vop_t *) vop_stdpathconf }, 530 { &vop_readdir_desc, (vop_t *) fdesc_readdir }, 531 { &vop_reclaim_desc, (vop_t *) fdesc_reclaim }, 532 { &vop_setattr_desc, (vop_t *) fdesc_setattr }, 533 { NULL, NULL } | 522static struct vop_vector fdesc_vnodeops = { 523 .vop_default = &default_vnodeops, 524 .vop_access = VOP_NULL, 525 .vop_getattr = fdesc_getattr, 526 .vop_inactive = fdesc_inactive, 527 .vop_lookup = fdesc_lookup, 528 .vop_open = fdesc_open, 529 .vop_pathconf = vop_stdpathconf, 530 .vop_readdir = fdesc_readdir, 531 .vop_reclaim = fdesc_reclaim, 532 .vop_setattr = fdesc_setattr, |
534}; | 533}; |
535static struct vnodeopv_desc fdesc_vnodeop_opv_desc = 536 { &fdesc_vnodeop_p, fdesc_vnodeop_entries }; 537 538VNODEOP_SET(fdesc_vnodeop_opv_desc); | |