Home | History | Annotate | Line # | Download | only in kernfs
kernfs_vnops.c revision 1.79.10.2
      1  1.79.10.2     lukem /*	$NetBSD: kernfs_vnops.c,v 1.79.10.2 2002/10/14 00:06:29 lukem Exp $	*/
      2       1.27       cgd 
      3        1.1       cgd /*
      4       1.23   mycroft  * Copyright (c) 1992, 1993
      5       1.23   mycroft  *	The Regents of the University of California.  All rights reserved.
      6        1.1       cgd  *
      7       1.17       cgd  * This code is derived from software donated to Berkeley by
      8        1.1       cgd  * Jan-Simon Pendry.
      9        1.1       cgd  *
     10        1.2       cgd  * Redistribution and use in source and binary forms, with or without
     11        1.2       cgd  * modification, are permitted provided that the following conditions
     12        1.2       cgd  * are met:
     13        1.2       cgd  * 1. Redistributions of source code must retain the above copyright
     14        1.2       cgd  *    notice, this list of conditions and the following disclaimer.
     15        1.2       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.2       cgd  *    notice, this list of conditions and the following disclaimer in the
     17        1.2       cgd  *    documentation and/or other materials provided with the distribution.
     18        1.2       cgd  * 3. All advertising materials mentioning features or use of this software
     19        1.2       cgd  *    must display the following acknowledgement:
     20       1.17       cgd  *	This product includes software developed by the University of
     21       1.17       cgd  *	California, Berkeley and its contributors.
     22        1.2       cgd  * 4. Neither the name of the University nor the names of its contributors
     23        1.2       cgd  *    may be used to endorse or promote products derived from this software
     24        1.2       cgd  *    without specific prior written permission.
     25        1.1       cgd  *
     26        1.2       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27        1.2       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28        1.2       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29        1.2       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30        1.2       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31        1.2       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32        1.2       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33        1.2       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34        1.2       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35        1.2       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36        1.2       cgd  * SUCH DAMAGE.
     37        1.1       cgd  *
     38       1.57      fvdl  *	@(#)kernfs_vnops.c	8.15 (Berkeley) 5/21/95
     39        1.1       cgd  */
     40        1.1       cgd 
     41        1.1       cgd /*
     42       1.23   mycroft  * Kernel parameter filesystem (/kern)
     43        1.1       cgd  */
     44       1.77     lukem 
     45       1.77     lukem #include <sys/cdefs.h>
     46  1.79.10.2     lukem __KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.79.10.2 2002/10/14 00:06:29 lukem Exp $");
     47       1.55       mrg 
     48       1.14   mycroft #include <sys/param.h>
     49       1.14   mycroft #include <sys/systm.h>
     50       1.14   mycroft #include <sys/kernel.h>
     51       1.23   mycroft #include <sys/vmmeter.h>
     52       1.14   mycroft #include <sys/time.h>
     53       1.14   mycroft #include <sys/proc.h>
     54       1.23   mycroft #include <sys/vnode.h>
     55       1.23   mycroft #include <sys/malloc.h>
     56       1.14   mycroft #include <sys/file.h>
     57       1.14   mycroft #include <sys/stat.h>
     58       1.14   mycroft #include <sys/mount.h>
     59       1.14   mycroft #include <sys/namei.h>
     60       1.14   mycroft #include <sys/buf.h>
     61       1.23   mycroft #include <sys/dirent.h>
     62       1.28   mycroft #include <sys/msgbuf.h>
     63       1.44   mycroft 
     64       1.44   mycroft #include <miscfs/genfs/genfs.h>
     65       1.17       cgd #include <miscfs/kernfs/kernfs.h>
     66       1.63       mrg 
     67       1.54       mrg #include <uvm/uvm_extern.h>
     68       1.54       mrg 
     69       1.17       cgd #define KSTRING	256		/* Largest I/O available via this filesystem */
     70       1.17       cgd #define	UIO_MX 32
     71        1.1       cgd 
     72       1.23   mycroft #define	READ_MODE	(S_IRUSR|S_IRGRP|S_IROTH)
     73       1.23   mycroft #define	WRITE_MODE	(S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH)
     74       1.23   mycroft #define DIR_MODE	(S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
     75       1.23   mycroft 
     76       1.75  jdolecek const struct kern_target kern_targets[] = {
     77        1.1       cgd /* NOTE: The name must be less than UIO_MX-16 chars in length */
     78       1.23   mycroft #define N(s) sizeof(s)-1, s
     79       1.23   mycroft      /*        name            data          tag           type  ro/rw */
     80       1.23   mycroft      { DT_DIR, N("."),         0,            KTT_NULL,     VDIR, DIR_MODE   },
     81       1.23   mycroft      { DT_DIR, N(".."),        0,            KTT_NULL,     VDIR, DIR_MODE   },
     82       1.23   mycroft      { DT_REG, N("boottime"),  &boottime.tv_sec, KTT_INT,  VREG, READ_MODE  },
     83       1.69   thorpej 			/* XXX cast away const */
     84       1.69   thorpej      { DT_REG, N("copyright"), (void *)copyright,
     85       1.69   thorpej      					     KTT_STRING,   VREG, READ_MODE  },
     86       1.23   mycroft      { DT_REG, N("hostname"),  0,            KTT_HOSTNAME, VREG, WRITE_MODE },
     87       1.23   mycroft      { DT_REG, N("hz"),        &hz,          KTT_INT,      VREG, READ_MODE  },
     88       1.23   mycroft      { DT_REG, N("loadavg"),   0,            KTT_AVENRUN,  VREG, READ_MODE  },
     89       1.28   mycroft      { DT_REG, N("msgbuf"),    0,	     KTT_MSGBUF,   VREG, READ_MODE  },
     90       1.54       mrg      { DT_REG, N("pagesize"),  &uvmexp.pagesize, KTT_INT,  VREG, READ_MODE  },
     91       1.73  jdolecek      { DT_REG, N("physmem"),   &physmem,     KTT_INT,      VREG, READ_MODE  },
     92       1.17       cgd #if 0
     93       1.23   mycroft      { DT_DIR, N("root"),      0,            KTT_NULL,     VDIR, DIR_MODE   },
     94       1.17       cgd #endif
     95       1.23   mycroft      { DT_BLK, N("rootdev"),   &rootdev,     KTT_DEVICE,   VBLK, READ_MODE  },
     96       1.23   mycroft      { DT_CHR, N("rrootdev"),  &rrootdev,    KTT_DEVICE,   VCHR, READ_MODE  },
     97       1.23   mycroft      { DT_REG, N("time"),      0,            KTT_TIME,     VREG, READ_MODE  },
     98       1.69   thorpej 			/* XXX cast away const */
     99       1.69   thorpej      { DT_REG, N("version"),   (void *)version,
    100       1.69   thorpej      					     KTT_STRING,   VREG, READ_MODE  },
    101       1.23   mycroft #undef N
    102        1.1       cgd };
    103       1.17       cgd static int nkern_targets = sizeof(kern_targets) / sizeof(kern_targets[0]);
    104        1.1       cgd 
    105       1.41  christos int	kernfs_lookup	__P((void *));
    106       1.64  wrstuden #define	kernfs_create	genfs_eopnotsupp_rele
    107       1.64  wrstuden #define	kernfs_mknod	genfs_eopnotsupp_rele
    108       1.44   mycroft #define	kernfs_open	genfs_nullop
    109       1.44   mycroft #define	kernfs_close	genfs_nullop
    110       1.41  christos int	kernfs_access	__P((void *));
    111       1.41  christos int	kernfs_getattr	__P((void *));
    112       1.41  christos int	kernfs_setattr	__P((void *));
    113       1.41  christos int	kernfs_read	__P((void *));
    114       1.41  christos int	kernfs_write	__P((void *));
    115       1.65  wrstuden #define	kernfs_fcntl	genfs_fcntl
    116       1.61  matthias #define	kernfs_ioctl	genfs_enoioctl
    117       1.45   mycroft #define	kernfs_poll	genfs_poll
    118       1.57      fvdl #define kernfs_revoke	genfs_revoke
    119       1.44   mycroft #define	kernfs_fsync	genfs_nullop
    120       1.44   mycroft #define	kernfs_seek	genfs_nullop
    121       1.64  wrstuden #define	kernfs_remove	genfs_eopnotsupp_rele
    122       1.41  christos int	kernfs_link	__P((void *));
    123       1.64  wrstuden #define	kernfs_rename	genfs_eopnotsupp_rele
    124       1.64  wrstuden #define	kernfs_mkdir	genfs_eopnotsupp_rele
    125       1.64  wrstuden #define	kernfs_rmdir	genfs_eopnotsupp_rele
    126       1.41  christos int	kernfs_symlink	__P((void *));
    127       1.41  christos int	kernfs_readdir	__P((void *));
    128       1.44   mycroft #define	kernfs_readlink	genfs_eopnotsupp
    129       1.44   mycroft #define	kernfs_abortop	genfs_abortop
    130       1.41  christos int	kernfs_inactive	__P((void *));
    131       1.41  christos int	kernfs_reclaim	__P((void *));
    132       1.64  wrstuden #define	kernfs_lock	genfs_lock
    133       1.64  wrstuden #define	kernfs_unlock	genfs_unlock
    134       1.44   mycroft #define	kernfs_bmap	genfs_badop
    135       1.44   mycroft #define	kernfs_strategy	genfs_badop
    136       1.41  christos int	kernfs_print	__P((void *));
    137       1.64  wrstuden #define	kernfs_islocked	genfs_islocked
    138       1.41  christos int	kernfs_pathconf	__P((void *));
    139       1.62    kleink #define	kernfs_advlock	genfs_einval
    140       1.44   mycroft #define	kernfs_blkatoff	genfs_eopnotsupp
    141       1.44   mycroft #define	kernfs_valloc	genfs_eopnotsupp
    142       1.44   mycroft #define	kernfs_vfree	genfs_nullop
    143       1.44   mycroft #define	kernfs_truncate	genfs_eopnotsupp
    144       1.44   mycroft #define	kernfs_update	genfs_nullop
    145       1.44   mycroft #define	kernfs_bwrite	genfs_eopnotsupp
    146       1.79       chs #define	kernfs_putpages	genfs_putpages
    147       1.41  christos 
    148  1.79.10.1     lukem static int	kernfs_xread __P((const struct kern_target *, int, char **, size_t, size_t *));
    149  1.79.10.1     lukem static int	kernfs_xwrite __P((const struct kern_target *, char *, size_t));
    150       1.41  christos 
    151       1.41  christos int (**kernfs_vnodeop_p) __P((void *));
    152       1.71  jdolecek const struct vnodeopv_entry_desc kernfs_vnodeop_entries[] = {
    153       1.41  christos 	{ &vop_default_desc, vn_default_error },
    154       1.44   mycroft 	{ &vop_lookup_desc, kernfs_lookup },		/* lookup */
    155       1.44   mycroft 	{ &vop_create_desc, kernfs_create },		/* create */
    156       1.44   mycroft 	{ &vop_mknod_desc, kernfs_mknod },		/* mknod */
    157       1.44   mycroft 	{ &vop_open_desc, kernfs_open },		/* open */
    158       1.44   mycroft 	{ &vop_close_desc, kernfs_close },		/* close */
    159       1.44   mycroft 	{ &vop_access_desc, kernfs_access },		/* access */
    160       1.44   mycroft 	{ &vop_getattr_desc, kernfs_getattr },		/* getattr */
    161       1.44   mycroft 	{ &vop_setattr_desc, kernfs_setattr },		/* setattr */
    162       1.44   mycroft 	{ &vop_read_desc, kernfs_read },		/* read */
    163       1.44   mycroft 	{ &vop_write_desc, kernfs_write },		/* write */
    164       1.65  wrstuden 	{ &vop_fcntl_desc, kernfs_fcntl },		/* fcntl */
    165       1.44   mycroft 	{ &vop_ioctl_desc, kernfs_ioctl },		/* ioctl */
    166       1.45   mycroft 	{ &vop_poll_desc, kernfs_poll },		/* poll */
    167       1.57      fvdl 	{ &vop_revoke_desc, kernfs_revoke },		/* revoke */
    168       1.44   mycroft 	{ &vop_fsync_desc, kernfs_fsync },		/* fsync */
    169       1.44   mycroft 	{ &vop_seek_desc, kernfs_seek },		/* seek */
    170       1.44   mycroft 	{ &vop_remove_desc, kernfs_remove },		/* remove */
    171       1.44   mycroft 	{ &vop_link_desc, kernfs_link },		/* link */
    172       1.44   mycroft 	{ &vop_rename_desc, kernfs_rename },		/* rename */
    173       1.44   mycroft 	{ &vop_mkdir_desc, kernfs_mkdir },		/* mkdir */
    174       1.44   mycroft 	{ &vop_rmdir_desc, kernfs_rmdir },		/* rmdir */
    175       1.44   mycroft 	{ &vop_symlink_desc, kernfs_symlink },		/* symlink */
    176       1.44   mycroft 	{ &vop_readdir_desc, kernfs_readdir },		/* readdir */
    177       1.44   mycroft 	{ &vop_readlink_desc, kernfs_readlink },	/* readlink */
    178       1.44   mycroft 	{ &vop_abortop_desc, kernfs_abortop },		/* abortop */
    179       1.44   mycroft 	{ &vop_inactive_desc, kernfs_inactive },	/* inactive */
    180       1.44   mycroft 	{ &vop_reclaim_desc, kernfs_reclaim },		/* reclaim */
    181       1.44   mycroft 	{ &vop_lock_desc, kernfs_lock },		/* lock */
    182       1.44   mycroft 	{ &vop_unlock_desc, kernfs_unlock },		/* unlock */
    183       1.44   mycroft 	{ &vop_bmap_desc, kernfs_bmap },		/* bmap */
    184       1.44   mycroft 	{ &vop_strategy_desc, kernfs_strategy },	/* strategy */
    185       1.44   mycroft 	{ &vop_print_desc, kernfs_print },		/* print */
    186       1.44   mycroft 	{ &vop_islocked_desc, kernfs_islocked },	/* islocked */
    187       1.44   mycroft 	{ &vop_pathconf_desc, kernfs_pathconf },	/* pathconf */
    188       1.44   mycroft 	{ &vop_advlock_desc, kernfs_advlock },		/* advlock */
    189       1.44   mycroft 	{ &vop_blkatoff_desc, kernfs_blkatoff },	/* blkatoff */
    190       1.44   mycroft 	{ &vop_valloc_desc, kernfs_valloc },		/* valloc */
    191       1.44   mycroft 	{ &vop_vfree_desc, kernfs_vfree },		/* vfree */
    192       1.44   mycroft 	{ &vop_truncate_desc, kernfs_truncate },	/* truncate */
    193       1.44   mycroft 	{ &vop_update_desc, kernfs_update },		/* update */
    194       1.44   mycroft 	{ &vop_bwrite_desc, kernfs_bwrite },		/* bwrite */
    195       1.79       chs 	{ &vop_putpages_desc, kernfs_putpages },	/* putpages */
    196       1.76       chs 	{ NULL, NULL }
    197       1.41  christos };
    198       1.71  jdolecek const struct vnodeopv_desc kernfs_vnodeop_opv_desc =
    199       1.41  christos 	{ &kernfs_vnodeop_p, kernfs_vnodeop_entries };
    200       1.41  christos 
    201  1.79.10.1     lukem static int
    202  1.79.10.1     lukem kernfs_xread(kt, off, bufp, len, wrlen)
    203       1.75  jdolecek 	const struct kern_target *kt;
    204       1.28   mycroft 	int off;
    205       1.28   mycroft 	char **bufp;
    206  1.79.10.1     lukem 	size_t len;
    207  1.79.10.1     lukem 	size_t *wrlen;
    208        1.1       cgd {
    209        1.1       cgd 
    210        1.1       cgd 	switch (kt->kt_tag) {
    211        1.1       cgd 	case KTT_TIME: {
    212        1.1       cgd 		struct timeval tv;
    213       1.28   mycroft 
    214        1.1       cgd 		microtime(&tv);
    215       1.47  christos 		sprintf(*bufp, "%ld %ld\n", tv.tv_sec, tv.tv_usec);
    216        1.1       cgd 		break;
    217        1.1       cgd 	}
    218        1.1       cgd 
    219        1.1       cgd 	case KTT_INT: {
    220        1.1       cgd 		int *ip = kt->kt_data;
    221       1.28   mycroft 
    222       1.47  christos 		sprintf(*bufp, "%d\n", *ip);
    223        1.1       cgd 		break;
    224        1.1       cgd 	}
    225        1.1       cgd 
    226        1.1       cgd 	case KTT_STRING: {
    227        1.1       cgd 		char *cp = kt->kt_data;
    228        1.1       cgd 
    229       1.28   mycroft 		*bufp = cp;
    230       1.28   mycroft 		break;
    231       1.28   mycroft 	}
    232        1.1       cgd 
    233       1.28   mycroft 	case KTT_MSGBUF: {
    234       1.28   mycroft 		long n;
    235       1.28   mycroft 
    236       1.52       leo 		/*
    237       1.52       leo 		 * deal with cases where the message buffer has
    238       1.52       leo 		 * become corrupted.
    239       1.52       leo 		 */
    240       1.52       leo 		if (!msgbufenabled || msgbufp->msg_magic != MSG_MAGIC) {
    241       1.52       leo 			msgbufenabled = 0;
    242       1.52       leo 			return (ENXIO);
    243       1.52       leo 		}
    244       1.52       leo 
    245       1.52       leo 		/*
    246       1.52       leo 		 * Note that reads of /kern/msgbuf won't necessarily yield
    247       1.52       leo 		 * consistent results, if the message buffer is modified
    248       1.52       leo 		 * while the read is in progress.  The worst that can happen
    249       1.52       leo 		 * is that incorrect data will be read.  There's no way
    250       1.52       leo 		 * that this can crash the system unless the values in the
    251       1.52       leo 		 * message buffer header are corrupted, but that'll cause
    252       1.52       leo 		 * the system to die anyway.
    253       1.52       leo 		 */
    254  1.79.10.1     lukem 		if (off >= msgbufp->msg_bufs) {
    255  1.79.10.1     lukem 			*wrlen = 0;
    256       1.28   mycroft 			return (0);
    257  1.79.10.1     lukem 		}
    258       1.28   mycroft 		n = msgbufp->msg_bufx + off;
    259       1.52       leo 		if (n >= msgbufp->msg_bufs)
    260       1.52       leo 			n -= msgbufp->msg_bufs;
    261       1.52       leo 		len = min(msgbufp->msg_bufs - n, msgbufp->msg_bufs - off);
    262       1.28   mycroft 		*bufp = msgbufp->msg_bufc + n;
    263  1.79.10.1     lukem 		*wrlen = len;
    264  1.79.10.1     lukem 		return (0);
    265        1.1       cgd 	}
    266        1.1       cgd 
    267        1.1       cgd 	case KTT_HOSTNAME: {
    268        1.1       cgd 		char *cp = hostname;
    269        1.1       cgd 		int xlen = hostnamelen;
    270        1.1       cgd 
    271       1.17       cgd 		if (xlen >= (len-2))
    272        1.1       cgd 			return (EINVAL);
    273        1.1       cgd 
    274       1.60     perry 		memcpy(*bufp, cp, xlen);
    275       1.28   mycroft 		(*bufp)[xlen] = '\n';
    276       1.28   mycroft 		(*bufp)[xlen+1] = '\0';
    277        1.1       cgd 		break;
    278        1.1       cgd 	}
    279        1.1       cgd 
    280        1.1       cgd 	case KTT_AVENRUN:
    281       1.31   mycroft 		averunnable.fscale = FSCALE;
    282       1.47  christos 		sprintf(*bufp, "%d %d %d %ld\n",
    283       1.23   mycroft 		    averunnable.ldavg[0], averunnable.ldavg[1],
    284       1.23   mycroft 		    averunnable.ldavg[2], averunnable.fscale);
    285        1.1       cgd 		break;
    286        1.1       cgd 
    287        1.1       cgd 	default:
    288  1.79.10.1     lukem 		*wrlen = 0;
    289       1.28   mycroft 		return (0);
    290        1.1       cgd 	}
    291        1.1       cgd 
    292       1.28   mycroft 	len = strlen(*bufp);
    293       1.28   mycroft 	if (len <= off)
    294  1.79.10.1     lukem 		*wrlen = 0;
    295  1.79.10.1     lukem 	else {
    296  1.79.10.1     lukem 		*bufp += off;
    297  1.79.10.1     lukem 		*wrlen = len - off;
    298  1.79.10.1     lukem 	}
    299  1.79.10.1     lukem 	return (0);
    300        1.1       cgd }
    301        1.1       cgd 
    302  1.79.10.1     lukem static int
    303        1.1       cgd kernfs_xwrite(kt, buf, len)
    304       1.75  jdolecek 	const struct kern_target *kt;
    305        1.1       cgd 	char *buf;
    306  1.79.10.1     lukem 	size_t len;
    307        1.1       cgd {
    308       1.23   mycroft 
    309        1.1       cgd 	switch (kt->kt_tag) {
    310       1.23   mycroft 	case KTT_HOSTNAME:
    311        1.1       cgd 		if (buf[len-1] == '\n')
    312        1.1       cgd 			--len;
    313       1.60     perry 		memcpy(hostname, buf, len);
    314       1.17       cgd 		hostname[len] = '\0';
    315  1.79.10.1     lukem 		hostnamelen = (size_t) len;
    316        1.1       cgd 		return (0);
    317        1.1       cgd 
    318        1.1       cgd 	default:
    319        1.1       cgd 		return (EIO);
    320        1.1       cgd 	}
    321        1.1       cgd }
    322        1.1       cgd 
    323       1.17       cgd 
    324       1.17       cgd /*
    325        1.1       cgd  * vp is the current namei directory
    326        1.1       cgd  * ndp is the name to locate in that directory...
    327        1.1       cgd  */
    328       1.41  christos int
    329       1.41  christos kernfs_lookup(v)
    330       1.41  christos 	void *v;
    331       1.41  christos {
    332       1.23   mycroft 	struct vop_lookup_args /* {
    333       1.23   mycroft 		struct vnode * a_dvp;
    334       1.23   mycroft 		struct vnode ** a_vpp;
    335       1.23   mycroft 		struct componentname * a_cnp;
    336       1.41  christos 	} */ *ap = v;
    337       1.23   mycroft 	struct componentname *cnp = ap->a_cnp;
    338       1.23   mycroft 	struct vnode **vpp = ap->a_vpp;
    339       1.23   mycroft 	struct vnode *dvp = ap->a_dvp;
    340       1.48       cgd 	const char *pname = cnp->cn_nameptr;
    341       1.75  jdolecek 	const struct kern_target *kt;
    342        1.1       cgd 	struct vnode *fvp;
    343       1.64  wrstuden 	int error, i, wantpunlock;
    344        1.1       cgd 
    345        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    346       1.51  christos 	printf("kernfs_lookup(%p)\n", ap);
    347       1.51  christos 	printf("kernfs_lookup(dp = %p, vpp = %p, cnp = %p)\n", dvp, vpp, ap->a_cnp);
    348       1.47  christos 	printf("kernfs_lookup(%s)\n", pname);
    349        1.1       cgd #endif
    350       1.23   mycroft 
    351       1.35   mycroft 	*vpp = NULLVP;
    352       1.64  wrstuden 	cnp->cn_flags &= ~PDIRUNLOCK;
    353       1.35   mycroft 
    354       1.35   mycroft 	if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)
    355       1.35   mycroft 		return (EROFS);
    356       1.35   mycroft 
    357       1.23   mycroft 	if (cnp->cn_namelen == 1 && *pname == '.') {
    358       1.23   mycroft 		*vpp = dvp;
    359        1.1       cgd 		VREF(dvp);
    360        1.1       cgd 		return (0);
    361        1.1       cgd 	}
    362       1.13       cgd 
    363       1.64  wrstuden 	/*
    364       1.64  wrstuden 	 * This code only supports a flat directory, so we don't
    365       1.64  wrstuden 	 * need to worry about ..
    366       1.64  wrstuden 	 */
    367       1.64  wrstuden 
    368       1.17       cgd #if 0
    369       1.60     perry 	if (cnp->cn_namelen == 4 && memcmp(pname, "root", 4) == 0) {
    370       1.23   mycroft 		*vpp = rootdir;
    371       1.17       cgd 		VREF(rootdir);
    372       1.57      fvdl 		vn_lock(rootdir, LK_SHARED | LK_RETRY);
    373        1.1       cgd 		return (0);
    374        1.1       cgd 	}
    375       1.13       cgd #endif
    376       1.25   mycroft 
    377       1.64  wrstuden 	wantpunlock = (~cnp->cn_flags & (LOCKPARENT | ISLASTCN));
    378       1.64  wrstuden 
    379       1.35   mycroft 	for (kt = kern_targets, i = 0; i < nkern_targets; kt++, i++) {
    380       1.26   mycroft 		if (cnp->cn_namelen == kt->kt_namlen &&
    381       1.60     perry 		    memcmp(kt->kt_name, pname, cnp->cn_namelen) == 0)
    382       1.35   mycroft 			goto found;
    383        1.1       cgd 	}
    384        1.1       cgd 
    385        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    386       1.47  christos 	printf("kernfs_lookup: i = %d, failed", i);
    387        1.1       cgd #endif
    388        1.1       cgd 
    389       1.35   mycroft 	return (cnp->cn_nameiop == LOOKUP ? ENOENT : EROFS);
    390       1.23   mycroft 
    391       1.35   mycroft found:
    392       1.23   mycroft 	if (kt->kt_tag == KTT_DEVICE) {
    393       1.23   mycroft 		dev_t *dp = kt->kt_data;
    394       1.24   mycroft 	loop:
    395       1.57      fvdl 		if (*dp == NODEV || !vfinddev(*dp, kt->kt_vtype, &fvp)) {
    396       1.24   mycroft 			return (ENOENT);
    397       1.57      fvdl 		}
    398       1.23   mycroft 		*vpp = fvp;
    399       1.57      fvdl 		if (vget(fvp, LK_EXCLUSIVE))
    400       1.24   mycroft 			goto loop;
    401       1.64  wrstuden 		if (wantpunlock) {
    402       1.64  wrstuden 			VOP_UNLOCK(dvp, 0);
    403       1.64  wrstuden 			cnp->cn_flags |= PDIRUNLOCK;
    404       1.64  wrstuden 		}
    405       1.23   mycroft 		return (0);
    406       1.23   mycroft 	}
    407        1.1       cgd 
    408        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    409       1.47  christos 	printf("kernfs_lookup: allocate new vnode\n");
    410        1.1       cgd #endif
    411       1.41  christos 	error = getnewvnode(VT_KERNFS, dvp->v_mount, kernfs_vnodeop_p, &fvp);
    412       1.57      fvdl 	if (error) {
    413       1.23   mycroft 		return (error);
    414       1.57      fvdl 	}
    415       1.23   mycroft 
    416       1.23   mycroft 	MALLOC(fvp->v_data, void *, sizeof(struct kernfs_node), M_TEMP,
    417       1.23   mycroft 	    M_WAITOK);
    418       1.23   mycroft 	VTOKERN(fvp)->kf_kt = kt;
    419       1.23   mycroft 	fvp->v_type = kt->kt_vtype;
    420       1.64  wrstuden 	vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY);
    421       1.23   mycroft 	*vpp = fvp;
    422       1.23   mycroft 
    423        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    424       1.51  christos 	printf("kernfs_lookup: newvp = %p\n", fvp);
    425        1.1       cgd #endif
    426       1.64  wrstuden 	if (wantpunlock) {
    427       1.64  wrstuden 		VOP_UNLOCK(dvp, 0);
    428       1.64  wrstuden 		cnp->cn_flags |= PDIRUNLOCK;
    429       1.64  wrstuden 	}
    430        1.1       cgd 	return (0);
    431        1.1       cgd }
    432        1.1       cgd 
    433       1.28   mycroft int
    434       1.41  christos kernfs_access(v)
    435       1.41  christos 	void *v;
    436       1.41  christos {
    437       1.23   mycroft 	struct vop_access_args /* {
    438       1.23   mycroft 		struct vnode *a_vp;
    439       1.34   mycroft 		int a_mode;
    440       1.23   mycroft 		struct ucred *a_cred;
    441       1.23   mycroft 		struct proc *a_p;
    442       1.41  christos 	} */ *ap = v;
    443       1.26   mycroft 	struct vnode *vp = ap->a_vp;
    444       1.49   mycroft 	mode_t mode;
    445       1.17       cgd 
    446       1.49   mycroft 	if (vp->v_flag & VROOT) {
    447       1.49   mycroft 		mode = DIR_MODE;
    448       1.49   mycroft 	} else {
    449       1.75  jdolecek 		const struct kern_target *kt = VTOKERN(vp)->kf_kt;
    450       1.49   mycroft 		mode = kt->kt_mode;
    451       1.49   mycroft 	}
    452       1.49   mycroft 
    453       1.49   mycroft 	return (vaccess(vp->v_type, mode, (uid_t)0, (gid_t)0, ap->a_mode,
    454       1.49   mycroft 	    ap->a_cred));
    455       1.23   mycroft }
    456       1.23   mycroft 
    457       1.41  christos int
    458       1.41  christos kernfs_getattr(v)
    459       1.41  christos 	void *v;
    460       1.41  christos {
    461       1.23   mycroft 	struct vop_getattr_args /* {
    462       1.23   mycroft 		struct vnode *a_vp;
    463       1.23   mycroft 		struct vattr *a_vap;
    464       1.23   mycroft 		struct ucred *a_cred;
    465       1.23   mycroft 		struct proc *a_p;
    466       1.41  christos 	} */ *ap = v;
    467       1.23   mycroft 	struct vnode *vp = ap->a_vp;
    468       1.23   mycroft 	struct vattr *vap = ap->a_vap;
    469       1.36       cgd 	struct timeval tv;
    470        1.1       cgd 	int error = 0;
    471       1.28   mycroft 	char strbuf[KSTRING], *buf;
    472        1.1       cgd 
    473       1.60     perry 	memset((caddr_t) vap, 0, sizeof(*vap));
    474        1.1       cgd 	vattr_null(vap);
    475       1.17       cgd 	vap->va_uid = 0;
    476       1.17       cgd 	vap->va_gid = 0;
    477        1.1       cgd 	vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
    478       1.23   mycroft 	vap->va_size = 0;
    479        1.1       cgd 	vap->va_blocksize = DEV_BSIZE;
    480       1.36       cgd 	microtime(&tv);
    481       1.36       cgd 	TIMEVAL_TO_TIMESPEC(&tv, &vap->va_atime);
    482        1.1       cgd 	vap->va_mtime = vap->va_atime;
    483        1.1       cgd 	vap->va_ctime = vap->va_ctime;
    484        1.1       cgd 	vap->va_gen = 0;
    485        1.1       cgd 	vap->va_flags = 0;
    486        1.1       cgd 	vap->va_rdev = 0;
    487        1.1       cgd 	vap->va_bytes = 0;
    488        1.1       cgd 
    489        1.1       cgd 	if (vp->v_flag & VROOT) {
    490        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    491       1.47  christos 		printf("kernfs_getattr: stat rootdir\n");
    492        1.1       cgd #endif
    493       1.17       cgd 		vap->va_type = VDIR;
    494       1.23   mycroft 		vap->va_mode = DIR_MODE;
    495        1.1       cgd 		vap->va_nlink = 2;
    496        1.1       cgd 		vap->va_fileid = 2;
    497        1.1       cgd 		vap->va_size = DEV_BSIZE;
    498        1.1       cgd 	} else {
    499       1.75  jdolecek 		const struct kern_target *kt = VTOKERN(vp)->kf_kt;
    500  1.79.10.2     lukem 		size_t nread, total;
    501        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    502       1.47  christos 		printf("kernfs_getattr: stat target %s\n", kt->kt_name);
    503        1.1       cgd #endif
    504       1.17       cgd 		vap->va_type = kt->kt_vtype;
    505       1.23   mycroft 		vap->va_mode = kt->kt_mode;
    506        1.1       cgd 		vap->va_nlink = 1;
    507       1.57      fvdl 		vap->va_fileid = 1 + (kt - kern_targets);
    508  1.79.10.2     lukem 		total = 0;
    509  1.79.10.2     lukem 		do {
    510  1.79.10.2     lukem 			buf = strbuf;
    511  1.79.10.2     lukem 			error = kernfs_xread(kt, total, &buf,
    512  1.79.10.2     lukem 				sizeof(strbuf), &nread);
    513  1.79.10.2     lukem 			total += nread;
    514  1.79.10.2     lukem 		} while (error == 0 && nread != 0);
    515  1.79.10.2     lukem 		vap->va_size = total;
    516        1.1       cgd 	}
    517        1.1       cgd 
    518        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    519       1.47  christos 	printf("kernfs_getattr: return error %d\n", error);
    520        1.1       cgd #endif
    521        1.1       cgd 	return (error);
    522        1.1       cgd }
    523        1.1       cgd 
    524       1.41  christos /*ARGSUSED*/
    525       1.41  christos int
    526       1.41  christos kernfs_setattr(v)
    527       1.41  christos 	void *v;
    528        1.1       cgd {
    529        1.1       cgd 	/*
    530       1.17       cgd 	 * Silently ignore attribute changes.
    531       1.17       cgd 	 * This allows for open with truncate to have no
    532       1.17       cgd 	 * effect until some data is written.  I want to
    533       1.17       cgd 	 * do it this way because all writes are atomic.
    534        1.1       cgd 	 */
    535       1.17       cgd 	return (0);
    536        1.1       cgd }
    537        1.1       cgd 
    538       1.28   mycroft int
    539       1.41  christos kernfs_read(v)
    540       1.41  christos 	void *v;
    541       1.41  christos {
    542       1.23   mycroft 	struct vop_read_args /* {
    543       1.23   mycroft 		struct vnode *a_vp;
    544       1.23   mycroft 		struct uio *a_uio;
    545       1.23   mycroft 		int  a_ioflag;
    546       1.23   mycroft 		struct ucred *a_cred;
    547       1.41  christos 	} */ *ap = v;
    548       1.23   mycroft 	struct vnode *vp = ap->a_vp;
    549       1.23   mycroft 	struct uio *uio = ap->a_uio;
    550       1.75  jdolecek 	const struct kern_target *kt;
    551       1.28   mycroft 	char strbuf[KSTRING], *buf;
    552  1.79.10.1     lukem 	off_t off;
    553  1.79.10.1     lukem 	size_t len;
    554       1.28   mycroft 	int error;
    555       1.23   mycroft 
    556       1.23   mycroft 	if (vp->v_type == VDIR)
    557       1.23   mycroft 		return (EOPNOTSUPP);
    558       1.23   mycroft 
    559       1.23   mycroft 	kt = VTOKERN(vp)->kf_kt;
    560       1.23   mycroft 
    561        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    562       1.47  christos 	printf("kern_read %s\n", kt->kt_name);
    563        1.1       cgd #endif
    564       1.18       cgd 
    565       1.28   mycroft 	off = uio->uio_offset;
    566  1.79.10.1     lukem 	buf = strbuf;
    567  1.79.10.1     lukem 	if ((error = kernfs_xread(kt, off, &buf, sizeof(strbuf), &len)) == 0)
    568  1.79.10.1     lukem 		error = uiomove(buf, len, uio);
    569  1.79.10.1     lukem 	return (error);
    570        1.1       cgd }
    571        1.1       cgd 
    572       1.28   mycroft int
    573       1.41  christos kernfs_write(v)
    574       1.41  christos 	void *v;
    575       1.41  christos {
    576       1.23   mycroft 	struct vop_write_args /* {
    577       1.23   mycroft 		struct vnode *a_vp;
    578       1.23   mycroft 		struct uio *a_uio;
    579       1.23   mycroft 		int  a_ioflag;
    580       1.23   mycroft 		struct ucred *a_cred;
    581       1.41  christos 	} */ *ap = v;
    582       1.23   mycroft 	struct vnode *vp = ap->a_vp;
    583       1.23   mycroft 	struct uio *uio = ap->a_uio;
    584       1.75  jdolecek 	const struct kern_target *kt;
    585       1.23   mycroft 	int error, xlen;
    586        1.1       cgd 	char strbuf[KSTRING];
    587       1.23   mycroft 
    588       1.23   mycroft 	if (vp->v_type == VDIR)
    589       1.23   mycroft 		return (EOPNOTSUPP);
    590       1.23   mycroft 
    591       1.23   mycroft 	kt = VTOKERN(vp)->kf_kt;
    592        1.1       cgd 
    593        1.1       cgd 	if (uio->uio_offset != 0)
    594        1.1       cgd 		return (EINVAL);
    595        1.1       cgd 
    596        1.1       cgd 	xlen = min(uio->uio_resid, KSTRING-1);
    597       1.41  christos 	if ((error = uiomove(strbuf, xlen, uio)) != 0)
    598        1.1       cgd 		return (error);
    599        1.1       cgd 
    600        1.1       cgd 	if (uio->uio_resid != 0)
    601        1.1       cgd 		return (EIO);
    602        1.1       cgd 
    603        1.1       cgd 	strbuf[xlen] = '\0';
    604       1.17       cgd 	xlen = strlen(strbuf);
    605        1.1       cgd 	return (kernfs_xwrite(kt, strbuf, xlen));
    606        1.1       cgd }
    607        1.1       cgd 
    608       1.41  christos int
    609       1.41  christos kernfs_readdir(v)
    610       1.41  christos 	void *v;
    611       1.41  christos {
    612       1.23   mycroft 	struct vop_readdir_args /* {
    613       1.23   mycroft 		struct vnode *a_vp;
    614       1.23   mycroft 		struct uio *a_uio;
    615       1.23   mycroft 		struct ucred *a_cred;
    616       1.26   mycroft 		int *a_eofflag;
    617       1.57      fvdl 		off_t **a_cookies;
    618       1.57      fvdl 		int a_*ncookies;
    619       1.41  christos 	} */ *ap = v;
    620       1.23   mycroft 	struct uio *uio = ap->a_uio;
    621       1.37   mycroft 	struct dirent d;
    622       1.75  jdolecek 	const struct kern_target *kt;
    623       1.67  sommerfe 	off_t i;
    624        1.1       cgd 	int error;
    625       1.57      fvdl 	off_t *cookies = NULL;
    626       1.57      fvdl 	int ncookies = 0, nc = 0;
    627        1.1       cgd 
    628       1.23   mycroft 	if (ap->a_vp->v_type != VDIR)
    629       1.23   mycroft 		return (ENOTDIR);
    630       1.23   mycroft 
    631       1.37   mycroft 	if (uio->uio_resid < UIO_MX)
    632       1.37   mycroft 		return (EINVAL);
    633       1.38   mycroft 	if (uio->uio_offset < 0)
    634       1.37   mycroft 		return (EINVAL);
    635       1.26   mycroft 
    636        1.1       cgd 	error = 0;
    637       1.38   mycroft 	i = uio->uio_offset;
    638       1.66  sommerfe 
    639       1.66  sommerfe 	if (i >= nkern_targets)
    640       1.66  sommerfe 		return 0;
    641       1.66  sommerfe 
    642       1.60     perry 	memset((caddr_t)&d, 0, UIO_MX);
    643       1.37   mycroft 	d.d_reclen = UIO_MX;
    644       1.37   mycroft 
    645       1.57      fvdl 	if (ap->a_ncookies) {
    646       1.57      fvdl 		nc = uio->uio_resid / UIO_MX;
    647       1.57      fvdl 		nc = min(nc, (nkern_targets - i));
    648       1.70   thorpej 		cookies = malloc(nc * sizeof(off_t), M_TEMP, M_WAITOK);
    649       1.57      fvdl 		*ap->a_cookies = cookies;
    650       1.57      fvdl 	}
    651       1.57      fvdl 
    652       1.23   mycroft 	for (kt = &kern_targets[i];
    653       1.23   mycroft 	     uio->uio_resid >= UIO_MX && i < nkern_targets; kt++, i++) {
    654        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    655       1.74       mrg 		printf("kernfs_readdir: i = %d\n", (int)i);
    656        1.1       cgd #endif
    657       1.26   mycroft 
    658       1.23   mycroft 		if (kt->kt_tag == KTT_DEVICE) {
    659       1.26   mycroft 			dev_t *dp = kt->kt_data;
    660       1.23   mycroft 			struct vnode *fvp;
    661       1.26   mycroft 
    662       1.23   mycroft 			if (*dp == NODEV || !vfinddev(*dp, kt->kt_vtype, &fvp))
    663       1.23   mycroft 				continue;
    664       1.23   mycroft 		}
    665       1.26   mycroft 
    666       1.37   mycroft 		d.d_fileno = i + 3;
    667       1.37   mycroft 		d.d_namlen = kt->kt_namlen;
    668       1.60     perry 		memcpy(d.d_name, kt->kt_name, kt->kt_namlen + 1);
    669       1.37   mycroft 		d.d_type = kt->kt_type;
    670       1.26   mycroft 
    671       1.41  christos 		if ((error = uiomove((caddr_t)&d, UIO_MX, uio)) != 0)
    672        1.1       cgd 			break;
    673       1.57      fvdl 		if (cookies) {
    674       1.38   mycroft 			*cookies++ = i + 1;
    675       1.57      fvdl 			ncookies++;
    676       1.57      fvdl 		}
    677       1.57      fvdl 	}
    678       1.57      fvdl 
    679       1.57      fvdl 	if (ap->a_ncookies) {
    680       1.57      fvdl 		if (error) {
    681       1.70   thorpej 			free(*ap->a_cookies, M_TEMP);
    682       1.57      fvdl 			*ap->a_ncookies = 0;
    683       1.57      fvdl 			*ap->a_cookies = NULL;
    684       1.57      fvdl 		} else
    685       1.57      fvdl 			*ap->a_ncookies = ncookies;
    686        1.1       cgd 	}
    687        1.1       cgd 
    688       1.38   mycroft 	uio->uio_offset = i;
    689        1.1       cgd 	return (error);
    690        1.1       cgd }
    691        1.1       cgd 
    692       1.41  christos int
    693       1.41  christos kernfs_inactive(v)
    694       1.41  christos 	void *v;
    695       1.41  christos {
    696       1.23   mycroft 	struct vop_inactive_args /* {
    697       1.23   mycroft 		struct vnode *a_vp;
    698       1.57      fvdl 		struct proc *a_p;
    699       1.41  christos 	} */ *ap = v;
    700       1.23   mycroft 	struct vnode *vp = ap->a_vp;
    701       1.23   mycroft 
    702       1.23   mycroft #ifdef KERNFS_DIAGNOSTIC
    703       1.51  christos 	printf("kernfs_inactive(%p)\n", vp);
    704       1.23   mycroft #endif
    705        1.1       cgd 	/*
    706        1.1       cgd 	 * Clear out the v_type field to avoid
    707        1.1       cgd 	 * nasty things happening in vgone().
    708        1.1       cgd 	 */
    709       1.57      fvdl 	VOP_UNLOCK(vp, 0);
    710        1.1       cgd 	vp->v_type = VNON;
    711       1.23   mycroft 	return (0);
    712       1.23   mycroft }
    713       1.23   mycroft 
    714       1.41  christos int
    715       1.41  christos kernfs_reclaim(v)
    716       1.41  christos 	void *v;
    717       1.41  christos {
    718       1.23   mycroft 	struct vop_reclaim_args /* {
    719       1.23   mycroft 		struct vnode *a_vp;
    720       1.41  christos 	} */ *ap = v;
    721       1.23   mycroft 	struct vnode *vp = ap->a_vp;
    722       1.23   mycroft 
    723        1.1       cgd #ifdef KERNFS_DIAGNOSTIC
    724       1.51  christos 	printf("kernfs_reclaim(%p)\n", vp);
    725        1.1       cgd #endif
    726       1.23   mycroft 	if (vp->v_data) {
    727       1.23   mycroft 		FREE(vp->v_data, M_TEMP);
    728       1.23   mycroft 		vp->v_data = 0;
    729       1.23   mycroft 	}
    730        1.1       cgd 	return (0);
    731        1.1       cgd }
    732        1.1       cgd 
    733        1.1       cgd /*
    734       1.23   mycroft  * Return POSIX pathconf information applicable to special devices.
    735       1.23   mycroft  */
    736       1.41  christos int
    737       1.41  christos kernfs_pathconf(v)
    738       1.41  christos 	void *v;
    739       1.41  christos {
    740       1.23   mycroft 	struct vop_pathconf_args /* {
    741       1.23   mycroft 		struct vnode *a_vp;
    742       1.23   mycroft 		int a_name;
    743       1.29       cgd 		register_t *a_retval;
    744       1.41  christos 	} */ *ap = v;
    745       1.23   mycroft 
    746       1.23   mycroft 	switch (ap->a_name) {
    747       1.23   mycroft 	case _PC_LINK_MAX:
    748       1.23   mycroft 		*ap->a_retval = LINK_MAX;
    749       1.23   mycroft 		return (0);
    750       1.23   mycroft 	case _PC_MAX_CANON:
    751       1.23   mycroft 		*ap->a_retval = MAX_CANON;
    752       1.23   mycroft 		return (0);
    753       1.23   mycroft 	case _PC_MAX_INPUT:
    754       1.23   mycroft 		*ap->a_retval = MAX_INPUT;
    755       1.23   mycroft 		return (0);
    756       1.23   mycroft 	case _PC_PIPE_BUF:
    757       1.23   mycroft 		*ap->a_retval = PIPE_BUF;
    758       1.23   mycroft 		return (0);
    759       1.23   mycroft 	case _PC_CHOWN_RESTRICTED:
    760       1.23   mycroft 		*ap->a_retval = 1;
    761       1.23   mycroft 		return (0);
    762       1.23   mycroft 	case _PC_VDISABLE:
    763       1.23   mycroft 		*ap->a_retval = _POSIX_VDISABLE;
    764       1.59    kleink 		return (0);
    765       1.59    kleink 	case _PC_SYNC_IO:
    766       1.59    kleink 		*ap->a_retval = 1;
    767       1.23   mycroft 		return (0);
    768       1.23   mycroft 	default:
    769       1.23   mycroft 		return (EINVAL);
    770       1.23   mycroft 	}
    771       1.23   mycroft 	/* NOTREACHED */
    772       1.23   mycroft }
    773       1.23   mycroft 
    774       1.23   mycroft /*
    775       1.23   mycroft  * Print out the contents of a /dev/fd vnode.
    776        1.1       cgd  */
    777        1.1       cgd /* ARGSUSED */
    778       1.41  christos int
    779       1.41  christos kernfs_print(v)
    780       1.41  christos 	void *v;
    781       1.23   mycroft {
    782       1.23   mycroft 
    783       1.47  christos 	printf("tag VT_KERNFS, kernfs vnode\n");
    784       1.23   mycroft 	return (0);
    785       1.23   mycroft }
    786       1.23   mycroft 
    787       1.40   mycroft int
    788       1.41  christos kernfs_link(v)
    789       1.41  christos 	void *v;
    790       1.41  christos {
    791       1.40   mycroft 	struct vop_link_args /* {
    792       1.40   mycroft 		struct vnode *a_dvp;
    793       1.40   mycroft 		struct vnode *a_vp;
    794       1.40   mycroft 		struct componentname *a_cnp;
    795       1.41  christos 	} */ *ap = v;
    796       1.40   mycroft 
    797       1.40   mycroft 	VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
    798       1.40   mycroft 	vput(ap->a_dvp);
    799       1.40   mycroft 	return (EROFS);
    800       1.40   mycroft }
    801       1.40   mycroft 
    802       1.40   mycroft int
    803       1.41  christos kernfs_symlink(v)
    804       1.41  christos 	void *v;
    805       1.41  christos {
    806       1.40   mycroft 	struct vop_symlink_args /* {
    807       1.40   mycroft 		struct vnode *a_dvp;
    808       1.40   mycroft 		struct vnode **a_vpp;
    809       1.40   mycroft 		struct componentname *a_cnp;
    810       1.40   mycroft 		struct vattr *a_vap;
    811       1.40   mycroft 		char *a_target;
    812       1.41  christos 	} */ *ap = v;
    813       1.40   mycroft 
    814       1.40   mycroft 	VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
    815       1.40   mycroft 	vput(ap->a_dvp);
    816       1.40   mycroft 	return (EROFS);
    817        1.1       cgd }
    818