Home | History | Annotate | Line # | Download | only in udf
udf_vnops.c revision 1.10.8.2
      1  1.10.8.2      matt /* $NetBSD: udf_vnops.c,v 1.10.8.2 2008/01/09 01:55:54 matt Exp $ */
      2       1.1   reinoud 
      3       1.1   reinoud /*
      4       1.1   reinoud  * Copyright (c) 2006 Reinoud Zandijk
      5       1.1   reinoud  * All rights reserved.
      6       1.1   reinoud  *
      7       1.1   reinoud  * Redistribution and use in source and binary forms, with or without
      8       1.1   reinoud  * modification, are permitted provided that the following conditions
      9       1.1   reinoud  * are met:
     10       1.1   reinoud  * 1. Redistributions of source code must retain the above copyright
     11       1.1   reinoud  *    notice, this list of conditions and the following disclaimer.
     12       1.1   reinoud  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1   reinoud  *    notice, this list of conditions and the following disclaimer in the
     14       1.1   reinoud  *    documentation and/or other materials provided with the distribution.
     15       1.1   reinoud  * 3. All advertising materials mentioning features or use of this software
     16       1.1   reinoud  *    must display the following acknowledgement:
     17       1.1   reinoud  *          This product includes software developed for the
     18       1.1   reinoud  *          NetBSD Project.  See http://www.NetBSD.org/ for
     19       1.1   reinoud  *          information about NetBSD.
     20       1.1   reinoud  * 4. The name of the author may not be used to endorse or promote products
     21       1.1   reinoud  *    derived from this software without specific prior written permission.
     22       1.1   reinoud  *
     23       1.1   reinoud  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24       1.1   reinoud  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1   reinoud  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1   reinoud  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27       1.1   reinoud  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28       1.1   reinoud  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29       1.1   reinoud  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30       1.1   reinoud  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31       1.1   reinoud  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32       1.1   reinoud  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1   reinoud  *
     34       1.1   reinoud  */
     35       1.1   reinoud 
     36       1.1   reinoud 
     37       1.1   reinoud #include <sys/cdefs.h>
     38       1.1   reinoud #ifndef lint
     39  1.10.8.2      matt __KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.10.8.2 2008/01/09 01:55:54 matt Exp $");
     40       1.1   reinoud #endif /* not lint */
     41       1.1   reinoud 
     42       1.1   reinoud 
     43       1.1   reinoud #include <sys/param.h>
     44       1.1   reinoud #include <sys/systm.h>
     45       1.1   reinoud #include <sys/namei.h>
     46       1.1   reinoud #include <sys/resourcevar.h>	/* defines plimit structure in proc struct */
     47       1.1   reinoud #include <sys/kernel.h>
     48       1.1   reinoud #include <sys/file.h>		/* define FWRITE ... */
     49       1.1   reinoud #include <sys/stat.h>
     50       1.1   reinoud #include <sys/buf.h>
     51       1.1   reinoud #include <sys/proc.h>
     52       1.1   reinoud #include <sys/mount.h>
     53       1.1   reinoud #include <sys/vnode.h>
     54       1.1   reinoud #include <sys/signalvar.h>
     55       1.1   reinoud #include <sys/malloc.h>
     56       1.1   reinoud #include <sys/dirent.h>
     57       1.1   reinoud #include <sys/lockf.h>
     58       1.1   reinoud 
     59       1.1   reinoud #include <miscfs/genfs/genfs.h>
     60       1.1   reinoud #include <uvm/uvm_extern.h>
     61       1.1   reinoud 
     62       1.1   reinoud #include <fs/udf/ecma167-udf.h>
     63       1.1   reinoud #include <fs/udf/udf_mount.h>
     64       1.1   reinoud #include "udf.h"
     65       1.1   reinoud #include "udf_subr.h"
     66       1.1   reinoud #include "udf_bswap.h"
     67       1.1   reinoud 
     68       1.1   reinoud 
     69       1.1   reinoud #define VTOI(vnode) ((struct udf_node *) vnode->v_data)
     70       1.1   reinoud 
     71       1.1   reinoud 
     72       1.1   reinoud /* externs */
     73       1.1   reinoud extern int prtactive;
     74       1.1   reinoud 
     75       1.1   reinoud 
     76       1.1   reinoud /* implementations of vnode functions; table follows at end */
     77       1.1   reinoud /* --------------------------------------------------------------------- */
     78       1.1   reinoud 
     79       1.1   reinoud int
     80       1.1   reinoud udf_inactive(void *v)
     81       1.1   reinoud {
     82       1.1   reinoud 	struct vop_inactive_args /* {
     83       1.1   reinoud 		struct vnode *a_vp;
     84       1.1   reinoud 		struct proc *a_p;
     85       1.1   reinoud 	} */ *ap = v;
     86       1.1   reinoud 	struct vnode *vp = ap->a_vp;
     87       1.1   reinoud 
     88       1.1   reinoud 	if (prtactive && vp->v_usecount != 0)
     89       1.1   reinoud 		vprint("udf_inactive(): pushing active", vp);
     90       1.1   reinoud 
     91       1.1   reinoud 	VOP_UNLOCK(vp, 0);
     92       1.1   reinoud 
     93       1.1   reinoud 	DPRINTF(LOCKING, ("udf_inactive called for node %p\n", VTOI(vp)));
     94       1.1   reinoud 
     95       1.1   reinoud 	/*
     96       1.1   reinoud 	 * Optionally flush metadata to disc. If the file has not been
     97       1.1   reinoud 	 * referenced anymore in a directory we ought to free up the resources
     98       1.1   reinoud 	 * on disc if applicable.
     99       1.1   reinoud 	 */
    100       1.1   reinoud 
    101       1.1   reinoud 	return 0;
    102       1.1   reinoud }
    103       1.1   reinoud 
    104       1.1   reinoud /* --------------------------------------------------------------------- */
    105       1.1   reinoud 
    106       1.1   reinoud int
    107       1.1   reinoud udf_reclaim(void *v)
    108       1.1   reinoud {
    109       1.1   reinoud 	struct vop_reclaim_args /* {
    110       1.1   reinoud 		struct vnode *a_vp;
    111       1.1   reinoud 	} */ *ap = v;
    112       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    113       1.1   reinoud 	struct udf_node *node = VTOI(vp);
    114       1.1   reinoud 
    115       1.1   reinoud 	if (prtactive && vp->v_usecount != 0)
    116       1.1   reinoud 		vprint("udf_reclaim(): pushing active", vp);
    117       1.1   reinoud 
    118       1.1   reinoud 	/* purge old data from namei */
    119       1.1   reinoud 	cache_purge(vp);
    120       1.1   reinoud 
    121       1.1   reinoud 	DPRINTF(LOCKING, ("udf_reclaim called for node %p\n", node));
    122       1.1   reinoud 	/* dispose all node knowledge */
    123       1.1   reinoud 	udf_dispose_node(node);
    124       1.1   reinoud 
    125       1.1   reinoud 	return 0;
    126       1.1   reinoud }
    127       1.1   reinoud 
    128       1.1   reinoud /* --------------------------------------------------------------------- */
    129       1.1   reinoud 
    130       1.1   reinoud int
    131       1.1   reinoud udf_read(void *v)
    132       1.1   reinoud {
    133       1.1   reinoud 	struct vop_read_args /* {
    134       1.1   reinoud 		struct vnode *a_vp;
    135       1.1   reinoud 		struct uio *a_uio;
    136       1.1   reinoud 		int a_ioflag;
    137       1.5      elad 		kauth_cred_t a_cred;
    138       1.1   reinoud 	} */ *ap = v;
    139       1.1   reinoud 	struct vnode *vp     = ap->a_vp;
    140       1.1   reinoud 	struct uio   *uio    = ap->a_uio;
    141       1.1   reinoud 	int           ioflag = ap->a_ioflag;
    142       1.1   reinoud 	struct uvm_object    *uobj;
    143       1.1   reinoud 	struct udf_node      *udf_node = VTOI(vp);
    144       1.1   reinoud 	struct file_entry    *fe;
    145       1.1   reinoud 	struct extfile_entry *efe;
    146       1.1   reinoud 	uint64_t file_size;
    147       1.1   reinoud 	vsize_t len;
    148       1.1   reinoud 	void *win;
    149       1.1   reinoud 	int error;
    150       1.1   reinoud 	int flags;
    151       1.1   reinoud 
    152       1.1   reinoud 	/* XXX how to deal with xtended attributes (files) */
    153       1.1   reinoud 
    154       1.1   reinoud 	DPRINTF(READ, ("udf_read called\n"));
    155       1.1   reinoud 
    156       1.1   reinoud 	/* can this happen? some filingsystems have this check */
    157       1.1   reinoud 	if (uio->uio_offset < 0)
    158       1.1   reinoud 		return EINVAL;
    159       1.1   reinoud 
    160       1.1   reinoud 	assert(udf_node);
    161       1.1   reinoud 	assert(udf_node->fe || udf_node->efe);
    162       1.1   reinoud 
    163       1.1   reinoud 	/* TODO set access time */
    164       1.1   reinoud 
    165       1.1   reinoud 	/* get directory filesize */
    166       1.1   reinoud 	if (udf_node->fe) {
    167       1.1   reinoud 		fe = udf_node->fe;
    168       1.1   reinoud 		file_size = udf_rw64(fe->inf_len);
    169       1.1   reinoud 	} else {
    170       1.1   reinoud 		assert(udf_node->efe);
    171       1.1   reinoud 		efe = udf_node->efe;
    172       1.1   reinoud 		file_size = udf_rw64(efe->inf_len);
    173       1.6  christos 	}
    174       1.1   reinoud 
    175       1.1   reinoud 	if (vp->v_type == VDIR) {
    176       1.1   reinoud 		/* protect against rogue programs reading raw directories */
    177       1.1   reinoud 		if ((ioflag & IO_ALTSEMANTICS) == 0)
    178       1.1   reinoud 			return EISDIR;
    179       1.6  christos 	}
    180       1.1   reinoud 	if (vp->v_type == VREG || vp->v_type == VDIR) {
    181       1.1   reinoud 		const int advice = IO_ADV_DECODE(ap->a_ioflag);
    182       1.1   reinoud 
    183       1.1   reinoud 		/* read contents using buffercache */
    184       1.1   reinoud 		uobj = &vp->v_uobj;
    185       1.1   reinoud 		flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0;
    186       1.1   reinoud 		error = 0;
    187       1.1   reinoud 		while (uio->uio_resid > 0) {
    188       1.1   reinoud 			/* reached end? */
    189       1.1   reinoud 			if (file_size <= uio->uio_offset)
    190       1.1   reinoud 				break;
    191       1.1   reinoud 
    192       1.1   reinoud 			/* maximise length to file extremity */
    193       1.1   reinoud 			len = MIN(file_size - uio->uio_offset, uio->uio_resid);
    194       1.1   reinoud 			if (len == 0)
    195       1.1   reinoud 				break;
    196       1.1   reinoud 
    197       1.1   reinoud 			/* ubc, here we come, prepare to trap */
    198       1.1   reinoud 			win = ubc_alloc(uobj, uio->uio_offset, &len,
    199       1.1   reinoud 					advice, UBC_READ);
    200       1.1   reinoud 			error = uiomove(win, len, uio);
    201       1.1   reinoud 			ubc_release(win, flags);
    202       1.1   reinoud 			if (error)
    203       1.1   reinoud 				break;
    204       1.1   reinoud 		}
    205       1.1   reinoud 		/* TODO note access time */
    206       1.1   reinoud 		return error;
    207       1.6  christos 	}
    208       1.1   reinoud 
    209       1.1   reinoud 	return EINVAL;
    210       1.1   reinoud }
    211       1.1   reinoud 
    212       1.1   reinoud /* --------------------------------------------------------------------- */
    213       1.1   reinoud 
    214       1.1   reinoud int
    215       1.1   reinoud udf_write(void *v)
    216       1.1   reinoud {
    217       1.1   reinoud 	struct vop_write_args /* {
    218       1.1   reinoud 		struct vnode *a_vp;
    219       1.1   reinoud 		struct uio *a_uio;
    220       1.1   reinoud 		int a_ioflag;
    221       1.5      elad 		kauth_cred_t a_cred;
    222       1.1   reinoud 	} */ *ap = v;
    223       1.1   reinoud 
    224       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_write called\n"));
    225       1.1   reinoud 	ap = ap;	/* shut up gcc */
    226       1.1   reinoud 
    227       1.1   reinoud 	/* TODO implement writing */
    228       1.1   reinoud 	return EROFS;
    229       1.1   reinoud }
    230       1.1   reinoud 
    231       1.1   reinoud 
    232       1.1   reinoud /* --------------------------------------------------------------------- */
    233       1.1   reinoud 
    234       1.1   reinoud /*
    235       1.1   reinoud  * `Special' bmap functionality that translates all incomming requests to
    236       1.1   reinoud  * translate to vop_strategy() calls with the same blocknumbers effectively
    237       1.1   reinoud  * not translating at all.
    238       1.1   reinoud  */
    239       1.1   reinoud 
    240       1.1   reinoud int
    241       1.1   reinoud udf_trivial_bmap(void *v)
    242       1.1   reinoud {
    243       1.1   reinoud 	struct vop_bmap_args /* {
    244       1.1   reinoud 		struct vnode *a_vp;
    245       1.1   reinoud 		daddr_t a_bn;
    246       1.1   reinoud 		struct vnode **a_vpp;
    247       1.1   reinoud 		daddr_t *a_bnp;
    248       1.1   reinoud 		int *a_runp;
    249       1.1   reinoud 	} */ *ap = v;
    250       1.1   reinoud 	struct vnode  *vp  = ap->a_vp;	/* our node	*/
    251       1.1   reinoud 	struct vnode **vpp = ap->a_vpp;	/* return node	*/
    252       1.1   reinoud 	daddr_t *bnp  = ap->a_bnp;	/* translated	*/
    253       1.1   reinoud 	daddr_t  bn   = ap->a_bn;	/* origional	*/
    254       1.1   reinoud 	int     *runp = ap->a_runp;
    255       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    256       1.1   reinoud 	uint32_t lb_size;
    257       1.1   reinoud 
    258       1.1   reinoud 	/* get logical block size */
    259       1.1   reinoud 	lb_size = udf_rw32(udf_node->ump->logical_vol->lb_size);
    260       1.1   reinoud 
    261       1.1   reinoud 	/* could return `-1' to indicate holes/zeros */
    262       1.1   reinoud 	/* translate 1:1 */
    263       1.1   reinoud 	*bnp = bn;
    264       1.1   reinoud 
    265       1.1   reinoud 	/* set the vnode to read the data from with strategy on itself */
    266       1.1   reinoud 	if (vpp)
    267       1.1   reinoud 		*vpp = vp;
    268       1.1   reinoud 
    269       1.1   reinoud 	/* set runlength of maximum block size */
    270       1.1   reinoud 	if (runp)
    271       1.1   reinoud 		*runp = MAXPHYS / lb_size;	/* or with -1 ? */
    272       1.1   reinoud 
    273       1.1   reinoud 	/* return success */
    274       1.1   reinoud 	return 0;
    275       1.1   reinoud }
    276       1.1   reinoud 
    277       1.1   reinoud /* --------------------------------------------------------------------- */
    278       1.1   reinoud 
    279       1.1   reinoud int
    280       1.1   reinoud udf_strategy(void *v)
    281       1.1   reinoud {
    282       1.1   reinoud 	struct vop_strategy_args /* {
    283       1.1   reinoud 		struct vnode *a_vp;
    284       1.1   reinoud 		struct buf *a_bp;
    285       1.1   reinoud 	} */ *ap = v;
    286       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    287       1.1   reinoud 	struct buf   *bp = ap->a_bp;
    288       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    289       1.1   reinoud 	uint32_t lb_size, from, sectors;
    290       1.1   reinoud 	int error;
    291       1.1   reinoud 
    292       1.1   reinoud 	DPRINTF(STRATEGY, ("udf_strategy called\n"));
    293       1.1   reinoud 
    294       1.1   reinoud 	/* check if we ought to be here */
    295       1.1   reinoud 	if (vp->v_type == VBLK || vp->v_type == VCHR)
    296       1.1   reinoud 		panic("udf_strategy: spec");
    297       1.1   reinoud 
    298       1.1   reinoud 	/* only filebuffers ought to be read by this, no descriptors */
    299       1.1   reinoud 	assert(bp->b_blkno >= 0);
    300       1.1   reinoud 
    301       1.1   reinoud 	/* get sector size */
    302       1.1   reinoud 	lb_size = udf_rw32(udf_node->ump->logical_vol->lb_size);
    303       1.1   reinoud 
    304       1.1   reinoud 	/* calculate sector to start from */
    305       1.1   reinoud 	from = bp->b_blkno;
    306       1.1   reinoud 
    307       1.1   reinoud 	/* calculate length to fetch/store in sectors */
    308       1.1   reinoud 	sectors = bp->b_bcount / lb_size;
    309       1.1   reinoud 	assert(bp->b_bcount > 0);
    310       1.1   reinoud 
    311       1.3       snj 	/* NEVER assume later that this buffer is already translated */
    312       1.1   reinoud 	/* bp->b_lblkno = bp->b_blkno; */
    313       1.1   reinoud 
    314       1.1   reinoud 	DPRINTF(STRATEGY, ("\tread vp %p buf %p (blk no %"PRIu64")"
    315       1.1   reinoud 	    ", sector %d for %d sectors\n",
    316       1.1   reinoud 	    vp, bp, bp->b_blkno, from, sectors));
    317       1.1   reinoud 
    318      1.10   msaitoh 	/* check assertions: we OUGHT to always get multiples of this */
    319       1.1   reinoud 	assert(sectors * lb_size == bp->b_bcount);
    320       1.1   reinoud 
    321       1.1   reinoud 	/* determine mode */
    322       1.1   reinoud 	error = 0;
    323       1.1   reinoud 	if (bp->b_flags & B_READ) {
    324       1.1   reinoud 		/* read buffer from the udf_node, translate vtop on the way*/
    325       1.1   reinoud 		udf_read_filebuf(udf_node, bp);
    326       1.1   reinoud 		return bp->b_error;
    327       1.6  christos 	}
    328       1.1   reinoud 
    329       1.1   reinoud 	printf("udf_strategy: can't write yet\n");
    330       1.1   reinoud 	return ENOTSUP;
    331       1.1   reinoud }
    332       1.1   reinoud 
    333       1.1   reinoud /* --------------------------------------------------------------------- */
    334       1.1   reinoud 
    335       1.1   reinoud int
    336       1.1   reinoud udf_readdir(void *v)
    337       1.1   reinoud {
    338       1.1   reinoud 	struct vop_readdir_args /* {
    339       1.1   reinoud 		struct vnode *a_vp;
    340       1.1   reinoud 		struct uio *a_uio;
    341       1.5      elad 		kauth_cred_t a_cred;
    342       1.1   reinoud 		int *a_eofflag;
    343       1.1   reinoud 		off_t **a_cookies;
    344       1.1   reinoud 		int *a_ncookies;
    345       1.1   reinoud 	} */ *ap = v;
    346       1.1   reinoud 	struct uio *uio = ap->a_uio;
    347       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    348       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    349       1.1   reinoud 	struct file_entry    *fe;
    350       1.1   reinoud 	struct extfile_entry *efe;
    351       1.1   reinoud 	struct fileid_desc *fid;
    352  1.10.8.1      matt 	struct dirent *dirent;
    353       1.1   reinoud 	uint64_t file_size, diroffset, transoffset;
    354       1.1   reinoud 	uint32_t lb_size;
    355       1.1   reinoud 	int error;
    356       1.1   reinoud 
    357       1.1   reinoud 	DPRINTF(READDIR, ("udf_readdir called\n"));
    358       1.1   reinoud 
    359       1.1   reinoud 	/* This operation only makes sense on directory nodes. */
    360       1.1   reinoud 	if (vp->v_type != VDIR)
    361       1.1   reinoud 		return ENOTDIR;
    362       1.1   reinoud 
    363       1.1   reinoud 	/* get directory filesize */
    364       1.1   reinoud 	if (udf_node->fe) {
    365       1.1   reinoud 		fe = udf_node->fe;
    366       1.1   reinoud 		file_size = udf_rw64(fe->inf_len);
    367       1.1   reinoud 	} else {
    368       1.1   reinoud 		assert(udf_node->efe);
    369       1.1   reinoud 		efe = udf_node->efe;
    370       1.1   reinoud 		file_size = udf_rw64(efe->inf_len);
    371       1.6  christos 	}
    372       1.1   reinoud 
    373  1.10.8.1      matt 	dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK | M_ZERO);
    374  1.10.8.1      matt 
    375       1.1   reinoud 	/*
    376       1.1   reinoud 	 * Add `.' pseudo entry if at offset zero since its not in the fid
    377       1.1   reinoud 	 * stream
    378       1.1   reinoud 	 */
    379       1.1   reinoud 	if (uio->uio_offset == 0) {
    380       1.1   reinoud 		DPRINTF(READDIR, ("\t'.' inserted\n"));
    381  1.10.8.1      matt 		strcpy(dirent->d_name, ".");
    382  1.10.8.1      matt 		dirent->d_fileno = udf_calchash(&udf_node->loc);
    383  1.10.8.1      matt 		dirent->d_type = DT_DIR;
    384  1.10.8.1      matt 		dirent->d_namlen = strlen(dirent->d_name);
    385  1.10.8.1      matt 		dirent->d_reclen = _DIRENT_SIZE(dirent);
    386  1.10.8.1      matt 		uiomove(dirent, _DIRENT_SIZE(dirent), uio);
    387       1.1   reinoud 
    388       1.1   reinoud 		/* mark with magic value that we have done the dummy */
    389       1.1   reinoud 		uio->uio_offset = UDF_DIRCOOKIE_DOT;
    390       1.6  christos 	}
    391       1.1   reinoud 
    392       1.1   reinoud 	/* we are called just as long as we keep on pushing data in */
    393       1.1   reinoud 	error = 0;
    394       1.1   reinoud 	if ((uio->uio_offset < file_size) &&
    395       1.1   reinoud 	    (uio->uio_resid >= sizeof(struct dirent))) {
    396       1.1   reinoud 		/* allocate temporary space for fid */
    397       1.1   reinoud 		lb_size = udf_rw32(udf_node->ump->logical_vol->lb_size);
    398  1.10.8.1      matt 		fid = malloc(lb_size, M_UDFTEMP, M_WAITOK);
    399       1.1   reinoud 
    400       1.1   reinoud 		if (uio->uio_offset == UDF_DIRCOOKIE_DOT)
    401       1.1   reinoud 			uio->uio_offset = 0;
    402       1.1   reinoud 
    403       1.1   reinoud 		diroffset   = uio->uio_offset;
    404       1.1   reinoud 		transoffset = diroffset;
    405       1.1   reinoud 		while (diroffset < file_size) {
    406       1.1   reinoud 			DPRINTF(READDIR, ("\tread in fid stream\n"));
    407       1.1   reinoud 			/* transfer a new fid/dirent */
    408       1.1   reinoud 			error = udf_read_fid_stream(vp, &diroffset,
    409  1.10.8.1      matt 				    fid, dirent);
    410       1.1   reinoud 			DPRINTFIF(READDIR, error, ("read error in read fid "
    411       1.1   reinoud 			    "stream : %d\n", error));
    412       1.1   reinoud 			if (error)
    413       1.1   reinoud 				break;
    414       1.1   reinoud 
    415       1.1   reinoud 			/*
    416       1.1   reinoud 			 * If there isn't enough space in the uio to return a
    417       1.1   reinoud 			 * whole dirent, break off read
    418       1.1   reinoud 			 */
    419  1.10.8.1      matt 			if (uio->uio_resid < _DIRENT_SIZE(dirent))
    420       1.1   reinoud 				break;
    421       1.1   reinoud 
    422       1.1   reinoud 			/* remember the last entry we transfered */
    423       1.1   reinoud 			transoffset = diroffset;
    424       1.1   reinoud 
    425       1.1   reinoud 			/* skip deleted entries */
    426       1.1   reinoud 			if (fid->file_char & UDF_FILE_CHAR_DEL)
    427       1.1   reinoud 				continue;
    428       1.1   reinoud 
    429       1.1   reinoud 			/* skip not visible files */
    430       1.1   reinoud 			if (fid->file_char & UDF_FILE_CHAR_VIS)
    431       1.1   reinoud 				continue;
    432       1.1   reinoud 
    433       1.1   reinoud 			/* copy dirent to the caller */
    434       1.1   reinoud 			DPRINTF(READDIR, ("\tread dirent `%s', type %d\n",
    435  1.10.8.1      matt 			    dirent->d_name, dirent->d_type));
    436  1.10.8.1      matt 			uiomove(dirent, _DIRENT_SIZE(dirent), uio);
    437       1.6  christos 		}
    438       1.1   reinoud 
    439       1.1   reinoud 		/* pass on last transfered offset */
    440       1.1   reinoud 		uio->uio_offset = transoffset;
    441  1.10.8.1      matt 		free(fid, M_UDFTEMP);
    442       1.6  christos 	}
    443       1.1   reinoud 
    444       1.1   reinoud 	if (ap->a_eofflag)
    445       1.1   reinoud 		*ap->a_eofflag = (uio->uio_offset == file_size);
    446       1.1   reinoud 
    447       1.1   reinoud #ifdef DEBUG
    448       1.1   reinoud 	if (udf_verbose & UDF_DEBUG_READDIR) {
    449       1.1   reinoud 		printf("returning offset %d\n", (uint32_t) uio->uio_offset);
    450       1.1   reinoud 		if (ap->a_eofflag)
    451       1.1   reinoud 			printf("returning EOF ? %d\n", *ap->a_eofflag);
    452       1.1   reinoud 		if (error)
    453       1.1   reinoud 			printf("readdir returning error %d\n", error);
    454       1.6  christos 	}
    455       1.1   reinoud #endif
    456       1.1   reinoud 
    457  1.10.8.1      matt 	free(dirent, M_UDFTEMP);
    458       1.1   reinoud 	return error;
    459       1.1   reinoud }
    460       1.1   reinoud 
    461       1.1   reinoud /* --------------------------------------------------------------------- */
    462       1.1   reinoud 
    463       1.1   reinoud int
    464       1.1   reinoud udf_lookup(void *v)
    465       1.1   reinoud {
    466       1.1   reinoud 	struct vop_lookup_args /* {
    467       1.1   reinoud 		struct vnode *a_dvp;
    468       1.1   reinoud 		struct vnode **a_vpp;
    469       1.1   reinoud 		struct componentname *a_cnp;
    470       1.1   reinoud 	} */ *ap = v;
    471       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
    472       1.1   reinoud 	struct vnode **vpp = ap->a_vpp;
    473       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
    474       1.1   reinoud 	struct udf_node  *dir_node, *res_node;
    475       1.1   reinoud 	struct udf_mount *ump;
    476       1.1   reinoud 	struct long_ad    icb_loc;
    477       1.1   reinoud 	const char *name;
    478       1.8       chs 	int namelen, nameiop, islastcn, mounted_ro;
    479       1.1   reinoud 	int vnodetp;
    480       1.1   reinoud 	int error, found;
    481       1.1   reinoud 
    482       1.1   reinoud 	dir_node = VTOI(dvp);
    483       1.1   reinoud 	ump = dir_node->ump;
    484       1.1   reinoud 	*vpp = NULL;
    485       1.1   reinoud 
    486       1.1   reinoud 	DPRINTF(LOOKUP, ("udf_lookup called\n"));
    487       1.1   reinoud 
    488       1.1   reinoud 	/* simplify/clarification flags */
    489       1.1   reinoud 	nameiop     = cnp->cn_nameiop;
    490       1.1   reinoud 	islastcn    = cnp->cn_flags & ISLASTCN;
    491       1.1   reinoud 	mounted_ro  = dvp->v_mount->mnt_flag & MNT_RDONLY;
    492       1.1   reinoud 
    493       1.1   reinoud 	/* check exec/dirread permissions first */
    494  1.10.8.2      matt 	error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred);
    495       1.1   reinoud 	if (error)
    496       1.1   reinoud 		return error;
    497       1.1   reinoud 
    498       1.1   reinoud 	DPRINTF(LOOKUP, ("\taccess ok\n"));
    499       1.1   reinoud 
    500       1.1   reinoud 	/*
    501       1.1   reinoud 	 * If requesting a modify on the last path element on a read-only
    502       1.1   reinoud 	 * filingsystem, reject lookup; XXX why is this repeated in every FS ?
    503       1.1   reinoud 	 */
    504       1.1   reinoud 	if (islastcn && mounted_ro && (nameiop == DELETE || nameiop == RENAME))
    505       1.1   reinoud 		return EROFS;
    506       1.1   reinoud 
    507       1.1   reinoud 	DPRINTF(LOOKUP, ("\tlooking up cnp->cn_nameptr '%s'\n",
    508       1.1   reinoud 	    cnp->cn_nameptr));
    509       1.1   reinoud 	/* look in the nami cache; returns 0 on success!! */
    510       1.1   reinoud 	error = cache_lookup(dvp, vpp, cnp);
    511       1.1   reinoud 	if (error >= 0)
    512       1.1   reinoud 		return error;
    513       1.1   reinoud 
    514       1.1   reinoud 	DPRINTF(LOOKUP, ("\tNOT found in cache\n"));
    515       1.1   reinoud 
    516       1.1   reinoud 	/*
    517       1.1   reinoud 	 * Obviously, the file is not (anymore) in the namecache, we have to
    518       1.1   reinoud 	 * search for it. There are three basic cases: '.', '..' and others.
    519       1.1   reinoud 	 *
    520       1.1   reinoud 	 * Following the guidelines of VOP_LOOKUP manpage and tmpfs.
    521       1.1   reinoud 	 */
    522       1.1   reinoud 	error = 0;
    523       1.1   reinoud 	if ((cnp->cn_namelen == 1) && (cnp->cn_nameptr[0] == '.')) {
    524       1.1   reinoud 		DPRINTF(LOOKUP, ("\tlookup '.'\n"));
    525       1.1   reinoud 		/* special case 1 '.' */
    526       1.1   reinoud 		VREF(dvp);
    527       1.1   reinoud 		*vpp = dvp;
    528       1.1   reinoud 		/* done */
    529       1.1   reinoud 	} else if (cnp->cn_flags & ISDOTDOT) {
    530       1.1   reinoud 		/* special case 2 '..' */
    531       1.1   reinoud 		DPRINTF(LOOKUP, ("\tlookup '..'\n"));
    532       1.1   reinoud 
    533       1.1   reinoud 		/* first unlock parent */
    534       1.1   reinoud 		VOP_UNLOCK(dvp, 0);
    535       1.1   reinoud 
    536       1.1   reinoud 		/* get our node */
    537       1.1   reinoud 		name    = "..";
    538       1.1   reinoud 		namelen = 2;
    539       1.1   reinoud 		found = udf_lookup_name_in_dir(dvp, name, namelen, &icb_loc);
    540       1.1   reinoud 		if (!found)
    541       1.1   reinoud 			error = ENOENT;
    542       1.1   reinoud 
    543       1.1   reinoud 		if (!error) {
    544       1.1   reinoud 			DPRINTF(LOOKUP, ("\tfound '..'\n"));
    545       1.1   reinoud 			/* try to create/reuse the node */
    546       1.1   reinoud 			error = udf_get_node(ump, &icb_loc, &res_node);
    547       1.1   reinoud 
    548       1.1   reinoud 			if (!error) {
    549       1.1   reinoud 			DPRINTF(LOOKUP, ("\tnode retrieved/created OK\n"));
    550       1.1   reinoud 				*vpp = res_node->vnode;
    551       1.6  christos 			}
    552       1.6  christos 		}
    553       1.1   reinoud 
    554       1.8       chs 		/* try to relock parent */
    555       1.8       chs 		vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
    556       1.1   reinoud 	} else {
    557       1.1   reinoud 		DPRINTF(LOOKUP, ("\tlookup file\n"));
    558       1.1   reinoud 		/* all other files */
    559       1.1   reinoud 		/* lookup filename in the directory; location icb_loc */
    560       1.1   reinoud 		name    = cnp->cn_nameptr;
    561       1.1   reinoud 		namelen = cnp->cn_namelen;
    562       1.1   reinoud 		found = udf_lookup_name_in_dir(dvp, name, namelen, &icb_loc);
    563       1.1   reinoud 		if (!found) {
    564       1.1   reinoud 			DPRINTF(LOOKUP, ("\tNOT found\n"));
    565       1.1   reinoud 			/*
    566       1.1   reinoud 			 * UGH, didn't find name. If we're creating or naming
    567       1.1   reinoud 			 * on the last name this is OK and we ought to return
    568       1.1   reinoud 			 * EJUSTRETURN if its allowed to be created.
    569       1.1   reinoud 			 */
    570       1.1   reinoud 			error = ENOENT;
    571       1.1   reinoud 			if (islastcn &&
    572       1.1   reinoud 				(nameiop == CREATE || nameiop == RENAME))
    573       1.1   reinoud 					error = 0;
    574       1.1   reinoud 			if (!error) {
    575  1.10.8.2      matt 				error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred);
    576       1.1   reinoud 				if (!error) {
    577       1.1   reinoud 					/* keep the component name */
    578       1.1   reinoud 					cnp->cn_flags |= SAVENAME;
    579       1.1   reinoud 					error = EJUSTRETURN;
    580       1.6  christos 				}
    581       1.6  christos 			}
    582       1.1   reinoud 			/* done */
    583       1.1   reinoud 		} else {
    584       1.1   reinoud 			/* try to create/reuse the node */
    585       1.1   reinoud 			error = udf_get_node(ump, &icb_loc, &res_node);
    586       1.1   reinoud 			if (!error) {
    587       1.1   reinoud 				/*
    588       1.1   reinoud 				 * If we are not at the last path component
    589       1.1   reinoud 				 * and found a non-directory or non-link entry
    590       1.1   reinoud 				 * (which may itself be pointing to a
    591       1.1   reinoud 				 * directory), raise an error.
    592       1.1   reinoud 				 */
    593       1.1   reinoud 				vnodetp = res_node->vnode->v_type;
    594       1.1   reinoud 				if ((vnodetp != VDIR) && (vnodetp != VLNK)) {
    595       1.1   reinoud 					if (!islastcn)
    596       1.1   reinoud 						error = ENOTDIR;
    597       1.1   reinoud 				}
    598       1.1   reinoud 
    599       1.6  christos 			}
    600       1.1   reinoud 			if (!error) {
    601       1.1   reinoud 				*vpp = res_node->vnode;
    602       1.6  christos 			}
    603       1.6  christos 		}
    604       1.1   reinoud 	}
    605       1.1   reinoud 
    606       1.1   reinoud 	/*
    607       1.1   reinoud 	 * Store result in the cache if requested. If we are creating a file,
    608       1.1   reinoud 	 * the file might not be found and thus putting it into the namecache
    609       1.1   reinoud 	 * might be seen as negative caching.
    610       1.1   reinoud 	 */
    611       1.1   reinoud 	if (cnp->cn_flags & MAKEENTRY)
    612       1.1   reinoud 		cache_enter(dvp, *vpp, cnp);
    613       1.1   reinoud 
    614       1.1   reinoud 	DPRINTFIF(LOOKUP, error, ("udf_lookup returing error %d\n", error));
    615       1.1   reinoud 
    616       1.1   reinoud 	return error;
    617       1.1   reinoud }
    618       1.1   reinoud 
    619       1.1   reinoud /* --------------------------------------------------------------------- */
    620       1.1   reinoud 
    621       1.1   reinoud int
    622       1.1   reinoud udf_getattr(void *v)
    623       1.1   reinoud {
    624       1.1   reinoud 	struct vop_getattr_args /* {
    625       1.1   reinoud 		struct vnode *a_vp;
    626       1.1   reinoud 		struct vattr *a_vap;
    627       1.5      elad 		kauth_cred_t a_cred;
    628       1.1   reinoud 		struct proc *a_p;
    629       1.1   reinoud 	} */ *ap = v;
    630       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    631       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    632       1.1   reinoud 	struct udf_mount *ump = udf_node->ump;
    633       1.1   reinoud 	struct vattr *vap = ap->a_vap;
    634       1.1   reinoud 	struct file_entry *fe;
    635       1.1   reinoud 	struct extfile_entry *efe;
    636       1.1   reinoud 	struct timestamp *atime, *mtime, *attrtime;
    637       1.1   reinoud 	uint32_t nlink;
    638       1.1   reinoud 	uint64_t filesize, blkssize;
    639       1.1   reinoud 	uid_t uid;
    640       1.1   reinoud 	gid_t gid;
    641       1.1   reinoud 
    642       1.1   reinoud 	DPRINTF(CALL, ("udf_getattr called\n"));
    643       1.1   reinoud 
    644       1.1   reinoud 	/* get descriptor information */
    645       1.1   reinoud 	if (udf_node->fe) {
    646       1.1   reinoud 		fe = udf_node->fe;
    647       1.1   reinoud 		nlink    = udf_rw16(fe->link_cnt);
    648       1.1   reinoud 		uid      = (uid_t)udf_rw32(fe->uid);
    649       1.1   reinoud 		gid      = (gid_t)udf_rw32(fe->gid);
    650       1.1   reinoud 		filesize = udf_rw64(fe->inf_len);
    651       1.1   reinoud 		blkssize = udf_rw64(fe->logblks_rec);
    652       1.1   reinoud 		atime    = &fe->atime;
    653       1.1   reinoud 		mtime    = &fe->mtime;
    654       1.1   reinoud 		attrtime = &fe->attrtime;
    655       1.1   reinoud 	} else {
    656       1.1   reinoud 		assert(udf_node->efe);
    657       1.1   reinoud 		efe = udf_node->efe;
    658       1.1   reinoud 		nlink    = udf_rw16(efe->link_cnt);
    659       1.1   reinoud 		uid      = (uid_t)udf_rw32(efe->uid);
    660       1.1   reinoud 		gid      = (gid_t)udf_rw32(efe->gid);
    661       1.1   reinoud 		filesize = udf_rw64(efe->inf_len);	/* XXX or obj_size? */
    662       1.1   reinoud 		blkssize = udf_rw64(efe->logblks_rec);
    663       1.1   reinoud 		atime    = &efe->atime;
    664       1.1   reinoud 		mtime    = &efe->mtime;
    665       1.1   reinoud 		attrtime = &efe->attrtime;
    666       1.6  christos 	}
    667       1.1   reinoud 
    668       1.1   reinoud 	/* do the uid/gid translation game */
    669       1.1   reinoud 	if ((uid == (uid_t) -1) && (gid == (gid_t) -1)) {
    670       1.1   reinoud 		uid = ump->mount_args.anon_uid;
    671       1.1   reinoud 		gid = ump->mount_args.anon_gid;
    672       1.6  christos 	}
    673       1.1   reinoud 
    674       1.1   reinoud 	/* fill in struct vattr with values from the node */
    675       1.1   reinoud 	VATTR_NULL(vap);
    676       1.1   reinoud 	vap->va_type      = vp->v_type;
    677       1.1   reinoud 	vap->va_mode      = udf_getaccessmode(udf_node);
    678       1.1   reinoud 	vap->va_nlink     = nlink;
    679       1.1   reinoud 	vap->va_uid       = uid;
    680       1.1   reinoud 	vap->va_gid       = gid;
    681       1.1   reinoud 	vap->va_fsid      = vp->v_mount->mnt_stat.f_fsidx.__fsid_val[0];
    682       1.1   reinoud 	vap->va_fileid    = udf_calchash(&udf_node->loc);   /* inode hash XXX */
    683       1.1   reinoud 	vap->va_size      = filesize;
    684       1.1   reinoud 	vap->va_blocksize = udf_node->ump->discinfo.sector_size;  /* wise? */
    685       1.1   reinoud 
    686       1.1   reinoud 	/*
    687       1.1   reinoud 	 * BUG-ALERT: UDF doesn't count '.' as an entry, so we'll have to add
    688       1.1   reinoud 	 * 1 to the link count if its a directory we're requested attributes
    689       1.1   reinoud 	 * of.
    690       1.1   reinoud 	 */
    691       1.1   reinoud 	if (vap->va_type == VDIR)
    692       1.1   reinoud 		vap->va_nlink++;
    693       1.1   reinoud 
    694       1.1   reinoud 	/* access times */
    695       1.1   reinoud 	udf_timestamp_to_timespec(ump, atime,    &vap->va_atime);
    696       1.1   reinoud 	udf_timestamp_to_timespec(ump, mtime,    &vap->va_mtime);
    697       1.1   reinoud 	udf_timestamp_to_timespec(ump, attrtime, &vap->va_ctime);
    698       1.1   reinoud 
    699       1.1   reinoud 	vap->va_gen       = 1;		/* no multiple generations yes (!?) */
    700       1.1   reinoud 	vap->va_flags     = 0;		/* no flags */
    701       1.1   reinoud 	vap->va_rdev      = udf_node->rdev;
    702       1.9   reinoud 	vap->va_bytes     = blkssize * udf_node->ump->discinfo.sector_size;
    703       1.1   reinoud 	vap->va_filerev   = 1;		/* TODO file revision numbers? */
    704       1.1   reinoud 	vap->va_vaflags   = 0;		/* TODO which va_vaflags? */
    705       1.1   reinoud 
    706       1.1   reinoud 	return 0;
    707       1.1   reinoud }
    708       1.1   reinoud 
    709       1.1   reinoud /* --------------------------------------------------------------------- */
    710       1.1   reinoud 
    711       1.1   reinoud int
    712       1.1   reinoud udf_setattr(void *v)
    713       1.1   reinoud {
    714       1.1   reinoud 	struct vop_setattr_args /* {
    715       1.1   reinoud 		struct vnode *a_vp;
    716       1.1   reinoud 		struct vattr *a_vap;
    717       1.5      elad 		kauth_cred_t a_cred;
    718       1.1   reinoud 		struct proc *a_p;
    719       1.1   reinoud 	} */ *ap = v;
    720       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    721       1.1   reinoud 	struct udf_node  *udf_node = VTOI(vp);
    722       1.1   reinoud 	struct udf_mount *ump = udf_node->ump;
    723       1.1   reinoud 	struct vattr *vap = ap->a_vap;
    724       1.1   reinoud 	uid_t uid, nobody_uid;
    725       1.1   reinoud 	gid_t gid, nobody_gid;
    726       1.1   reinoud 
    727       1.1   reinoud 	/* shut up gcc for now */
    728       1.1   reinoud 	ap = ap;
    729       1.1   reinoud 	vp = vp;
    730       1.4       mrg 	uid = 0;	/* XXX gcc */
    731       1.4       mrg 	gid = 0;	/* XXX gcc */
    732       1.1   reinoud 	udf_node = udf_node;
    733       1.1   reinoud 
    734       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_setattr called\n"));
    735       1.1   reinoud 
    736       1.1   reinoud 	/*
    737       1.1   reinoud 	 * BUG-ALERT: UDF doesn't count '.' as an entry, so we'll have to
    738       1.1   reinoud 	 * subtract 1 to the link count if its a directory we're setting
    739       1.1   reinoud 	 * attributes on. See getattr.
    740       1.1   reinoud 	 */
    741       1.1   reinoud 	if (vap->va_type == VDIR)
    742       1.1   reinoud 		vap->va_nlink--;
    743       1.1   reinoud 
    744       1.1   reinoud 	/* do the uid/gid translation game */
    745       1.1   reinoud 	nobody_uid = ump->mount_args.nobody_uid;
    746       1.1   reinoud 	nobody_gid = ump->mount_args.nobody_gid;
    747       1.1   reinoud 	if ((uid == nobody_uid) && (gid == nobody_gid)) {
    748       1.1   reinoud 		uid = (uid_t) -1;
    749       1.1   reinoud 		gid = (gid_t) -1;
    750       1.6  christos 	}
    751       1.1   reinoud 
    752       1.1   reinoud 	/* TODO implement setattr!! NOT IMPLEMENTED yet */
    753       1.1   reinoud 	return 0;
    754       1.1   reinoud }
    755       1.1   reinoud 
    756       1.1   reinoud /* --------------------------------------------------------------------- */
    757       1.1   reinoud 
    758       1.1   reinoud /*
    759       1.1   reinoud  * Return POSIX pathconf information for UDF file systems.
    760       1.1   reinoud  */
    761       1.1   reinoud int
    762       1.1   reinoud udf_pathconf(void *v)
    763       1.1   reinoud {
    764       1.1   reinoud 	struct vop_pathconf_args /* {
    765       1.1   reinoud 		struct vnode *a_vp;
    766       1.1   reinoud 		int a_name;
    767       1.1   reinoud 		register_t *a_retval;
    768       1.1   reinoud 	} */ *ap = v;
    769       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    770       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    771       1.1   reinoud 	uint32_t bits;
    772       1.1   reinoud 
    773       1.1   reinoud 	DPRINTF(CALL, ("udf_pathconf called\n"));
    774       1.1   reinoud 
    775       1.1   reinoud 	switch (ap->a_name) {
    776       1.1   reinoud 	case _PC_LINK_MAX:
    777       1.1   reinoud 		*ap->a_retval = (1<<16)-1;	/* 16 bits */
    778       1.1   reinoud 		return 0;
    779       1.1   reinoud 	case _PC_NAME_MAX:
    780       1.1   reinoud 		*ap->a_retval = NAME_MAX;
    781       1.1   reinoud 		return 0;
    782       1.1   reinoud 	case _PC_PATH_MAX:
    783       1.1   reinoud 		*ap->a_retval = PATH_MAX;
    784       1.1   reinoud 		return 0;
    785       1.1   reinoud 	case _PC_PIPE_BUF:
    786       1.1   reinoud 		*ap->a_retval = PIPE_BUF;
    787       1.1   reinoud 		return 0;
    788       1.1   reinoud 	case _PC_CHOWN_RESTRICTED:
    789       1.1   reinoud 		*ap->a_retval = 1;
    790       1.1   reinoud 		return 0;
    791       1.1   reinoud 	case _PC_NO_TRUNC:
    792       1.1   reinoud 		*ap->a_retval = 1;
    793       1.1   reinoud 		return 0;
    794       1.1   reinoud 	case _PC_SYNC_IO:
    795       1.1   reinoud 		*ap->a_retval = 0;     /* synchronised is off for performance */
    796       1.1   reinoud 		return 0;
    797       1.1   reinoud 	case _PC_FILESIZEBITS:
    798       1.1   reinoud 		bits = 32;
    799       1.1   reinoud 		if (udf_node)
    800       1.1   reinoud 			bits = 32 * vp->v_mount->mnt_dev_bshift;
    801       1.1   reinoud 		*ap->a_retval = bits;
    802       1.1   reinoud 		return 0;
    803       1.6  christos 	}
    804       1.1   reinoud 
    805       1.1   reinoud 	return EINVAL;
    806       1.1   reinoud }
    807       1.1   reinoud 
    808       1.1   reinoud 
    809       1.1   reinoud /* --------------------------------------------------------------------- */
    810       1.1   reinoud 
    811       1.1   reinoud int
    812       1.1   reinoud udf_open(void *v)
    813       1.1   reinoud {
    814       1.1   reinoud 	struct vop_open_args /* {
    815       1.1   reinoud 		struct vnode *a_vp;
    816       1.1   reinoud 		int a_mode;
    817       1.5      elad 		kauth_cred_t a_cred;
    818       1.1   reinoud 		struct proc *a_p;
    819       1.7  christos 	} */ *ap = v;
    820       1.1   reinoud 
    821       1.1   reinoud 	DPRINTF(CALL, ("udf_open called\n"));
    822       1.4       mrg 	ap = 0;		/* XXX gcc */
    823       1.1   reinoud 
    824       1.1   reinoud 	return 0;
    825       1.1   reinoud }
    826       1.1   reinoud 
    827       1.1   reinoud 
    828       1.1   reinoud /* --------------------------------------------------------------------- */
    829       1.1   reinoud 
    830       1.1   reinoud int
    831       1.1   reinoud udf_close(void *v)
    832       1.1   reinoud {
    833       1.1   reinoud 	struct vop_close_args /* {
    834       1.1   reinoud 		struct vnode *a_vp;
    835       1.1   reinoud 		int a_fflag;
    836       1.5      elad 		kauth_cred_t a_cred;
    837       1.1   reinoud 		struct proc *a_p;
    838       1.1   reinoud 	} */ *ap = v;
    839       1.1   reinoud 	struct vnode *vp = ap->a_vp;
    840       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    841       1.1   reinoud 
    842       1.1   reinoud 	DPRINTF(CALL, ("udf_close called\n"));
    843       1.1   reinoud 	udf_node = udf_node;	/* shut up gcc */
    844       1.1   reinoud 
    845  1.10.8.2      matt 	mutex_enter(&vp->v_interlock);
    846       1.1   reinoud 		if (vp->v_usecount > 1) {
    847       1.1   reinoud 			/* TODO update times */
    848       1.6  christos 		}
    849  1.10.8.2      matt 	mutex_exit(&vp->v_interlock);
    850       1.1   reinoud 
    851       1.1   reinoud 	return 0;
    852       1.1   reinoud }
    853       1.1   reinoud 
    854       1.1   reinoud 
    855       1.1   reinoud /* --------------------------------------------------------------------- */
    856       1.1   reinoud 
    857       1.1   reinoud int
    858       1.1   reinoud udf_access(void *v)
    859       1.1   reinoud {
    860       1.1   reinoud 	struct vop_access_args /* {
    861       1.1   reinoud 		struct vnode *a_vp;
    862       1.1   reinoud 		int a_mode;
    863       1.5      elad 		kauth_cred_t a_cred;
    864       1.1   reinoud 		struct proc *a_p;
    865       1.1   reinoud 	} */ *ap = v;
    866       1.1   reinoud 	struct vnode    *vp   = ap->a_vp;
    867       1.1   reinoud 	mode_t	         mode = ap->a_mode;
    868       1.5      elad 	kauth_cred_t    cred = ap->a_cred;
    869       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
    870       1.1   reinoud 	struct file_entry    *fe;
    871       1.1   reinoud 	struct extfile_entry *efe;
    872       1.1   reinoud 	mode_t   node_mode;
    873       1.1   reinoud 	uid_t uid;
    874       1.1   reinoud 	gid_t gid;
    875       1.1   reinoud 
    876       1.1   reinoud 	DPRINTF(CALL, ("udf_access called\n"));
    877       1.1   reinoud 
    878       1.1   reinoud 	/* get access mode to compare to */
    879       1.1   reinoud 	node_mode = udf_getaccessmode(udf_node);
    880       1.1   reinoud 
    881       1.1   reinoud 	/* get uid/gid pair */
    882       1.1   reinoud 	if (udf_node->fe) {
    883       1.1   reinoud 		fe = udf_node->fe;
    884       1.1   reinoud 		uid = (uid_t)udf_rw32(fe->uid);
    885       1.1   reinoud 		gid = (gid_t)udf_rw32(fe->gid);
    886       1.1   reinoud 	} else {
    887       1.1   reinoud 		assert(udf_node->efe);
    888       1.1   reinoud 		efe = udf_node->efe;
    889       1.1   reinoud 		uid = (uid_t)udf_rw32(efe->uid);
    890       1.1   reinoud 		gid = (gid_t)udf_rw32(efe->gid);
    891       1.6  christos 	}
    892       1.1   reinoud 
    893       1.1   reinoud 	/* check if we are allowed to write */
    894       1.1   reinoud 	switch (vp->v_type) {
    895       1.1   reinoud 	case VDIR:
    896       1.1   reinoud 	case VLNK:
    897       1.1   reinoud 	case VREG:
    898       1.1   reinoud 		/*
    899       1.1   reinoud 		 * normal nodes: check if we're on a read-only mounted
    900       1.1   reinoud 		 * filingsystem and bomb out if we're trying to write.
    901       1.1   reinoud 		 */
    902       1.1   reinoud 		if ((mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY))
    903       1.1   reinoud 			return EROFS;
    904       1.1   reinoud 		break;
    905       1.1   reinoud 	case VBLK:
    906       1.1   reinoud 	case VCHR:
    907       1.1   reinoud 	case VSOCK:
    908       1.1   reinoud 	case VFIFO:
    909       1.1   reinoud 		/*
    910       1.1   reinoud 		 * special nodes: even on read-only mounted filingsystems
    911       1.1   reinoud 		 * these are allowed to be written to if permissions allow.
    912       1.1   reinoud 		 */
    913       1.1   reinoud 		break;
    914       1.1   reinoud 	default:
    915       1.1   reinoud 		/* no idea what this is */
    916       1.1   reinoud 		return EINVAL;
    917       1.1   reinoud 	}
    918       1.1   reinoud 
    919       1.1   reinoud 	/* TODO support for chflags checking i.e. IMMUTABLE flag */
    920       1.1   reinoud 
    921       1.1   reinoud 	/* ask the generic vaccess to advice on security */
    922       1.1   reinoud 	return vaccess(vp->v_type, node_mode, uid, gid, mode, cred);
    923       1.1   reinoud }
    924       1.1   reinoud 
    925       1.1   reinoud /* --------------------------------------------------------------------- */
    926       1.1   reinoud 
    927       1.1   reinoud int
    928       1.1   reinoud udf_create(void *v)
    929       1.1   reinoud {
    930       1.1   reinoud 	struct vop_create_args /* {
    931       1.1   reinoud 		struct vnode *a_dvp;
    932       1.1   reinoud 		struct vnode **a_vpp;
    933       1.1   reinoud 		struct componentname *a_cnp;
    934       1.1   reinoud 		struct vattr *a_vap;
    935       1.1   reinoud 	} */ *ap = v;
    936       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
    937       1.1   reinoud 
    938       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_create called\n"));
    939       1.1   reinoud 
    940       1.1   reinoud 	/* error out */
    941       1.1   reinoud 	PNBUF_PUT(cnp->cn_pnbuf);
    942       1.1   reinoud 	vput(ap->a_dvp);
    943       1.1   reinoud 	return ENOTSUP;
    944       1.1   reinoud }
    945       1.1   reinoud 
    946       1.1   reinoud /* --------------------------------------------------------------------- */
    947       1.1   reinoud 
    948       1.1   reinoud int
    949       1.1   reinoud udf_mknod(void *v)
    950       1.1   reinoud {
    951       1.1   reinoud 	struct vop_mknod_args /* {
    952       1.1   reinoud 		struct vnode *a_dvp;
    953       1.1   reinoud 		struct vnode **a_vpp;
    954       1.1   reinoud 		struct componentname *a_cnp;
    955       1.1   reinoud 		struct vattr *a_vap;
    956       1.1   reinoud 	} */ *ap = v;
    957       1.1   reinoud 
    958       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_mknod called\n"));
    959       1.1   reinoud 
    960       1.1   reinoud 	/* error out */
    961       1.1   reinoud 	PNBUF_PUT(ap->a_cnp->cn_pnbuf);
    962       1.1   reinoud 	vput(ap->a_dvp);
    963       1.1   reinoud 	return ENOTSUP;
    964       1.1   reinoud }
    965       1.1   reinoud 
    966       1.1   reinoud /* --------------------------------------------------------------------- */
    967       1.1   reinoud 
    968       1.1   reinoud int
    969       1.1   reinoud udf_remove(void *v)
    970       1.1   reinoud {
    971       1.1   reinoud 	struct vop_remove_args /* {
    972       1.1   reinoud 		struct vnode *a_dvp;
    973       1.1   reinoud 		struct vnode *a_vp;
    974       1.1   reinoud 		struct componentname *a_cnp;
    975       1.1   reinoud 	} */ *ap = v;
    976       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
    977       1.1   reinoud 	struct vnode *vp  = ap->a_vp;
    978       1.1   reinoud 
    979       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_remove called\n"));
    980       1.1   reinoud 
    981       1.1   reinoud 	/* error out */
    982       1.1   reinoud 	vput(dvp);
    983       1.1   reinoud 	vput(vp);
    984       1.1   reinoud 
    985       1.1   reinoud 	return ENOTSUP;
    986       1.1   reinoud }
    987       1.1   reinoud 
    988       1.1   reinoud /* --------------------------------------------------------------------- */
    989       1.1   reinoud 
    990       1.1   reinoud int
    991       1.1   reinoud udf_link(void *v)
    992       1.1   reinoud {
    993       1.1   reinoud 	struct vop_link_args /* {
    994       1.1   reinoud 		struct vnode *a_dvp;
    995       1.1   reinoud 		struct vnode *a_vp;
    996       1.1   reinoud 		struct componentname *a_cnp;
    997       1.1   reinoud 	} */ *ap = v;
    998       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
    999       1.1   reinoud 	struct vnode *vp  = ap->a_vp;
   1000       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
   1001       1.1   reinoud 
   1002       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_link called\n"));
   1003       1.1   reinoud 
   1004       1.1   reinoud 	/* error out */
   1005       1.1   reinoud 	/* XXX or just VOP_ABORTOP(dvp, a_cnp); ? */
   1006  1.10.8.1      matt 	if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
   1007       1.1   reinoud 		VOP_UNLOCK(vp, 0);
   1008       1.1   reinoud 	PNBUF_PUT(cnp->cn_pnbuf);
   1009       1.1   reinoud 	vput(dvp);
   1010       1.1   reinoud 
   1011       1.1   reinoud 	return ENOTSUP;
   1012       1.1   reinoud }
   1013       1.1   reinoud 
   1014       1.1   reinoud /* --------------------------------------------------------------------- */
   1015       1.1   reinoud 
   1016       1.1   reinoud int
   1017       1.1   reinoud udf_symlink(void *v)
   1018       1.1   reinoud {
   1019       1.1   reinoud 	struct vop_symlink_args /* {
   1020       1.1   reinoud 		struct vnode *a_dvp;
   1021       1.1   reinoud 		struct vnode **a_vpp;
   1022       1.1   reinoud 		struct componentname *a_cnp;
   1023       1.1   reinoud 		struct vattr *a_vap;
   1024       1.1   reinoud 		char *a_target;
   1025       1.1   reinoud 	} */ *ap = v;
   1026       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
   1027       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
   1028       1.1   reinoud 
   1029       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_symlink called\n"));
   1030       1.1   reinoud 
   1031       1.1   reinoud 	/* error out */
   1032       1.1   reinoud 	VOP_ABORTOP(dvp, cnp);
   1033       1.1   reinoud 	vput(dvp);
   1034       1.1   reinoud 
   1035       1.1   reinoud 	return ENOTSUP;
   1036       1.1   reinoud }
   1037       1.1   reinoud 
   1038       1.1   reinoud /* --------------------------------------------------------------------- */
   1039       1.1   reinoud 
   1040       1.1   reinoud int
   1041       1.1   reinoud udf_readlink(void *v)
   1042       1.1   reinoud {
   1043       1.1   reinoud 	struct vop_readlink_args /* {
   1044       1.1   reinoud 		struct vnode *a_vp;
   1045       1.1   reinoud 		struct uio *a_uio;
   1046       1.5      elad 		kauth_cred_t a_cred;
   1047       1.1   reinoud 	} */ *ap = v;
   1048       1.1   reinoud #ifdef notyet
   1049       1.1   reinoud 	struct vnode *vp = ap->a_vp;
   1050       1.1   reinoud 	struct uio *uio = ap->a_uio;
   1051       1.5      elad 	kauth_cred_t cred = ap->a_cred;
   1052       1.1   reinoud #endif
   1053       1.1   reinoud 
   1054       1.1   reinoud 	ap = ap;	/* shut up gcc */
   1055       1.1   reinoud 
   1056       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_readlink called\n"));
   1057       1.1   reinoud 
   1058       1.1   reinoud 	/* TODO read `file' contents and process pathcomponents into a path */
   1059       1.1   reinoud 	return ENOTSUP;
   1060       1.1   reinoud }
   1061       1.1   reinoud 
   1062       1.1   reinoud /* --------------------------------------------------------------------- */
   1063       1.1   reinoud 
   1064       1.1   reinoud int
   1065       1.1   reinoud udf_rename(void *v)
   1066       1.1   reinoud {
   1067       1.1   reinoud 	struct vop_rename_args /* {
   1068       1.1   reinoud 		struct vnode *a_fdvp;
   1069       1.1   reinoud 		struct vnode *a_fvp;
   1070       1.1   reinoud 		struct componentname *a_fcnp;
   1071       1.1   reinoud 		struct vnode *a_tdvp;
   1072       1.1   reinoud 		struct vnode *a_tvp;
   1073       1.1   reinoud 		struct componentname *a_tcnp;
   1074       1.1   reinoud 	} */ *ap = v;
   1075       1.1   reinoud 	struct vnode *tvp = ap->a_tvp;
   1076       1.1   reinoud 	struct vnode *tdvp = ap->a_tdvp;
   1077       1.1   reinoud 	struct vnode *fvp = ap->a_fvp;
   1078       1.1   reinoud 	struct vnode *fdvp = ap->a_fdvp;
   1079       1.1   reinoud 
   1080       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_rename called\n"));
   1081       1.1   reinoud 
   1082       1.1   reinoud 	/* error out */
   1083       1.1   reinoud 	if (tdvp == tvp)
   1084       1.1   reinoud 		vrele(tdvp);
   1085       1.1   reinoud 	else
   1086       1.1   reinoud 		vput(tdvp);
   1087       1.1   reinoud 	if (tvp != NULL)
   1088       1.1   reinoud 		vput(tvp);
   1089       1.1   reinoud 
   1090       1.1   reinoud 	/* release source nodes. */
   1091       1.1   reinoud 	vrele(fdvp);
   1092       1.1   reinoud 	vrele(fvp);
   1093       1.1   reinoud 
   1094       1.1   reinoud 	return ENOTSUP;
   1095       1.1   reinoud }
   1096       1.1   reinoud 
   1097       1.1   reinoud /* --------------------------------------------------------------------- */
   1098       1.1   reinoud 
   1099       1.1   reinoud int
   1100       1.1   reinoud udf_mkdir(void *v)
   1101       1.1   reinoud {
   1102       1.1   reinoud 	struct vop_mkdir_args /* {
   1103       1.1   reinoud 		struct vnode *a_dvp;
   1104       1.1   reinoud 		struct vnode **a_vpp;
   1105       1.1   reinoud 		struct componentname *a_cnp;
   1106       1.1   reinoud 		struct vattr *a_vap;
   1107       1.1   reinoud 	} */ *ap = v;
   1108       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
   1109       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
   1110       1.1   reinoud 
   1111       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_mkdir called\n"));
   1112       1.1   reinoud 
   1113       1.1   reinoud 	/* error out */
   1114       1.1   reinoud 	PNBUF_PUT(cnp->cn_pnbuf);
   1115       1.1   reinoud 	vput(dvp);
   1116       1.1   reinoud 
   1117       1.1   reinoud 	return ENOTSUP;
   1118       1.1   reinoud }
   1119       1.1   reinoud 
   1120       1.1   reinoud /* --------------------------------------------------------------------- */
   1121       1.1   reinoud 
   1122       1.1   reinoud int
   1123       1.1   reinoud udf_rmdir(void *v)
   1124       1.1   reinoud {
   1125       1.1   reinoud 	struct vop_rmdir_args /* {
   1126       1.1   reinoud 		struct vnode *a_dvp;
   1127       1.1   reinoud 		struct vnode *a_vp;
   1128       1.1   reinoud 		struct componentname *a_cnp;
   1129       1.1   reinoud 	} */ *ap = v;
   1130       1.1   reinoud 	struct vnode *vp = ap->a_vp;
   1131       1.1   reinoud 	struct vnode *dvp = ap->a_dvp;
   1132       1.1   reinoud 	struct componentname *cnp = ap->a_cnp;
   1133       1.1   reinoud 	int error;
   1134       1.1   reinoud 
   1135       1.1   reinoud 	cnp = cnp;	/* shut up gcc */
   1136       1.1   reinoud 
   1137       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_rmdir called\n"));
   1138       1.1   reinoud 
   1139       1.1   reinoud 	error = ENOTSUP;
   1140       1.1   reinoud 	/* error out */
   1141       1.1   reinoud 	if (error != 0) {
   1142       1.1   reinoud 		vput(dvp);
   1143       1.1   reinoud 		vput(vp);
   1144       1.1   reinoud 	}
   1145       1.1   reinoud 
   1146       1.1   reinoud 	return error;
   1147       1.1   reinoud }
   1148       1.1   reinoud 
   1149       1.1   reinoud /* --------------------------------------------------------------------- */
   1150       1.1   reinoud 
   1151       1.1   reinoud int
   1152       1.1   reinoud udf_fsync(void *v)
   1153       1.1   reinoud {
   1154       1.1   reinoud 	struct vop_fsync_args /* {
   1155       1.1   reinoud 		struct vnode *a_vp;
   1156       1.5      elad 		kauth_cred_t a_cred;
   1157       1.1   reinoud 		int a_flags;
   1158       1.1   reinoud 		off_t offlo;
   1159       1.1   reinoud 		off_t offhi;
   1160       1.1   reinoud 		struct proc *a_p;
   1161       1.1   reinoud 	} */ *ap = v;
   1162       1.1   reinoud 	struct vnode *vp = ap->a_vp;
   1163       1.1   reinoud 
   1164       1.1   reinoud 	DPRINTF(NOTIMPL, ("udf_fsync called\n"));
   1165       1.1   reinoud 
   1166       1.1   reinoud 	vp = vp;	/* shut up gcc */
   1167       1.1   reinoud 
   1168       1.1   reinoud 	return 0;
   1169       1.1   reinoud }
   1170       1.1   reinoud 
   1171       1.1   reinoud /* --------------------------------------------------------------------- */
   1172       1.1   reinoud 
   1173       1.1   reinoud int
   1174       1.1   reinoud udf_advlock(void *v)
   1175       1.1   reinoud {
   1176       1.1   reinoud 	struct vop_advlock_args /* {
   1177       1.1   reinoud 		struct vnode *a_vp;
   1178       1.1   reinoud 		void *a_id;
   1179       1.1   reinoud 		int a_op;
   1180       1.1   reinoud 		struct flock *a_fl;
   1181       1.1   reinoud 		int a_flags;
   1182       1.1   reinoud 	} */ *ap = v;
   1183       1.1   reinoud 	struct vnode *vp = ap->a_vp;
   1184       1.1   reinoud 	struct udf_node *udf_node = VTOI(vp);
   1185       1.1   reinoud 	struct file_entry    *fe;
   1186       1.1   reinoud 	struct extfile_entry *efe;
   1187       1.1   reinoud 	uint64_t file_size;
   1188       1.1   reinoud 
   1189       1.1   reinoud 	DPRINTF(LOCKING, ("udf_advlock called\n"));
   1190       1.1   reinoud 
   1191       1.1   reinoud 	/* get directory filesize */
   1192       1.1   reinoud 	if (udf_node->fe) {
   1193       1.1   reinoud 		fe = udf_node->fe;
   1194       1.1   reinoud 		file_size = udf_rw64(fe->inf_len);
   1195       1.1   reinoud 	} else {
   1196       1.1   reinoud 		assert(udf_node->efe);
   1197       1.1   reinoud 		efe = udf_node->efe;
   1198       1.1   reinoud 		file_size = udf_rw64(efe->inf_len);
   1199       1.6  christos 	}
   1200       1.1   reinoud 
   1201       1.1   reinoud 	return lf_advlock(ap, &udf_node->lockf, file_size);
   1202       1.1   reinoud }
   1203       1.1   reinoud 
   1204       1.1   reinoud /* --------------------------------------------------------------------- */
   1205       1.1   reinoud 
   1206       1.1   reinoud 
   1207       1.1   reinoud /* Global vfs vnode data structures for udfs */
   1208       1.1   reinoud int (**udf_vnodeop_p) __P((void *));
   1209       1.1   reinoud 
   1210       1.1   reinoud const struct vnodeopv_entry_desc udf_vnodeop_entries[] = {
   1211       1.1   reinoud 	{ &vop_default_desc, vn_default_error },
   1212       1.1   reinoud 	{ &vop_lookup_desc, udf_lookup },	/* lookup */
   1213       1.1   reinoud 	{ &vop_create_desc, udf_create },	/* create */	/* TODO */
   1214       1.1   reinoud 	{ &vop_mknod_desc, udf_mknod },		/* mknod */	/* TODO */
   1215       1.1   reinoud 	{ &vop_open_desc, udf_open },		/* open */
   1216       1.1   reinoud 	{ &vop_close_desc, udf_close },		/* close */
   1217       1.1   reinoud 	{ &vop_access_desc, udf_access },	/* access */
   1218       1.1   reinoud 	{ &vop_getattr_desc, udf_getattr },	/* getattr */
   1219       1.1   reinoud 	{ &vop_setattr_desc, udf_setattr },	/* setattr */	/* TODO */
   1220       1.1   reinoud 	{ &vop_read_desc, udf_read },		/* read */
   1221       1.1   reinoud 	{ &vop_write_desc, udf_write },		/* write */	/* WRITE */
   1222       1.1   reinoud 	{ &vop_lease_desc, genfs_lease_check },	/* lease */	/* TODO? */
   1223       1.1   reinoud 	{ &vop_fcntl_desc, genfs_fcntl },	/* fcntl */	/* TODO? */
   1224       1.1   reinoud 	{ &vop_ioctl_desc, genfs_enoioctl },	/* ioctl */	/* TODO? */
   1225       1.1   reinoud 	{ &vop_poll_desc, genfs_poll },		/* poll */	/* TODO/OK? */
   1226       1.1   reinoud 	{ &vop_kqfilter_desc, genfs_kqfilter },	/* kqfilter */	/* ? */
   1227       1.1   reinoud 	{ &vop_revoke_desc, genfs_revoke },	/* revoke */	/* TODO? */
   1228       1.1   reinoud 	{ &vop_mmap_desc, genfs_mmap },		/* mmap */	/* OK? */
   1229       1.1   reinoud 	{ &vop_fsync_desc, udf_fsync },		/* fsync */	/* TODO */
   1230       1.1   reinoud 	{ &vop_seek_desc, genfs_seek },		/* seek */
   1231       1.1   reinoud 	{ &vop_remove_desc, udf_remove },	/* remove */ 	/* TODO */
   1232       1.1   reinoud 	{ &vop_link_desc, udf_link },		/* link */	/* TODO */
   1233       1.1   reinoud 	{ &vop_rename_desc, udf_rename },	/* rename */ 	/* TODO */
   1234       1.1   reinoud 	{ &vop_mkdir_desc, udf_mkdir },		/* mkdir */ 	/* TODO */
   1235       1.1   reinoud 	{ &vop_rmdir_desc, udf_rmdir },		/* rmdir */	/* TODO */
   1236       1.1   reinoud 	{ &vop_symlink_desc, udf_symlink },	/* symlink */	/* TODO */
   1237       1.1   reinoud 	{ &vop_readdir_desc, udf_readdir },	/* readdir */
   1238       1.1   reinoud 	{ &vop_readlink_desc, udf_readlink },	/* readlink */	/* TEST ME */
   1239       1.1   reinoud 	{ &vop_abortop_desc, genfs_abortop },	/* abortop */	/* TODO/OK? */
   1240       1.1   reinoud 	{ &vop_inactive_desc, udf_inactive },	/* inactive */
   1241       1.1   reinoud 	{ &vop_reclaim_desc, udf_reclaim },	/* reclaim */
   1242       1.1   reinoud 	{ &vop_lock_desc, genfs_lock },		/* lock */
   1243       1.1   reinoud 	{ &vop_unlock_desc, genfs_unlock },	/* unlock */
   1244       1.1   reinoud 	{ &vop_bmap_desc, udf_trivial_bmap },	/* bmap */	/* 1:1 bmap */
   1245       1.1   reinoud 	{ &vop_strategy_desc, udf_strategy },	/* strategy */
   1246       1.1   reinoud /*	{ &vop_print_desc, udf_print },	*/	/* print */
   1247       1.1   reinoud 	{ &vop_islocked_desc, genfs_islocked },	/* islocked */
   1248       1.1   reinoud 	{ &vop_pathconf_desc, udf_pathconf },	/* pathconf */
   1249       1.1   reinoud 	{ &vop_advlock_desc, udf_advlock },	/* advlock */	/* TEST ME */
   1250       1.1   reinoud 	{ &vop_bwrite_desc, vn_bwrite },	/* bwrite */	/* ->strategy */
   1251       1.1   reinoud 	{ &vop_getpages_desc, genfs_getpages },	/* getpages */
   1252       1.1   reinoud 	{ &vop_putpages_desc, genfs_putpages },	/* putpages */
   1253       1.1   reinoud 	{ NULL, NULL }
   1254       1.1   reinoud };
   1255       1.1   reinoud 
   1256       1.1   reinoud 
   1257       1.1   reinoud const struct vnodeopv_desc udf_vnodeop_opv_desc = {
   1258       1.1   reinoud 	&udf_vnodeop_p, udf_vnodeop_entries
   1259       1.1   reinoud };
   1260       1.1   reinoud 
   1261