1998-08-13 14:06:31 +04:00
|
|
|
/* $NetBSD: fdesc_vnops.c,v 1.47 1998/08/13 10:06:32 kleink Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1993-03-24 02:56:31 +03:00
|
|
|
/*
|
1994-06-08 15:33:09 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-24 02:56:31 +03:00
|
|
|
*
|
1994-01-05 12:00:57 +03:00
|
|
|
* This code is derived from software donated to Berkeley by
|
1993-03-24 02:56:31 +03:00
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
changed copyright notice thanks to following statement:
Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...
You may put this copyright message on the source code:
/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
1993-03-25 09:00:17 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1994-01-05 12:00:57 +03:00
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
changed copyright notice thanks to following statement:
Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...
You may put this copyright message on the source code:
/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
1993-03-25 09:00:17 +03:00
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
1993-03-24 02:56:31 +03:00
|
|
|
*
|
changed copyright notice thanks to following statement:
Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...
You may put this copyright message on the source code:
/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
1993-03-25 09:00:17 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1993-03-24 02:56:31 +03:00
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)fdesc_vnops.c 8.17 (Berkeley) 5/22/95
|
1994-12-13 12:58:11 +03:00
|
|
|
*
|
|
|
|
* #Id: fdesc_vnops.c,v 1.12 1993/04/06 16:17:17 jsp Exp #
|
1993-03-24 02:56:31 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* /dev/fd Filesystem
|
|
|
|
*/
|
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/kernel.h> /* boottime */
|
|
|
|
#include <sys/resourcevar.h>
|
1996-02-10 01:39:56 +03:00
|
|
|
#include <sys/socketvar.h>
|
1994-01-05 12:00:57 +03:00
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/vnode.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <sys/malloc.h>
|
1996-04-11 15:24:29 +04:00
|
|
|
#include <sys/conf.h>
|
1994-01-05 12:00:57 +03:00
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/buf.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <sys/dirent.h>
|
1996-02-10 01:39:56 +03:00
|
|
|
#include <sys/tty.h>
|
1996-09-02 03:47:48 +04:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
#include <miscfs/fdesc/fdesc.h>
|
1996-09-02 03:47:48 +04:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
#define FDL_WANT 0x01
|
|
|
|
#define FDL_LOCKED 0x02
|
1994-06-08 15:33:09 +04:00
|
|
|
static int fdcache_lock;
|
|
|
|
|
|
|
|
dev_t devctty;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
#if (FD_STDIN != FD_STDOUT-1) || (FD_STDOUT != FD_STDERR-1)
|
|
|
|
FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
|
|
|
|
#endif
|
|
|
|
|
1994-07-15 00:58:28 +04:00
|
|
|
#define NFDCACHE 4
|
1994-06-08 15:33:09 +04:00
|
|
|
|
1994-08-19 15:25:29 +04:00
|
|
|
#define FD_NHASH(ix) \
|
|
|
|
(&fdhashtbl[(ix) & fdhash])
|
|
|
|
LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl;
|
|
|
|
u_long fdhash;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_lookup __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_create genfs_eopnotsupp
|
|
|
|
#define fdesc_mknod genfs_eopnotsupp
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_open __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_close genfs_nullop
|
|
|
|
#define fdesc_access genfs_nullop
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_getattr __P((void *));
|
|
|
|
int fdesc_setattr __P((void *));
|
|
|
|
int fdesc_read __P((void *));
|
|
|
|
int fdesc_write __P((void *));
|
|
|
|
int fdesc_ioctl __P((void *));
|
1996-09-07 16:40:22 +04:00
|
|
|
int fdesc_poll __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_mmap genfs_eopnotsupp
|
|
|
|
#define fdesc_fsync genfs_nullop
|
1997-04-17 02:43:41 +04:00
|
|
|
#define fdesc_seek genfs_seek
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_remove genfs_eopnotsupp
|
1996-02-13 16:12:48 +03:00
|
|
|
int fdesc_link __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_rename genfs_eopnotsupp
|
|
|
|
#define fdesc_mkdir genfs_eopnotsupp
|
|
|
|
#define fdesc_rmdir genfs_eopnotsupp
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_symlink __P((void *));
|
|
|
|
int fdesc_readdir __P((void *));
|
|
|
|
int fdesc_readlink __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_abortop genfs_abortop
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_inactive __P((void *));
|
|
|
|
int fdesc_reclaim __P((void *));
|
1998-03-01 05:20:01 +03:00
|
|
|
#define fdesc_lock genfs_nolock
|
|
|
|
#define fdesc_unlock genfs_nounlock
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_bmap genfs_badop
|
|
|
|
#define fdesc_strategy genfs_badop
|
1996-02-10 01:39:56 +03:00
|
|
|
int fdesc_print __P((void *));
|
|
|
|
int fdesc_pathconf __P((void *));
|
1998-03-01 05:20:01 +03:00
|
|
|
#define fdesc_islocked genfs_noislocked
|
1998-08-13 14:06:31 +04:00
|
|
|
#define fdesc_advlock genfs_einval
|
1996-09-02 03:47:48 +04:00
|
|
|
#define fdesc_blkatoff genfs_eopnotsupp
|
|
|
|
#define fdesc_valloc genfs_eopnotsupp
|
|
|
|
#define fdesc_vfree genfs_nullop
|
|
|
|
#define fdesc_truncate genfs_eopnotsupp
|
|
|
|
#define fdesc_update genfs_nullop
|
|
|
|
#define fdesc_bwrite genfs_eopnotsupp
|
1998-03-01 05:20:01 +03:00
|
|
|
#define fdesc_revoke genfs_revoke
|
1996-02-10 01:39:56 +03:00
|
|
|
|
|
|
|
static int fdesc_attr __P((int, struct vattr *, struct ucred *, struct proc *));
|
|
|
|
|
|
|
|
int (**fdesc_vnodeop_p) __P((void *));
|
|
|
|
struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = {
|
|
|
|
{ &vop_default_desc, vn_default_error },
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_lookup_desc, fdesc_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, fdesc_create }, /* create */
|
|
|
|
{ &vop_mknod_desc, fdesc_mknod }, /* mknod */
|
|
|
|
{ &vop_open_desc, fdesc_open }, /* open */
|
|
|
|
{ &vop_close_desc, fdesc_close }, /* close */
|
|
|
|
{ &vop_access_desc, fdesc_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, fdesc_getattr }, /* getattr */
|
|
|
|
{ &vop_setattr_desc, fdesc_setattr }, /* setattr */
|
|
|
|
{ &vop_read_desc, fdesc_read }, /* read */
|
|
|
|
{ &vop_write_desc, fdesc_write }, /* write */
|
|
|
|
{ &vop_ioctl_desc, fdesc_ioctl }, /* ioctl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, fdesc_poll }, /* poll */
|
1998-03-01 05:20:01 +03:00
|
|
|
{ &vop_revoke_desc, fdesc_revoke }, /* revoke */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_mmap_desc, fdesc_mmap }, /* mmap */
|
|
|
|
{ &vop_fsync_desc, fdesc_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, fdesc_seek }, /* seek */
|
|
|
|
{ &vop_remove_desc, fdesc_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, fdesc_link }, /* link */
|
|
|
|
{ &vop_rename_desc, fdesc_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, fdesc_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, fdesc_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, fdesc_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, fdesc_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, fdesc_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, fdesc_abortop }, /* abortop */
|
|
|
|
{ &vop_inactive_desc, fdesc_inactive }, /* inactive */
|
|
|
|
{ &vop_reclaim_desc, fdesc_reclaim }, /* reclaim */
|
|
|
|
{ &vop_lock_desc, fdesc_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, fdesc_unlock }, /* unlock */
|
|
|
|
{ &vop_bmap_desc, fdesc_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, fdesc_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, fdesc_print }, /* print */
|
|
|
|
{ &vop_islocked_desc, fdesc_islocked }, /* islocked */
|
|
|
|
{ &vop_pathconf_desc, fdesc_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, fdesc_advlock }, /* advlock */
|
|
|
|
{ &vop_blkatoff_desc, fdesc_blkatoff }, /* blkatoff */
|
|
|
|
{ &vop_valloc_desc, fdesc_valloc }, /* valloc */
|
|
|
|
{ &vop_vfree_desc, fdesc_vfree }, /* vfree */
|
|
|
|
{ &vop_truncate_desc, fdesc_truncate }, /* truncate */
|
|
|
|
{ &vop_update_desc, fdesc_update }, /* update */
|
|
|
|
{ &vop_bwrite_desc, fdesc_bwrite }, /* bwrite */
|
1996-02-10 01:39:56 +03:00
|
|
|
{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vnodeopv_desc fdesc_vnodeop_opv_desc =
|
|
|
|
{ &fdesc_vnodeop_p, fdesc_vnodeop_entries };
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Initialise cache headers
|
|
|
|
*/
|
1996-02-10 01:39:56 +03:00
|
|
|
void
|
1994-06-08 15:33:09 +04:00
|
|
|
fdesc_init()
|
|
|
|
{
|
1996-04-11 15:24:29 +04:00
|
|
|
int cttymajor;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
1996-04-11 15:24:29 +04:00
|
|
|
/* locate the major number */
|
|
|
|
for (cttymajor = 0; cttymajor < nchrdev; cttymajor++)
|
|
|
|
if (cdevsw[cttymajor].d_open == cttyopen)
|
|
|
|
break;
|
|
|
|
devctty = makedev(cttymajor, 0);
|
1998-02-07 05:44:44 +03:00
|
|
|
fdhashtbl = hashinit(NFDCACHE, M_CACHE, M_NOWAIT, &fdhash);
|
1994-06-08 15:33:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-01-05 12:00:57 +03:00
|
|
|
fdesc_allocvp(ftype, ix, mp, vpp)
|
|
|
|
fdntype ftype;
|
|
|
|
int ix;
|
|
|
|
struct mount *mp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
1994-08-19 15:25:29 +04:00
|
|
|
struct fdhashhead *fc;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct fdescnode *fd;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error = 0;
|
|
|
|
|
1994-08-19 15:25:29 +04:00
|
|
|
fc = FD_NHASH(ix);
|
1994-01-05 12:00:57 +03:00
|
|
|
loop:
|
1994-08-19 15:25:29 +04:00
|
|
|
for (fd = fc->lh_first; fd != 0; fd = fd->fd_hash.le_next) {
|
1994-06-08 15:33:09 +04:00
|
|
|
if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {
|
|
|
|
if (vget(fd->fd_vnode, 0))
|
1994-01-05 12:00:57 +03:00
|
|
|
goto loop;
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = fd->fd_vnode;
|
1994-01-05 12:00:57 +03:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* otherwise lock the array while we call getnewvnode
|
|
|
|
* since that can block.
|
|
|
|
*/
|
1994-06-08 15:33:09 +04:00
|
|
|
if (fdcache_lock & FDL_LOCKED) {
|
|
|
|
fdcache_lock |= FDL_WANT;
|
|
|
|
sleep((caddr_t) &fdcache_lock, PINOD);
|
1994-01-05 12:00:57 +03:00
|
|
|
goto loop;
|
|
|
|
}
|
1994-06-08 15:33:09 +04:00
|
|
|
fdcache_lock |= FDL_LOCKED;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
error = getnewvnode(VT_FDESC, mp, fdesc_vnodeop_p, vpp);
|
1994-01-05 12:00:57 +03:00
|
|
|
if (error)
|
|
|
|
goto out;
|
1994-06-08 15:33:09 +04:00
|
|
|
MALLOC(fd, void *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
|
|
|
|
(*vpp)->v_data = fd;
|
|
|
|
fd->fd_vnode = *vpp;
|
|
|
|
fd->fd_type = ftype;
|
|
|
|
fd->fd_fd = -1;
|
|
|
|
fd->fd_link = 0;
|
|
|
|
fd->fd_ix = ix;
|
1994-08-19 15:25:29 +04:00
|
|
|
LIST_INSERT_HEAD(fc, fd, fd_hash);
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
out:;
|
1994-06-08 15:33:09 +04:00
|
|
|
fdcache_lock &= ~FDL_LOCKED;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
if (fdcache_lock & FDL_WANT) {
|
|
|
|
fdcache_lock &= ~FDL_WANT;
|
|
|
|
wakeup((caddr_t) &fdcache_lock);
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* vp is the current namei directory
|
|
|
|
* ndp is the name to locate in that directory...
|
|
|
|
*/
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_lookup(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_lookup_args /* {
|
|
|
|
struct vnode * a_dvp;
|
|
|
|
struct vnode ** a_vpp;
|
|
|
|
struct componentname * a_cnp;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
struct vnode *dvp = ap->a_dvp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct componentname *cnp = ap->a_cnp;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
const char *pname = cnp->cn_nameptr;
|
|
|
|
int nfiles = p->p_fd->fd_nfiles;
|
1996-02-10 01:39:56 +03:00
|
|
|
unsigned fd = 0;
|
1993-03-24 02:56:31 +03:00
|
|
|
int error;
|
|
|
|
struct vnode *fvp;
|
1994-01-05 12:00:57 +03:00
|
|
|
char *ln;
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (cnp->cn_namelen == 1 && *pname == '.') {
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = dvp;
|
1998-03-01 05:20:01 +03:00
|
|
|
VREF(dvp);
|
|
|
|
vn_lock(dvp, LK_SHARED | LK_RETRY);
|
1993-03-24 02:56:31 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
switch (VTOFDESC(dvp)->fd_type) {
|
|
|
|
default:
|
|
|
|
case Flink:
|
|
|
|
case Fdesc:
|
|
|
|
case Fctty:
|
|
|
|
error = ENOTDIR;
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
case Froot:
|
1998-08-10 00:51:08 +04:00
|
|
|
if (cnp->cn_namelen == 2 && memcmp(pname, "fd", 2) == 0) {
|
1994-01-05 12:00:57 +03:00
|
|
|
error = fdesc_allocvp(Fdevfd, FD_DEVFD, dvp->v_mount, &fvp);
|
|
|
|
if (error)
|
|
|
|
goto bad;
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = fvp;
|
1994-01-05 12:00:57 +03:00
|
|
|
fvp->v_type = VDIR;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(dvp, LK_SHARED | LK_RETRY);
|
1994-01-05 12:00:57 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-08-10 00:51:08 +04:00
|
|
|
if (cnp->cn_namelen == 3 && memcmp(pname, "tty", 3) == 0) {
|
1994-01-05 12:00:57 +03:00
|
|
|
struct vnode *ttyvp = cttyvp(p);
|
|
|
|
if (ttyvp == NULL) {
|
|
|
|
error = ENXIO;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
error = fdesc_allocvp(Fctty, FD_CTTY, dvp->v_mount, &fvp);
|
|
|
|
if (error)
|
|
|
|
goto bad;
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = fvp;
|
1996-04-11 15:24:29 +04:00
|
|
|
fvp->v_type = VCHR;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(dvp, LK_SHARED | LK_RETRY);
|
1994-01-05 12:00:57 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ln = 0;
|
1998-03-01 05:20:01 +03:00
|
|
|
switch (cnp->cn_namelen) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case 5:
|
1998-08-10 00:51:08 +04:00
|
|
|
if (memcmp(pname, "stdin", 5) == 0) {
|
1994-01-05 12:00:57 +03:00
|
|
|
ln = "fd/0";
|
|
|
|
fd = FD_STDIN;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
1994-01-05 12:00:57 +03:00
|
|
|
case 6:
|
1998-08-10 00:51:08 +04:00
|
|
|
if (memcmp(pname, "stdout", 6) == 0) {
|
1994-01-05 12:00:57 +03:00
|
|
|
ln = "fd/1";
|
|
|
|
fd = FD_STDOUT;
|
|
|
|
} else
|
1998-08-10 00:51:08 +04:00
|
|
|
if (memcmp(pname, "stderr", 6) == 0) {
|
1994-01-05 12:00:57 +03:00
|
|
|
ln = "fd/2";
|
|
|
|
fd = FD_STDERR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
if (ln) {
|
|
|
|
error = fdesc_allocvp(Flink, fd, dvp->v_mount, &fvp);
|
|
|
|
if (error)
|
|
|
|
goto bad;
|
|
|
|
VTOFDESC(fvp)->fd_link = ln;
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = fvp;
|
1994-01-05 12:00:57 +03:00
|
|
|
fvp->v_type = VLNK;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(fvp, LK_SHARED | LK_RETRY);
|
1994-01-05 12:00:57 +03:00
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
error = ENOENT;
|
|
|
|
goto bad;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/* FALL THROUGH */
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fdevfd:
|
1998-08-10 00:51:08 +04:00
|
|
|
if (cnp->cn_namelen == 2 && memcmp(pname, "..", 2) == 0) {
|
1994-06-08 15:33:09 +04:00
|
|
|
error = fdesc_root(dvp->v_mount, vpp);
|
1998-03-01 05:20:01 +03:00
|
|
|
if (error)
|
|
|
|
goto bad;
|
|
|
|
return (0);
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fd = 0;
|
|
|
|
while (*pname >= '0' && *pname <= '9') {
|
|
|
|
fd = 10 * fd + *pname++ - '0';
|
|
|
|
if (fd >= nfiles)
|
|
|
|
break;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
if (*pname != '\0') {
|
|
|
|
error = ENOENT;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fd >= nfiles || p->p_fd->fd_ofiles[fd] == NULL) {
|
|
|
|
error = EBADF;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
|
|
|
|
if (error)
|
|
|
|
goto bad;
|
|
|
|
VTOFDESC(fvp)->fd_fd = fd;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(dvp, LK_SHARED | LK_RETRY);
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = fvp;
|
1994-01-05 12:00:57 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
|
|
|
bad:;
|
1998-03-01 05:20:01 +03:00
|
|
|
vn_lock(dvp, LK_SHARED | LK_RETRY);
|
1994-06-08 15:33:09 +04:00
|
|
|
*vpp = NULL;
|
1993-03-24 02:56:31 +03:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_open(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_open_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_mode;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
switch (VTOFDESC(vp)->fd_type) {
|
|
|
|
case Fdesc:
|
1994-12-14 21:40:27 +03:00
|
|
|
/*
|
|
|
|
* XXX Kludge: set p->p_dupfd to contain the value of the
|
|
|
|
* the file descriptor being sought for duplication. The error
|
|
|
|
* return ensures that the vnode for this device will be
|
|
|
|
* released by vn_open. Open will detect this special error and
|
|
|
|
* take the actions in dupfdopen. Other callers of vn_open or
|
|
|
|
* VOP_OPEN will simply report the error.
|
|
|
|
*/
|
|
|
|
ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
|
|
|
|
return (ENODEV);
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
1994-12-04 06:13:06 +03:00
|
|
|
return (cttyopen(devctty, ap->a_mode, 0, ap->a_p));
|
1996-02-10 01:39:56 +03:00
|
|
|
case Froot:
|
|
|
|
case Fdevfd:
|
|
|
|
case Flink:
|
|
|
|
break;
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-12-04 06:13:06 +03:00
|
|
|
return (0);
|
1993-03-24 02:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fdesc_attr(fd, vap, cred, p)
|
|
|
|
int fd;
|
|
|
|
struct vattr *vap;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct filedesc *fdp = p->p_fd;
|
|
|
|
struct file *fp;
|
1994-01-05 12:00:57 +03:00
|
|
|
struct stat stb;
|
1993-03-24 02:56:31 +03:00
|
|
|
int error;
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
|
1993-03-24 02:56:31 +03:00
|
|
|
return (EBADF);
|
|
|
|
|
|
|
|
switch (fp->f_type) {
|
|
|
|
case DTYPE_VNODE:
|
|
|
|
error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred, p);
|
1994-01-05 12:00:57 +03:00
|
|
|
if (error == 0 && vap->va_type == VDIR) {
|
|
|
|
/*
|
1994-12-13 12:58:11 +03:00
|
|
|
* directories can cause loops in the namespace,
|
|
|
|
* so turn off the 'x' bits to avoid trouble.
|
1994-01-05 12:00:57 +03:00
|
|
|
*/
|
1997-05-05 11:13:57 +04:00
|
|
|
vap->va_mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DTYPE_SOCKET:
|
1994-01-05 12:00:57 +03:00
|
|
|
error = soo_stat((struct socket *)fp->f_data, &stb);
|
|
|
|
if (error == 0) {
|
|
|
|
vattr_null(vap);
|
|
|
|
vap->va_type = VSOCK;
|
|
|
|
vap->va_mode = stb.st_mode;
|
|
|
|
vap->va_nlink = stb.st_nlink;
|
|
|
|
vap->va_uid = stb.st_uid;
|
|
|
|
vap->va_gid = stb.st_gid;
|
|
|
|
vap->va_fsid = stb.st_dev;
|
|
|
|
vap->va_fileid = stb.st_ino;
|
|
|
|
vap->va_size = stb.st_size;
|
|
|
|
vap->va_blocksize = stb.st_blksize;
|
1994-04-25 07:49:27 +04:00
|
|
|
vap->va_atime = stb.st_atimespec;
|
|
|
|
vap->va_mtime = stb.st_mtimespec;
|
|
|
|
vap->va_ctime = stb.st_ctimespec;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_gen = stb.st_gen;
|
|
|
|
vap->va_flags = stb.st_flags;
|
|
|
|
vap->va_rdev = stb.st_rdev;
|
|
|
|
vap->va_bytes = stb.st_blocks * stb.st_blksize;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("fdesc attr");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_getattr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct vattr *vap = ap->a_vap;
|
1993-03-24 02:56:31 +03:00
|
|
|
unsigned fd;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error = 0;
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
switch (VTOFDESC(vp)->fd_type) {
|
|
|
|
case Froot:
|
|
|
|
case Fdevfd:
|
|
|
|
case Flink:
|
|
|
|
case Fctty:
|
1996-06-14 13:27:23 +04:00
|
|
|
VATTR_NULL(vap);
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_fileid = VTOFDESC(vp)->fd_ix;
|
|
|
|
|
1996-02-10 01:39:56 +03:00
|
|
|
#define R_ALL (S_IRUSR|S_IRGRP|S_IROTH)
|
|
|
|
#define W_ALL (S_IWUSR|S_IWGRP|S_IWOTH)
|
|
|
|
#define X_ALL (S_IXUSR|S_IXGRP|S_IXOTH)
|
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
switch (VTOFDESC(vp)->fd_type) {
|
|
|
|
case Flink:
|
1996-02-10 01:39:56 +03:00
|
|
|
vap->va_mode = R_ALL|X_ALL;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_type = VLNK;
|
1996-04-11 15:24:29 +04:00
|
|
|
vap->va_rdev = 0;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_nlink = 1;
|
|
|
|
vap->va_size = strlen(VTOFDESC(vp)->fd_link);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Fctty:
|
1996-02-10 01:39:56 +03:00
|
|
|
vap->va_mode = R_ALL|W_ALL;
|
1996-04-11 15:24:29 +04:00
|
|
|
vap->va_type = VCHR;
|
|
|
|
vap->va_rdev = devctty;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_nlink = 1;
|
|
|
|
vap->va_size = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1996-02-10 01:39:56 +03:00
|
|
|
vap->va_mode = R_ALL|X_ALL;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_type = VDIR;
|
1996-04-11 15:24:29 +04:00
|
|
|
vap->va_rdev = 0;
|
1994-01-05 12:00:57 +03:00
|
|
|
vap->va_nlink = 2;
|
|
|
|
vap->va_size = DEV_BSIZE;
|
|
|
|
break;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
vap->va_uid = 0;
|
|
|
|
vap->va_gid = 0;
|
|
|
|
vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
|
|
|
|
vap->va_blocksize = DEV_BSIZE;
|
1996-02-01 03:31:05 +03:00
|
|
|
vap->va_atime.tv_sec = boottime.tv_sec;
|
|
|
|
vap->va_atime.tv_nsec = 0;
|
1993-03-24 02:56:31 +03:00
|
|
|
vap->va_mtime = vap->va_atime;
|
1994-06-08 15:33:09 +04:00
|
|
|
vap->va_ctime = vap->va_mtime;
|
1993-03-24 02:56:31 +03:00
|
|
|
vap->va_gen = 0;
|
|
|
|
vap->va_flags = 0;
|
|
|
|
vap->va_bytes = 0;
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Fdesc:
|
|
|
|
fd = VTOFDESC(vp)->fd_fd;
|
1994-06-08 15:33:09 +04:00
|
|
|
error = fdesc_attr(fd, vap, ap->a_cred, ap->a_p);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("fdesc_getattr");
|
|
|
|
break;
|
1993-03-24 02:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (error == 0)
|
|
|
|
vp->v_type = vap->va_type;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1993-03-24 02:56:31 +03:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_setattr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_setattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct filedesc *fdp = ap->a_p->p_fd;
|
1993-03-24 02:56:31 +03:00
|
|
|
struct file *fp;
|
|
|
|
unsigned fd;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Can't mess with the root vnode
|
|
|
|
*/
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fdesc:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Fctty:
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
default:
|
1993-03-24 02:56:31 +03:00
|
|
|
return (EACCES);
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
fd = VTOFDESC(ap->a_vp)->fd_fd;
|
1993-03-24 02:56:31 +03:00
|
|
|
if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
|
|
|
|
return (EBADF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Can setattr the underlying vnode, but not sockets!
|
|
|
|
*/
|
|
|
|
switch (fp->f_type) {
|
|
|
|
case DTYPE_VNODE:
|
1994-06-08 15:33:09 +04:00
|
|
|
error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap, ap->a_cred, ap->a_p);
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DTYPE_SOCKET:
|
1994-06-08 15:33:09 +04:00
|
|
|
error = 0;
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("fdesc setattr");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
#define UIO_MX 32
|
|
|
|
|
|
|
|
struct fdesc_target {
|
|
|
|
ino_t ft_fileno;
|
|
|
|
u_char ft_type;
|
|
|
|
u_char ft_namlen;
|
|
|
|
char *ft_name;
|
|
|
|
} fdesc_targets[] = {
|
|
|
|
/* NOTE: The name must be less than UIO_MX-16 chars in length */
|
|
|
|
#define N(s) sizeof(s)-1, s
|
|
|
|
{ FD_DEVFD, DT_DIR, N("fd") },
|
1995-10-09 17:20:04 +03:00
|
|
|
{ FD_STDIN, DT_LNK, N("stdin") },
|
|
|
|
{ FD_STDOUT, DT_LNK, N("stdout") },
|
|
|
|
{ FD_STDERR, DT_LNK, N("stderr") },
|
1995-10-09 14:18:51 +03:00
|
|
|
{ FD_CTTY, DT_UNKNOWN, N("tty") },
|
|
|
|
#undef N
|
1994-01-05 12:00:57 +03:00
|
|
|
};
|
1995-10-09 14:18:51 +03:00
|
|
|
static int nfdesc_targets = sizeof(fdesc_targets) / sizeof(fdesc_targets[0]);
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_readdir(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_readdir_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
1994-12-13 12:58:11 +03:00
|
|
|
int *a_eofflag;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t **a_cookies;
|
|
|
|
int *a_ncookies;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct uio *uio = ap->a_uio;
|
1995-10-09 14:18:51 +03:00
|
|
|
struct dirent d;
|
1993-03-24 02:56:31 +03:00
|
|
|
struct filedesc *fdp;
|
1994-01-05 12:00:57 +03:00
|
|
|
int i;
|
1993-03-24 02:56:31 +03:00
|
|
|
int error;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t *cookies = NULL;
|
|
|
|
int ncookies = 0;
|
1994-12-13 12:58:11 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
case Fdesc:
|
|
|
|
return (ENOTDIR);
|
1996-02-10 01:39:56 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
|
|
|
fdp = uio->uio_procp->p_fd;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
if (uio->uio_resid < UIO_MX)
|
|
|
|
return (EINVAL);
|
1995-10-09 17:03:32 +03:00
|
|
|
if (uio->uio_offset < 0)
|
1995-10-09 14:18:51 +03:00
|
|
|
return (EINVAL);
|
1993-03-30 09:16:56 +04:00
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
error = 0;
|
1995-10-09 17:03:32 +03:00
|
|
|
i = uio->uio_offset;
|
1998-08-10 00:51:08 +04:00
|
|
|
memset((caddr_t)&d, 0, UIO_MX);
|
1995-10-09 14:18:51 +03:00
|
|
|
d.d_reclen = UIO_MX;
|
1998-03-01 05:20:01 +03:00
|
|
|
if (ap->a_ncookies)
|
|
|
|
ncookies = (uio->uio_resid / UIO_MX);
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
if (VTOFDESC(ap->a_vp)->fd_type == Froot) {
|
|
|
|
struct fdesc_target *ft;
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (ap->a_ncookies) {
|
|
|
|
ncookies = min(ncookies, (nfdesc_targets - i));
|
|
|
|
MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
|
|
|
|
M_TEMP, M_WAITOK);
|
|
|
|
*ap->a_cookies = cookies;
|
|
|
|
*ap->a_ncookies = ncookies;
|
|
|
|
}
|
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
for (ft = &fdesc_targets[i];
|
|
|
|
uio->uio_resid >= UIO_MX && i < nfdesc_targets; ft++, i++) {
|
|
|
|
switch (ft->ft_fileno) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case FD_CTTY:
|
|
|
|
if (cttyvp(uio->uio_procp) == NULL)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FD_STDIN:
|
|
|
|
case FD_STDOUT:
|
|
|
|
case FD_STDERR:
|
1995-10-09 14:18:51 +03:00
|
|
|
if ((ft->ft_fileno - FD_STDIN) >= fdp->fd_nfiles)
|
1994-01-05 12:00:57 +03:00
|
|
|
continue;
|
1995-10-09 14:18:51 +03:00
|
|
|
if (fdp->fd_ofiles[ft->ft_fileno - FD_STDIN] == NULL)
|
1994-01-05 12:00:57 +03:00
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
1994-06-08 15:33:09 +04:00
|
|
|
|
1995-10-09 14:18:51 +03:00
|
|
|
d.d_fileno = ft->ft_fileno;
|
|
|
|
d.d_namlen = ft->ft_namlen;
|
1998-08-10 00:51:08 +04:00
|
|
|
memcpy(d.d_name, ft->ft_name, ft->ft_namlen + 1);
|
1995-10-09 14:18:51 +03:00
|
|
|
d.d_type = ft->ft_type;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
1996-02-10 01:39:56 +03:00
|
|
|
if ((error = uiomove((caddr_t)&d, UIO_MX, uio)) != 0)
|
1995-10-09 14:18:51 +03:00
|
|
|
break;
|
1998-03-01 05:20:01 +03:00
|
|
|
if (cookies)
|
1995-10-09 17:03:32 +03:00
|
|
|
*cookies++ = i + 1;
|
1995-10-09 14:18:51 +03:00
|
|
|
}
|
|
|
|
} else {
|
1998-03-01 05:20:01 +03:00
|
|
|
if (ap->a_ncookies) {
|
|
|
|
ncookies = min(ncookies, (fdp->fd_nfiles + 2));
|
|
|
|
MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
|
|
|
|
*ap->a_cookies = cookies;
|
|
|
|
*ap->a_ncookies = ncookies;
|
|
|
|
}
|
1995-10-09 14:18:51 +03:00
|
|
|
for (; i - 2 < fdp->fd_nfiles && uio->uio_resid >= UIO_MX;
|
|
|
|
i++) {
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
d.d_fileno = FD_ROOT; /* XXX */
|
|
|
|
d.d_namlen = i + 1;
|
1998-08-10 00:51:08 +04:00
|
|
|
memcpy(d.d_name, "..", d.d_namlen);
|
1995-10-09 14:18:51 +03:00
|
|
|
d.d_name[i + 1] = '\0';
|
|
|
|
d.d_type = DT_DIR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (fdp->fd_ofiles[i - 2] == NULL)
|
|
|
|
continue;
|
|
|
|
d.d_fileno = i - 2 + FD_STDIN;
|
1996-10-13 06:21:25 +04:00
|
|
|
d.d_namlen = sprintf(d.d_name, "%d", i - 2);
|
1995-10-09 14:18:51 +03:00
|
|
|
d.d_type = DT_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1996-02-10 01:39:56 +03:00
|
|
|
if ((error = uiomove((caddr_t)&d, UIO_MX, uio)) != 0)
|
1993-03-24 02:56:31 +03:00
|
|
|
break;
|
1998-03-01 05:20:01 +03:00
|
|
|
if (cookies)
|
1995-10-09 17:03:32 +03:00
|
|
|
*cookies++ = i + 1;
|
1993-03-24 02:56:31 +03:00
|
|
|
}
|
1994-01-05 12:00:57 +03:00
|
|
|
}
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (ap->a_ncookies && error) {
|
|
|
|
FREE(*ap->a_cookies, M_TEMP);
|
|
|
|
*ap->a_ncookies = 0;
|
|
|
|
*ap->a_cookies = NULL;
|
|
|
|
}
|
|
|
|
|
1995-10-09 17:03:32 +03:00
|
|
|
uio->uio_offset = i;
|
1994-01-05 12:00:57 +03:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_readlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_readlink_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error;
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
if (vp->v_type != VLNK)
|
|
|
|
return (EPERM);
|
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
if (VTOFDESC(vp)->fd_type == Flink) {
|
|
|
|
char *ln = VTOFDESC(vp)->fd_link;
|
1994-06-08 15:33:09 +04:00
|
|
|
error = uiomove(ln, strlen(ln), ap->a_uio);
|
1994-01-05 12:00:57 +03:00
|
|
|
} else {
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_read(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_read_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error = EOPNOTSUPP;
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
1994-06-08 15:33:09 +04:00
|
|
|
error = cttyread(devctty, ap->a_uio, ap->a_ioflag);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_write(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_write_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error = EOPNOTSUPP;
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
1994-06-08 15:33:09 +04:00
|
|
|
error = cttywrite(devctty, ap->a_uio, ap->a_ioflag);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_ioctl(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_ioctl_args /* {
|
|
|
|
struct vnode *a_vp;
|
1994-10-31 00:43:03 +03:00
|
|
|
u_long a_command;
|
1994-06-08 15:33:09 +04:00
|
|
|
caddr_t a_data;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-01-05 12:00:57 +03:00
|
|
|
int error = EOPNOTSUPP;
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
1994-06-08 15:33:09 +04:00
|
|
|
error = cttyioctl(devctty, ap->a_command, ap->a_data,
|
1996-02-10 01:39:56 +03:00
|
|
|
ap->a_fflag, ap->a_p);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
1993-03-24 02:56:31 +03:00
|
|
|
}
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-09-07 16:40:22 +04:00
|
|
|
fdesc_poll(v)
|
1996-02-10 01:39:56 +03:00
|
|
|
void *v;
|
|
|
|
{
|
1996-09-07 16:40:22 +04:00
|
|
|
struct vop_poll_args /* {
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *a_vp;
|
1996-09-07 16:40:22 +04:00
|
|
|
int a_events;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1996-09-07 16:40:22 +04:00
|
|
|
int revents;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (VTOFDESC(ap->a_vp)->fd_type) {
|
1994-01-05 12:00:57 +03:00
|
|
|
case Fctty:
|
1996-09-07 16:40:22 +04:00
|
|
|
revents = cttypoll(devctty, ap->a_events, ap->a_p);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
1993-03-24 02:56:31 +03:00
|
|
|
|
1994-01-05 12:00:57 +03:00
|
|
|
default:
|
1996-09-07 16:40:22 +04:00
|
|
|
revents = genfs_poll(v);
|
1994-01-05 12:00:57 +03:00
|
|
|
break;
|
|
|
|
}
|
1996-09-02 03:47:48 +04:00
|
|
|
|
1996-09-07 16:40:22 +04:00
|
|
|
return (revents);
|
1993-03-24 02:56:31 +03:00
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_inactive(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct proc *a_p;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
|
1993-03-24 02:56:31 +03:00
|
|
|
/*
|
|
|
|
* Clear out the v_type field to avoid
|
|
|
|
* nasty things happening in vgone().
|
|
|
|
*/
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1993-03-24 02:56:31 +03:00
|
|
|
vp->v_type = VNON;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_reclaim(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
1994-08-19 15:25:29 +04:00
|
|
|
struct fdescnode *fd = VTOFDESC(vp);
|
1994-01-05 12:00:57 +03:00
|
|
|
|
1994-08-19 15:25:29 +04:00
|
|
|
LIST_REMOVE(fd, fd_hash);
|
1994-06-08 15:33:09 +04:00
|
|
|
FREE(vp->v_data, M_TEMP);
|
|
|
|
vp->v_data = 0;
|
1994-01-05 12:00:57 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Return POSIX pathconf information applicable to special devices.
|
|
|
|
*/
|
1996-02-10 01:39:56 +03:00
|
|
|
int
|
|
|
|
fdesc_pathconf(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-08 15:33:09 +04:00
|
|
|
struct vop_pathconf_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_name;
|
1994-10-20 07:22:35 +03:00
|
|
|
register_t *a_retval;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
switch (ap->a_name) {
|
|
|
|
case _PC_LINK_MAX:
|
|
|
|
*ap->a_retval = LINK_MAX;
|
|
|
|
return (0);
|
|
|
|
case _PC_MAX_CANON:
|
|
|
|
*ap->a_retval = MAX_CANON;
|
|
|
|
return (0);
|
|
|
|
case _PC_MAX_INPUT:
|
|
|
|
*ap->a_retval = MAX_INPUT;
|
|
|
|
return (0);
|
|
|
|
case _PC_PIPE_BUF:
|
|
|
|
*ap->a_retval = PIPE_BUF;
|
|
|
|
return (0);
|
|
|
|
case _PC_CHOWN_RESTRICTED:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
|
|
|
case _PC_VDISABLE:
|
|
|
|
*ap->a_retval = _POSIX_VDISABLE;
|
|
|
|
return (0);
|
1998-08-03 18:19:57 +04:00
|
|
|
case _PC_SYNC_IO:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
1994-06-08 15:33:09 +04:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
1993-03-24 02:56:31 +03:00
|
|
|
/*
|
|
|
|
* Print out the contents of a /dev/fd vnode.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1994-06-08 15:33:09 +04:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_print(v)
|
|
|
|
void *v;
|
1993-03-24 02:56:31 +03:00
|
|
|
{
|
1996-10-13 06:21:25 +04:00
|
|
|
printf("tag VT_NON, fdesc vnode\n");
|
1994-06-08 15:33:09 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-02-09 17:45:36 +03:00
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_link(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1996-02-09 17:45:36 +03:00
|
|
|
struct vop_link_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1996-02-09 17:45:36 +03:00
|
|
|
|
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EROFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-10 01:39:56 +03:00
|
|
|
fdesc_symlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1996-02-09 17:45:36 +03:00
|
|
|
struct vop_symlink_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
char *a_target;
|
1996-02-10 01:39:56 +03:00
|
|
|
} */ *ap = v;
|
1996-02-09 17:45:36 +03:00
|
|
|
|
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EROFS);
|
|
|
|
}
|