The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/xfs/xfs_vnodeops-bsd.c

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan
    3  * (Royal Institute of Technology, Stockholm, Sweden).
    4  * All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  *
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  *
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * 3. Neither the name of the Institute nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  */
   33 
   34 /*
   35  * NNPFS operations.
   36  */
   37 
   38 #ifdef __APPLE__
   39 #define MACH_KERNEL 1
   40 #endif
   41 
   42 #include <xfs/xfs_locl.h>
   43 #include <xfs/xfs_message.h>
   44 #include <xfs/xfs_common.h>
   45 #include <xfs/xfs_fs.h>
   46 #include <xfs/xfs_dev.h>
   47 #include <xfs/xfs_deb.h>
   48 #include <xfs/xfs_syscalls.h>
   49 #include <xfs/xfs_vnodeops.h>
   50 #ifdef HAVE_VM_VNODE_PAGER_H
   51 #include <vm/vnode_pager.h>
   52 #endif
   53 
   54 #include <sys/pool.h>
   55 
   56 RCSID("$arla: xfs_vnodeops-bsd.c,v 1.123 2003/02/15 16:40:36 lha Exp $");
   57 
   58 /*
   59  * vnode functions
   60  */
   61 
   62 #ifdef HAVE_VOP_OPEN
   63 int
   64 xfs_open(struct vop_open_args * ap)
   65      /*
   66   struct vop_open {
   67           struct vnode *vp;
   68           int mode;
   69           struct ucred *cred;
   70           struct proc *p;
   71   }; */
   72 {
   73 #ifdef HAVE_FREEBSD_THREAD
   74     return xfs_open_common (ap->a_vp, ap->a_mode, ap->a_cred, ap->a_td);
   75 #else
   76     return xfs_open_common (ap->a_vp, ap->a_mode, ap->a_cred, ap->a_p);
   77 #endif
   78 }
   79 #endif /* HAVE_VOP_OPEN */
   80 
   81 #ifdef HAVE_VOP_FSYNC
   82 int
   83 xfs_fsync(struct vop_fsync_args * ap)
   84      /*
   85   vop_fsync {
   86         struct vnode *vp;
   87         struct ucred *cred;
   88         int waitfor;
   89         struct proc *p;
   90 };  */
   91 {
   92 #ifdef HAVE_STRUCT_VOP_FSYNC_ARGS_A_FLAGS
   93     return xfs_fsync_common(ap->a_vp, ap->a_cred, ap->a_flags, ap->a_p);
   94 #else
   95 #ifdef HAVE_FREEBSD_THREAD
   96     return xfs_fsync_common(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td);
   97 #else
   98     return xfs_fsync_common(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p);
   99 #endif
  100 #endif
  101 }
  102 #endif /* HAVE_VOP_FSYNC */
  103 
  104 #ifdef HAVE_VOP_CLOSE 
  105 int
  106 xfs_close(struct vop_close_args * ap)
  107      /* vop_close {
  108         IN struct vnode *vp;
  109         IN int fflag;
  110         IN struct ucred *cred;
  111         IN struct proc *p;
  112   }; */
  113 {
  114 #ifdef HAVE_FREEBSD_THREAD
  115     return xfs_close_common(ap->a_vp, ap->a_fflag, ap->a_td, ap->a_cred);
  116 #else
  117     return xfs_close_common(ap->a_vp, ap->a_fflag, ap->a_p, ap->a_cred);
  118 #endif
  119 }
  120 #endif /* HAVE_VOP_CLOSE */
  121 
  122 #ifdef HAVE_VOP_READ
  123 int
  124 xfs_read(struct vop_read_args * ap)
  125      /* vop_read {
  126         IN struct vnode *vp;
  127         INOUT struct uio *uio;
  128         IN int ioflag;
  129         IN struct ucred *cred;
  130    }; */
  131 {
  132     return xfs_read_common(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
  133 }
  134 #endif /* HAVE_VOP_READ */
  135 
  136 #ifdef HAVE_VOP_WRITE
  137 int
  138 xfs_write(struct vop_write_args * ap)
  139      /* vop_write {
  140         IN struct vnode *vp;
  141         INOUT struct uio *uio;
  142         IN int ioflag;
  143         IN struct ucred *cred;
  144    }; */
  145 {
  146     return xfs_write_common(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
  147 }
  148 #endif /* HAVE_VOP_WRITE */
  149 
  150 #ifdef HAVE_VOP_IOCTL
  151 int
  152 xfs_ioctl(struct vop_ioctl_args * ap)
  153      /* struct vnode *vp,
  154           int com,
  155           caddr_t data,
  156           int flag,
  157           struct ucred *cred) */
  158 {
  159     NNPFSDEB(XDEBVNOPS, ("xfs_ioctl\n"));
  160 
  161     return EOPNOTSUPP;
  162 }
  163 #endif /* HAVE_VOP_IOCTL */
  164 
  165 #ifdef HAVE_VOP_SELECT
  166 int
  167 xfs_select(struct vop_select_args * ap)
  168      /* struct vnode *vp,
  169            int which,
  170            struct ucred *cred ) */
  171 {
  172     NNPFSDEB(XDEBVNOPS, ("xfs_select\n"));
  173 
  174     return EOPNOTSUPP;
  175 }
  176 #endif /* HAVE_VOP_SELECT */
  177 
  178 #ifdef HAVE_VOP_SEEK
  179 int
  180 xfs_seek(struct vop_seek_args * ap)
  181      /*
  182 struct vop_seek_args {
  183         struct vnodeop_desc *a_desc;
  184         struct vnode *a_vp;
  185         off_t a_oldoff;
  186         off_t a_newoff;
  187         struct ucred *a_cred;
  188 };
  189 */
  190 {
  191     NNPFSDEB(XDEBVNOPS, ("xfs_seek\n"));
  192     return 0;
  193 }
  194 #endif /* HAVE_VOP_SEEK */
  195 
  196 #ifdef HAVE_VOP_POLL
  197 int
  198 xfs_poll(struct vop_poll_args * ap)
  199      /* vop_poll {
  200         IN struct vnode *vp;
  201         IN int events;
  202         IN struct proc *p;
  203    }; */
  204 {
  205     NNPFSDEB(XDEBVNOPS, ("xfs_poll\n"));
  206     return EOPNOTSUPP;
  207 }
  208 #endif /* HAVE_VOP_POLL */
  209 
  210 #ifdef HAVE_VOP_GETATTR
  211 int
  212 xfs_getattr(struct vop_getattr_args * ap)
  213      /* struct vnode *vp,
  214             struct vattr *vap,
  215             struct ucred *cred,
  216             struct proc *p) */
  217 {
  218 #ifdef HAVE_FREEBSD_THREAD
  219     return xfs_getattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_td);
  220 #else
  221     return xfs_getattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_p);
  222 #endif
  223 }
  224 #endif /* HAVE_VOP_GETATTR */
  225 
  226 #ifdef HAVE_VOP_SETATTR
  227 int
  228 xfs_setattr(struct vop_setattr_args * ap)
  229      /* struct vnode *vp,
  230             struct vattr *vap,
  231             struct ucred *cred,
  232             struct proc *p)
  233             */
  234 {
  235 #ifdef HAVE_FREEBSD_THREAD
  236     return xfs_setattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_td);
  237 #else
  238     return xfs_setattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_p);
  239 #endif
  240 }
  241 #endif /* HAVE_VOP_SETATTR */
  242 
  243 #ifdef HAVE_VOP_ACCESS
  244 int
  245 xfs_access(struct vop_access_args * ap)
  246      /*
  247 struct vnode *vp,
  248            int mode,
  249            struct ucred *cred,
  250            struct proc *p)
  251            */
  252 {
  253 #ifdef HAVE_FREEBSD_THREAD
  254     return xfs_access_common(ap->a_vp, ap->a_mode, ap->a_cred, ap->a_td);
  255 #else
  256     return xfs_access_common(ap->a_vp, ap->a_mode, ap->a_cred, ap->a_p);
  257 #endif
  258 }
  259 #endif /* HAVE_VOP_ACCESS */
  260 
  261 #ifdef HAVE_VOP_LOOKUP
  262 int
  263 xfs_lookup(struct vop_lookup_args * ap)
  264      /* struct vop_lookup_args {
  265         struct vnodeop_desc *a_desc;
  266         struct vnode *a_dvp;
  267         struct vnode **a_vpp;
  268         struct componentname *a_cnp;
  269 }; */
  270 {
  271     struct componentname *cnp = ap->a_cnp;
  272     int error;
  273     int lockparent = (cnp->cn_flags & (LOCKPARENT | ISLASTCN))
  274         == (LOCKPARENT | ISLASTCN);
  275 
  276     NNPFSDEB(XDEBVNOPS, ("xfs_lookup: (%s, %ld), nameiop = %lu, flags = %lu\n",
  277                        cnp->cn_nameptr,
  278                        cnp->cn_namelen,
  279                        cnp->cn_nameiop,
  280                        cnp->cn_flags));
  281 
  282 #ifdef PDIRUNLOCK
  283     cnp->cn_flags &= ~PDIRUNLOCK;
  284 #endif
  285 
  286     error = xfs_lookup_common(ap->a_dvp, cnp, ap->a_vpp);
  287 
  288     if (error == ENOENT
  289         && (cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
  290         && (cnp->cn_flags & ISLASTCN)) {
  291         error = EJUSTRETURN;
  292     }
  293 
  294     if (cnp->cn_nameiop != LOOKUP && cnp->cn_flags & ISLASTCN)
  295         cnp->cn_flags |= SAVENAME;
  296 
  297     if (error == 0 || error == EJUSTRETURN) {
  298         if (ap->a_dvp == *(ap->a_vpp)) {
  299             /* if we looked up ourself, do nothing */
  300         } else if (!(cnp->cn_flags & ISLASTCN) || !lockparent) {
  301             /* if we isn't last component and is isn't requested,
  302              * return parent unlocked */
  303 #ifdef HAVE_FREEBSD_THREAD
  304             xfs_vfs_unlock (ap->a_dvp, xfs_cnp_to_thread(cnp));
  305 #else
  306             xfs_vfs_unlock (ap->a_dvp, xfs_cnp_to_proc(cnp));
  307 #endif
  308 #ifdef PDIRUNLOCK
  309             cnp->cn_flags |= PDIRUNLOCK;
  310 #endif
  311         }
  312     } else {
  313         /* in case of a error do nothing  */
  314     } 
  315     
  316     NNPFSDEB(XDEBVNOPS, ("xfs_lookup: error = %d\n", error));
  317 
  318     return error;
  319 }
  320 #endif /* HAVE_VOP_LOOKUP */
  321 
  322 #ifdef HAVE_VOP_CACHEDLOOKUP
  323 int
  324 xfs_cachedlookup(struct vop_cachedlookup_args * ap)
  325      /* struct vop_cachedlookup_args {
  326         struct vnodeop_desc *a_desc;
  327         struct vnode *a_dvp;
  328         struct vnode **a_vpp;
  329         struct componentname *a_cnp;
  330 }; */
  331 {
  332     return xfs_lookup((struct vop_lookup_args *)ap);
  333 }
  334 #endif /* HAVE_VOP_CACHEDLOOKUP */
  335 
  336 /*
  337  * whatever clean-ups are needed for a componentname.
  338  */
  339 
  340 static void
  341 cleanup_cnp (struct componentname *cnp, int error)
  342 {
  343     if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) {
  344 #if defined(HAVE_KERNEL_ZFREEI)
  345         zfreei(namei_zone, cnp->cn_pnbuf);
  346         cnp->cn_flags &= ~HASBUF;
  347 #elif defined(HAVE_KERNEL_UMA_ZFREE_ARG)
  348         uma_zfree_arg(namei_zone, cnp->cn_pnbuf, NULL);
  349         cnp->cn_flags &= ~HASBUF;
  350 #elif defined(FREE_ZONE)
  351         FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
  352 #elif defined(HAVE_KERNEL_ZFREE)
  353         zfree(namei_zone, cnp->cn_pnbuf);
  354         cnp->cn_flags &= ~HASBUF;
  355 #elif defined(PNBUF_PUT)
  356         PNBUF_PUT(cnp->cn_pnbuf);
  357 #else
  358         pool_put(&namei_pool, cnp->cn_pnbuf);
  359 #endif
  360     }
  361 }
  362 
  363 #ifdef HAVE_VOP_CREATE
  364 int
  365 xfs_create(struct vop_create_args *ap)
  366 {
  367     struct vnode *dvp  = ap->a_dvp;
  368     struct componentname *cnp = ap->a_cnp;
  369     const char *name   = cnp->cn_nameptr;
  370     struct ucred *cred = cnp->cn_cred;
  371 #ifdef HAVE_FREEBSD_THREAD
  372     d_thread_t *p     = xfs_cnp_to_thread(cnp);
  373 #else
  374     d_thread_t *p     = xfs_cnp_to_proc(cnp);
  375 #endif
  376     int error;
  377 
  378     error = xfs_create_common(dvp, name, ap->a_vap, cred, p);
  379 
  380     if (error == 0) {
  381         error = xfs_lookup_common(dvp, cnp, ap->a_vpp);
  382     }
  383 
  384     cleanup_cnp (cnp, error);
  385 
  386 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
  387     vput (dvp);
  388 #endif
  389 
  390     NNPFSDEB(XDEBVNOPS, ("xfs_create: error = %d\n", error));
  391     
  392     return error;
  393 }
  394 #endif /* HAVE_VOP_CREATE */
  395 
  396 #ifdef HAVE_VOP_REMOVE
  397 int
  398 xfs_remove(struct vop_remove_args * ap)
  399      /* struct vnode *dvp,
  400    struct vnode *vp,
  401    struct componentname *cnp */
  402 {
  403     struct componentname *cnp = ap->a_cnp;
  404     struct vnode *dvp = ap->a_dvp;
  405     struct vnode *vp  = ap->a_vp;
  406 
  407 #ifdef HAVE_FREEBSD_THREAD
  408     int error = xfs_remove_common(dvp, vp, cnp->cn_nameptr, 
  409                                   cnp->cn_cred, xfs_cnp_to_thread(cnp));
  410 #else
  411     int error = xfs_remove_common(dvp, vp, cnp->cn_nameptr, 
  412                                   cnp->cn_cred, xfs_cnp_to_proc(cnp));
  413 #endif
  414 
  415     cleanup_cnp (cnp, error);
  416 
  417 #if !defined(__FreeBSD__) || __FreeBSD_version < 300000
  418     if (dvp == vp)
  419         vrele(vp);
  420     else
  421         vput(vp);
  422     vput(dvp);
  423 #endif
  424     
  425 #ifdef __APPLE__
  426     if (error == 0) {
  427         if (UBCINFOEXISTS(vp)) {
  428             ubc_setsize(vp, 0);
  429             ubc_release(vp);
  430             ubc_uncache(vp);
  431         }
  432     }
  433 #endif
  434 
  435     return error;
  436 }
  437 #endif /* HAVE_VOP_REMOVE */
  438 
  439 #ifdef HAVE_VOP_RENAME
  440 int
  441 xfs_rename(struct vop_rename_args * ap)
  442      /* vop_rename {
  443         IN WILLRELE struct vnode *fdvp;
  444         IN WILLRELE struct vnode *fvp;
  445         IN struct componentname *fcnp;
  446         IN WILLRELE struct vnode *tdvp;
  447         IN WILLRELE struct vnode *tvp;
  448         IN struct componentname *tcnp;
  449   }; */
  450 {
  451     struct vnode *tdvp = ap->a_tdvp;
  452     struct vnode *tvp  = ap->a_tvp;
  453     struct vnode *fdvp = ap->a_fdvp;
  454     struct vnode *fvp  = ap->a_fvp;
  455 
  456     int error = xfs_rename_common(fdvp,
  457                                   fvp,
  458                                   ap->a_fcnp->cn_nameptr,
  459                                   tdvp,
  460                                   tvp,
  461                                   ap->a_tcnp->cn_nameptr,
  462                                   ap->a_tcnp->cn_cred,
  463 #ifdef HAVE_FREEBSD_THREAD
  464                                   xfs_cnp_to_thread (ap->a_fcnp));
  465 #else
  466                                   xfs_cnp_to_proc (ap->a_fcnp));
  467 #endif
  468     if(tdvp == tvp)
  469         vrele(tdvp);
  470     else
  471         vput(tdvp);
  472     if(tvp)
  473         vput(tvp);
  474     vrele(fdvp);
  475     vrele(fvp);
  476     return error;
  477 }
  478 #endif /* HAVE_VOP_RENAME */
  479 
  480 #ifdef HAVE_VOP_MKDIR
  481 int
  482 xfs_mkdir(struct vop_mkdir_args * ap)
  483      /* struct vnode *dvp,
  484           char *nm,
  485           struct vattr *va,
  486           struct vnode **vpp,
  487           struct ucred *cred)      */
  488 {
  489     struct vnode *dvp  = ap->a_dvp;
  490     struct componentname *cnp = ap->a_cnp;
  491     const char *name   = cnp->cn_nameptr;
  492     struct ucred *cred = cnp->cn_cred;
  493 #ifdef HAVE_FREEBSD_THREAD
  494     d_thread_t *p     = xfs_cnp_to_thread(cnp);
  495 #else
  496     d_thread_t *p     = xfs_cnp_to_proc(cnp);
  497 #endif
  498     int error;
  499 
  500     error = xfs_mkdir_common(dvp, name, ap->a_vap, cred, p);
  501 
  502     if (error == 0)
  503         error = xfs_lookup_common(dvp, cnp, ap->a_vpp);
  504 
  505     cleanup_cnp (cnp, error);
  506 
  507 #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
  508     vput(dvp);
  509 #endif
  510 
  511     NNPFSDEB(XDEBVNOPS, ("xfs_mkdir: error = %d\n", error));
  512 
  513     return error;
  514 }
  515 #endif /* HAVE_VOP_MKDIR */
  516 
  517 #ifdef HAVE_VOP_RMDIR
  518 int
  519 xfs_rmdir(struct vop_rmdir_args * ap)
  520      /* struct vnode *dvp,
  521    struct vnode *vp,
  522    struct componentname *cnp */
  523 {
  524     struct componentname *cnp = ap->a_cnp;
  525     struct vnode *dvp = ap->a_dvp;
  526     struct vnode *vp  = ap->a_vp;
  527     int error = xfs_rmdir_common(ap->a_dvp, ap->a_vp, 
  528                                  cnp->cn_nameptr,
  529                                  cnp->cn_cred,
  530 #ifdef HAVE_FREEBSD_THREAD
  531                                  xfs_cnp_to_thread(cnp));
  532 #else
  533                                  xfs_cnp_to_proc(cnp));
  534 #endif
  535 
  536     cleanup_cnp (cnp, error);
  537 #if !defined(__FreeBSD__) || __FreeBSD_version < 300000
  538     if (dvp == vp)
  539         vrele(vp);
  540     else
  541         vput(vp);
  542     vput(dvp);
  543 #endif
  544 
  545     return error;
  546 }
  547 #endif /* HAVE_VOP_RMDIR */
  548 
  549 #ifdef HAVE_VOP_READDIR
  550 
  551 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
  552 typedef u_long xfs_cookie_t;
  553 #elif defined(__NetBSD__)
  554 typedef off_t xfs_cookie_t;
  555 #else
  556 #error dunno want kind of cookies you have
  557 #endif
  558 
  559 int
  560 xfs_readdir(struct vop_readdir_args * ap)
  561      /* struct vnode *vp,
  562             struct uio *uiop,
  563             struct ucred *cred) */
  564 {
  565     int error;
  566     off_t off;
  567 
  568     off = ap->a_uio->uio_offset;
  569 
  570     error = xfs_readdir_common(ap->a_vp, ap->a_uio, ap->a_cred,
  571 #ifdef HAVE_FREEBSD_THREAD
  572                                xfs_uio_to_thread (ap->a_uio),
  573 #else
  574                                xfs_uio_to_proc (ap->a_uio),
  575 #endif
  576                                ap->a_eofflag);
  577 
  578     if (!error && ap->a_ncookies != NULL) {
  579         struct uio *uio = ap->a_uio;
  580         const struct dirent *dp, *dp_start, *dp_end;
  581         int ncookies;
  582         xfs_cookie_t *cookies, *cookiep;
  583 
  584         if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
  585             panic("xfs_readdir: mail arla-drinkers and tell them to bake burned cookies");
  586         dp = (const struct dirent *)
  587             ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off));
  588 
  589         dp_end = (const struct dirent *) uio->uio_iov->iov_base;
  590         for (dp_start = dp, ncookies = 0;
  591              dp < dp_end;
  592              dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) {
  593             if (dp->d_reclen <= 0)
  594                 break;
  595             ncookies++;
  596         }
  597 
  598         cookies = malloc(ncookies * sizeof(xfs_cookie_t), M_TEMP, M_WAITOK);
  599         for (dp = dp_start, cookiep = cookies;
  600              dp < dp_end;
  601              dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) {
  602             if (dp->d_reclen <= 0)
  603                 break;
  604             off += dp->d_reclen;
  605             *cookiep++ = off;
  606         }
  607         *ap->a_cookies = cookies;
  608         *ap->a_ncookies = ncookies;
  609     }
  610     return error;
  611 }
  612 #endif /* HAVE_VOP_READDIR */
  613 
  614 #ifdef HAVE_VOP_LINK
  615 int
  616 xfs_link(struct vop_link_args * ap)
  617      /*
  618         WILLRELE struct vnode *tdvp;
  619         struct vnode *vp;
  620         struct componentname *cnp;
  621         */
  622 {
  623     struct componentname *cnp = ap->a_cnp;
  624     struct vnode *vp = ap->a_vp;
  625     struct vnode *dvp;
  626 #ifdef HAVE_FREEBSD_THREAD
  627     d_thread_t *p = cnp->cn_thread;
  628 #else
  629     d_thread_t *p = cnp->cn_proc;
  630 #endif
  631     int error;
  632 
  633 #if defined (__OpenBSD__) || defined(__NetBSD__)
  634     dvp = ap->a_dvp;
  635 #elif defined(__FreeBSD__) || defined(__APPLE__)
  636     dvp = ap->a_tdvp;
  637 #else
  638 #error what kind of BSD is this?
  639 #endif
  640 
  641     if (vp->v_type == VDIR) {
  642 #ifdef HAVE_VOP_ABORTOP
  643             VOP_ABORTOP(dvp, cnp);
  644 #endif
  645             error = EPERM;
  646             goto out;
  647     }
  648     if (dvp->v_mount != vp->v_mount) {
  649 #ifdef HAVE_VOP_ABORTOP
  650             VOP_ABORTOP(dvp, cnp);
  651 #endif
  652             error = EXDEV;
  653             goto out;
  654     }
  655     /* FreeBSD 5.0 doesn't need to lock the vnode in VOP_LINK */
  656 #if !defined(__FreeBSD_version) || __FreeBSD_version < 500043
  657 
  658     if (dvp != vp && (error = xfs_vfs_writelock(vp, p))) {
  659 #ifdef HAVE_VOP_ABORTOP
  660             VOP_ABORTOP(dvp, cnp);
  661 #endif
  662             goto out;
  663     }
  664 #endif /* defined(__FreeBSD_version) || __FreeBSD_version < 500043 */
  665 
  666     error = xfs_link_common(
  667                            dvp,
  668                            vp,
  669                            cnp->cn_nameptr,
  670                            cnp->cn_cred,
  671 #ifdef HAVE_FREEBSD_THREAD
  672                            xfs_cnp_to_thread (cnp));
  673 #else
  674                            xfs_cnp_to_proc (cnp));
  675 #endif
  676 
  677     cleanup_cnp (cnp, error);
  678 
  679     if (dvp != vp)
  680         xfs_vfs_unlock(vp, p);
  681 
  682 out:
  683 #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
  684     vput(dvp);
  685 #endif
  686 
  687     return error;
  688 }
  689 #endif /* HAVE_VOP_LINK */
  690 
  691 #ifdef HAVE_VOP_SYMLINK
  692 int
  693 xfs_symlink(struct vop_symlink_args * ap)
  694      /*
  695   IN WILLRELE struct vnode *dvp;
  696   OUT WILLRELE struct vnode **vpp;
  697   IN struct componentname *cnp;
  698   IN struct vattr *vap;
  699   IN char *target;
  700   */
  701 {
  702     struct componentname *cnp = ap->a_cnp;
  703     struct vnode *dvp  = ap->a_dvp;
  704     struct vnode **vpp = ap->a_vpp;
  705     
  706     int error = xfs_symlink_common(dvp,
  707                                    vpp,
  708                                    cnp,
  709                                    ap->a_vap,
  710                                    ap->a_target);
  711 
  712     if (error == 0) {
  713         error = xfs_lookup_common(dvp, cnp, vpp);
  714         if (error == 0)
  715             vput (*vpp);
  716     }
  717     cleanup_cnp (cnp, error);
  718 #if !defined(__FreeBSD__)
  719     vput(dvp);
  720 #endif
  721     return error;
  722 }
  723 #endif /* HAVE_VOP_SYMLINK */
  724 
  725 
  726 #ifdef HAVE_VOP_READLINK
  727 int
  728 xfs_readlink(struct vop_readlink_args * ap)
  729      /* struct vnode *vp,
  730              struct uio *uiop,
  731              struct ucred *cred) */
  732 {
  733     return xfs_readlink_common(ap->a_vp, ap->a_uio, ap->a_cred);
  734 }
  735 #endif /* HAVE_VOP_READLINK */
  736 
  737 #ifdef HAVE_VOP_INACTIVE
  738 int
  739 xfs_inactive(struct vop_inactive_args * ap)
  740      /*struct vnode *vp,
  741              struct ucred *cred)*/
  742 {
  743 #ifdef HAVE_FREEBSD_THREAD
  744     return xfs_inactive_common(ap->a_vp, xfs_curthread());
  745 #else
  746     return xfs_inactive_common(ap->a_vp, xfs_curproc());
  747 #endif
  748 }
  749 #endif /* HAVE_VOP_INACTICE */
  750 
  751 #ifdef HAVE_VOP_RECLAIM
  752 int
  753 xfs_reclaim(struct vop_reclaim_args * ap)
  754      /*struct vop_reclaim_args {
  755         struct vnodeop_desc *a_desc;
  756         struct vnode *a_vp;
  757 };*/
  758 {
  759     struct vnode *vp = ap->a_vp;
  760     int ret;
  761 
  762     ret = xfs_reclaim_common(vp);
  763     vp->v_data = NULL;
  764     return ret;
  765 }
  766 #endif /* HAVE_VOP_RECLAIM */
  767 
  768 /*
  769  * Do lock, unlock, and islocked with lockmgr if we have it.
  770  */
  771 
  772 #if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR)
  773 
  774 #ifdef HAVE_VOP_LOCK
  775 int
  776 xfs_lock(struct vop_lock_args * ap)
  777 {               
  778     struct vnode *vp    = ap->a_vp;
  779     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  780     xfs_vnode_lock *l   = &xn->lock;
  781     int flags           = ap->a_flags;
  782     int ret;
  783 
  784     NNPFSDEB(XDEBVNOPS, ("xfs_lock: %lx, flags 0x%x\n",
  785                        (unsigned long)vp, flags));
  786 
  787     if (l == NULL)
  788       panic("xfs_lock: lock NULL");
  789 
  790     NNPFSDEB(XDEBVNOPS, ("xfs_lock before: lk flags: %d share: %d "
  791                          "wait: %d excl: %d holder: 0x%llx\n",
  792                          l->lk_flags, l->lk_sharecount, l->lk_waitcount,
  793                          l->lk_exclusivecount,
  794                          (unsigned long long)
  795                          (xfs_uintptr_t)l->lk_lockholder));
  796 
  797 #ifndef DEBUG_LOCKS
  798 #ifdef HAVE_FOUR_ARGUMENT_LOCKMGR
  799 #ifdef HAVE_FREEBSD_THREAD
  800     ret = lockmgr(l, flags, &vp->v_interlock, ap->a_td);
  801 #else
  802     ret = lockmgr(l, flags, &vp->v_interlock, ap->a_p);
  803 #endif
  804 #else
  805     ret = lockmgr(l, flags, NULL);
  806 #endif
  807 #else
  808 #ifdef HAVE_FREEBSD_THREAD
  809     ret = debuglockmgr(l, flags, &vp->v_interlock, ap->a_td,
  810                         "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
  811 #else
  812     ret = debuglockmgr(l, flags, &vp->v_interlock, ap->a_p,
  813                         "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
  814 #endif
  815 #endif
  816     NNPFSDEB(XDEBVNOPS, ("xfs_lock: lk flags: %d share: %d "
  817                          "wait: %d excl: %d holder: 0x%llx\n",
  818                          l->lk_flags, l->lk_sharecount, l->lk_waitcount,
  819                          l->lk_exclusivecount, 
  820                          (unsigned long long)
  821                          (xfs_uintptr_t)l->lk_lockholder));
  822     return ret;
  823 }
  824 #endif /* HAVE_VOP_LOCK */
  825 
  826 #ifdef HAVE_VOP_UNLOCK
  827 int
  828 xfs_unlock(struct vop_unlock_args * ap)
  829 {
  830     struct vnode *vp    = ap->a_vp;
  831     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  832     xfs_vnode_lock *l   = &xn->lock;
  833     int flags           = ap->a_flags;
  834     int ret;
  835 
  836     if (l == NULL)
  837       panic("xfs_unlock: lock NULL");
  838 
  839     NNPFSDEB(XDEBVNOPS,
  840            ("xfs_unlock: %lx, flags 0x%x, l %lx, ap %lx\n",
  841             (unsigned long)vp, flags,
  842             (unsigned long)l,
  843             (unsigned long)ap));
  844 
  845     NNPFSDEB(XDEBVNOPS, ("xfs_unlock: lk flags: %d share: %d "
  846                          "wait: %d excl: %d holder: 0x%lld\n",
  847                          l->lk_flags, l->lk_sharecount, l->lk_waitcount,
  848                          l->lk_exclusivecount, 
  849                          (unsigned long long)
  850                          (xfs_uintptr_t)l->lk_lockholder));
  851 #ifndef DEBUG_LOCKS
  852 #ifdef HAVE_FOUR_ARGUMENT_LOCKMGR
  853 #ifdef HAVE_FREEBSD_THREAD
  854     ret = lockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_td);
  855 #else
  856     ret = lockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_p);
  857 #endif
  858 #else
  859     ret = lockmgr (l, flags | LK_RELEASE, NULL);
  860 #endif
  861 #else
  862 #ifdef HAVE_FREEBSD_THREAD
  863     ret = debuglockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_td,
  864                         "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
  865 #else
  866     ret = debuglockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_p,
  867                         "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
  868 #endif
  869 #endif
  870     NNPFSDEB(XDEBVNOPS, ("xfs_unlock: return %d\n", ret));
  871     return ret;
  872 }
  873 #endif /* HAVE_VOP_UNLOCK */
  874 
  875 #ifdef HAVE_VOP_ISLOCKED
  876 int
  877 xfs_islocked (struct vop_islocked_args *ap)
  878 {
  879     struct vnode *vp    = ap->a_vp;
  880     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  881     xfs_vnode_lock *l   = &xn->lock;
  882 
  883     NNPFSDEB(XDEBVNOPS, ("xfs_islocked: %lx\n",
  884                        (unsigned long)vp));
  885 
  886 #if defined(HAVE_TWO_ARGUMENT_LOCKSTATUS)
  887 #ifdef HAVE_FREEBSD_THREAD
  888     return lockstatus (l, ap->a_td);
  889 #else
  890     return lockstatus (l, ap->a_p);
  891 #endif
  892 #elif defined(HAVE_ONE_ARGUMENT_LOCKSTATUS)
  893     return lockstatus (l);
  894 #else
  895 #error what lockstatus?
  896 #endif
  897 }
  898 #endif /* HAVE_VOP_ISLOCKED */
  899 
  900 #else /* !HAVE_KERNEL_LOCKMGR && !HAVE_KERNEL_DEBUGLOCKMGR */
  901 
  902 #ifdef HAVE_VOP_LOCK
  903 int
  904 xfs_lock(struct vop_lock_args * ap)
  905 {
  906     struct vnode *vp    = ap->a_vp;
  907     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  908 
  909     NNPFSDEB(XDEBVNOPS, ("xfs_lock: %lx, %d\n",
  910                        (unsigned long)vp, xn->vnlocks));
  911 
  912     while (vp->v_flag & VXLOCK) {
  913         vp->v_flag |= VXWANT;
  914         (void) tsleep((caddr_t)vp, PINOD, "xfs_vnlock", 0);
  915     }
  916     if (vp->v_tag == VT_NON)
  917         return (ENOENT);
  918     ++xn->vnlocks;
  919     return 0;
  920 }
  921 #endif /* HAVE_VOP_LOCK */
  922 
  923 #ifdef HAVE_VOP_UNLOCK
  924 int
  925 xfs_unlock(struct vop_unlock_args * ap)
  926 {
  927     struct vnode *vp    = ap->a_vp;
  928     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  929     NNPFSDEB(XDEBVNOPS, ("xfs_unlock: %lx, %d\n",
  930                        (unsigned long)vp, xn->vnlocks));
  931 
  932     --xn->vnlocks;
  933     if (xn->vnlocks < 0) {
  934         printf ("PANIC: xfs_unlock: unlocking unlocked\n");
  935         xn->vnlocks = 0;
  936     }
  937     NNPFSDEB(XDEBVNOPS, ("xfs_unlock: return\n"));
  938 
  939     return 0;
  940 }
  941 #endif /* HAVE_VOP_UNLOCK */
  942 
  943 #ifdef HAVE_VOP_ISLOCKED
  944 int
  945 xfs_islocked (struct vop_islocked_args *ap)
  946 {
  947     struct vnode *vp    = ap->a_vp;
  948     struct xfs_node *xn = VNODE_TO_XNODE(vp);
  949 
  950     NNPFSDEB(XDEBVNOPS, ("xfs_islocked: %lx, %d\n",
  951                        (unsigned long)vp, xn->vnlocks));
  952 
  953     return xn->vnlocks;
  954 }
  955 #endif /* HAVE_VOP_ISLOCKED */
  956 #endif /* !HAVE_KERNEL_LOCKMGR */
  957 
  958 #ifdef HAVE_VOP_ABORTOP
  959 int
  960 xfs_abortop (struct vop_abortop_args *ap)
  961      /* struct vnode *dvp;
  962    struct componentname *cnp; */
  963 {
  964     struct componentname *cnp = ap->a_cnp;
  965 
  966     if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
  967 #if defined(HAVE_KERNEL_ZFREEI)
  968         zfreei(namei_zone, cnp->cn_pnbuf);
  969         ap->a_cnp->cn_flags &= ~HASBUF;
  970 #elif defined(HAVE_KERNEL_UMA_ZFREE_ARG)
  971         uma_zfree_arg(namei_zone, cnp->cn_pnbuf, NULL);
  972         cnp->cn_flags &= ~HASBUF;
  973 #elif defined(FREE_ZONE)
  974         FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
  975 #elif defined(HAVE_KERNEL_ZFREE)
  976         zfree(namei_zone, cnp->cn_pnbuf);
  977         ap->a_cnp->cn_flags &= ~HASBUF;
  978 #elif defined(PNBUF_PUT)
  979         PNBUF_PUT(cnp->cn_pnbuf);
  980 #else
  981         pool_put(&namei_pool, cnp->cn_pnbuf);
  982 #endif
  983     return 0;
  984 }
  985 #endif /* HAVE_VOP_ABORTOP */
  986 
  987 #ifdef HAVE_VOP_MMAP
  988 int
  989 xfs_mmap(struct vop_mmap_args *ap)
  990      /*
  991         IN struct vnode *vp;
  992         IN int fflags;
  993         IN struct ucred *cred;
  994         IN struct proc *p;
  995         */
  996 {
  997     NNPFSDEB(XDEBVNOPS, ("xfs_mmap\n"));
  998 #ifdef HAVE_KERNEL_GENFS_MMAP
  999     return genfs_mmap(ap);
 1000 #else
 1001     return EOPNOTSUPP;
 1002 #endif
 1003 }
 1004 #endif /* HAVE_VOP_MMAP */
 1005 
 1006 #ifdef HAVE_VOP_BMAP
 1007 int
 1008 xfs_bmap(struct vop_bmap_args *ap)
 1009      /* IN struct vnode *vp;
 1010         IN daddr64_t bn;
 1011         OUT struct vnode **vpp;
 1012         IN daddr64_t *bnp;
 1013         OUT int *runp;
 1014         OUT int *runb;
 1015         */
 1016 {
 1017     NNPFSDEB(XDEBVNOPS, ("xfs_bmap\n"));
 1018     return EOPNOTSUPP;
 1019 }
 1020 #endif /* HAVE_VOP_BMAP */
 1021 
 1022 #ifdef HAVE_VOP_GETPAGES
 1023 
 1024 static size_t
 1025 get_pages_endlength (struct vop_getpages_args *ap)
 1026 {
 1027 #ifdef HAVE_STRUCT_VOP_GETPAGES_ARGS_A_OFFSET
 1028     /* NetBSD ubc */
 1029     return (ap->a_offset << PAGE_SHIFT) + *ap->a_count * PAGE_SIZE;
 1030 #else
 1031     return (ap->a_reqpage << PAGE_SHIFT) +  ap->a_count * PAGE_SIZE;
 1032 #endif
 1033 }
 1034 
 1035 int
 1036 xfs_getpages (struct vop_getpages_args *ap)
 1037      /* Old BSD
 1038         IN struct vnode *vp;
 1039         IN vm_page_t *m;
 1040         IN int count;
 1041         IN int reqpage;
 1042         IN vm_ooffset_t offset;
 1043      */
 1044     /* NetBSD UBC
 1045         IN struct vnode *vp;
 1046         IN voff_t offset;
 1047         IN vm_page_t *m;
 1048         IN int *count;
 1049         IN int centeridx;
 1050         IN vm_prot_t access_type;
 1051         IN int advice;
 1052         IN int flags;
 1053     */
 1054 {
 1055     int error;
 1056 
 1057     NNPFSDEB(XDEBVNOPS, ("xfs_getpages\n"));
 1058 
 1059 #if HAVE_KERNEL_VNODE_PAGER_GENERIC_GETPAGES
 1060     error = vnode_pager_generic_getpages (ap->a_vp, ap->a_m, 
 1061                                           ap->a_count, ap->a_reqpage);
 1062 #else
 1063     error = xfs_data_valid (ap->a_vp, VNODE_TO_XNODE(ap->a_vp)->rd_cred,
 1064                             xfs_curproc(), NNPFS_DATA_R,
 1065                             get_pages_endlength(ap));
 1066     if (error == 0)
 1067         error = VOP_GETPAGES(DATA_FROM_VNODE(ap->a_vp), 
 1068                              ap->a_offset, ap->a_m,
 1069                              ap->a_count, ap->a_centeridx, ap->a_access_type,
 1070                              ap->a_advice, ap->a_flags);
 1071 #endif
 1072     NNPFSDEB(XDEBVNOPS, ("xfs_getpages = %d\n", error));
 1073     return error;
 1074 }
 1075 #endif /* HAVE_VOP_GETPAGES */
 1076 
 1077 #ifdef HAVE_VOP_PUTPAGES
 1078 int
 1079 xfs_putpages (struct vop_putpages_args *ap)
 1080      /* Old BSD
 1081         IN struct vnode *vp;
 1082         IN vm_page_t *m;
 1083         IN int count;
 1084         IN int sync;
 1085         IN int *rtvals;
 1086         IN vm_ooffset_t offset;
 1087      */
 1088     /* NetBSD UBC (>= 1.5Y)
 1089         IN struct vnode *vp;
 1090         IN voff_t offlo;
 1091         IN voff_t offhi;
 1092         IN int flags;
 1093     */
 1094 {
 1095     struct vnode *vp    = ap->a_vp;
 1096     struct xfs_node *xn = VNODE_TO_XNODE(vp);
 1097     struct vnode *t     = DATA_FROM_XNODE(xn);
 1098     int error;
 1099 
 1100     NNPFSDEB(XDEBVNOPS, ("xfs_putpages\n"));
 1101 
 1102     if (t == NULL)
 1103         return 0;
 1104 
 1105 #ifdef HAVE_STRUCT_VOP_PUTPAGES_ARGS_A_SYNC /* FreeBSD-style */
 1106     xn->flags |= NNPFS_DATA_DIRTY;
 1107 
 1108     return VOP_PUTPAGES(t, ap->a_m, ap->a_count, ap->a_sync, ap->a_rtvals,
 1109                         ap->a_offset);
 1110 #else /* NetBSD-style */
 1111 #if defined(__NetBSD__) && __NetBSD_Version__  >= 105250000 
 1112     /* XXX should only walk over those pages that is requested */
 1113     if (vp->v_type == VREG && ap->a_flags & PGO_CLEANIT) {
 1114         struct uvm_object *uobj = &t->v_uobj;
 1115         struct vm_page *pg;
 1116         int dirty = 0;
 1117 
 1118         pg = TAILQ_FIRST(&uobj->memq);
 1119 
 1120         while (pg && !dirty) {
 1121             dirty = pmap_is_modified(pg) || (pg->flags & PG_CLEAN) == 0;
 1122             pg = TAILQ_NEXT(pg, listq);
 1123         }       
 1124 
 1125         if (dirty)
 1126             xn->flags |= NNPFS_DATA_DIRTY;
 1127     }
 1128 
 1129     return VOP_PUTPAGES(t, ap->a_offlo, ap->a_offhi, ap->a_flags);
 1130 #else
 1131     xn->flags |= NNPFS_DATA_DIRTY;
 1132     return VOP_PUTPAGES(t, ap->a_m, ap->a_count, ap->a_flags, ap->a_rtvals);
 1133 #endif
 1134 #endif /* HAVE_STRUCT_VOP_PUTPAGES_ARGS_A_SYNC */
 1135 }
 1136 #endif /* HAVE_VOP_PUTPAGES */
 1137 
 1138 #ifdef HAVE_VOP_CMP
 1139 int
 1140 xfs_cmp(struct vnode * vp1, struct vnode * vp2)
 1141 {
 1142     NNPFSDEB(XDEBVNOPS, ("xfs_cmp\n"));
 1143     return EOPNOTSUPP;
 1144 }
 1145 #endif /* HAVE_VOP_CMP */
 1146 
 1147 #ifdef HAVE_VOP_REALVP
 1148 int
 1149 xfs_realvp(struct vnode * vp,
 1150            struct vnode ** vpp)
 1151 {
 1152     NNPFSDEB(XDEBVNOPS, ("xfs_realvp\n"));
 1153     return EOPNOTSUPP;
 1154 }
 1155 #endif /* HAVE_VOP_REALVP */
 1156 
 1157 #ifdef HAVE_VOP_CNTL
 1158 int
 1159 xfs_cntl(struct vnode * vp,
 1160          int cmd,
 1161          caddr_t idata,
 1162          caddr_t odata,
 1163          int iflag,
 1164          int oflag)
 1165 {
 1166     NNPFSDEB(XDEBVNOPS, ("xfs_cntl\n"));
 1167     return EOPNOTSUPP;
 1168 }
 1169 #endif /* HAVE_VOP_CNTL */
 1170 
 1171 #ifdef HAVE_VOP_PRINT
 1172 int
 1173 xfs_print (struct vop_print_args *v)
 1174 {
 1175     struct vop_print_args *ap = v;
 1176     xfs_printnode_common (ap->a_vp);
 1177     return 0;
 1178 }
 1179 #endif
 1180 
 1181 #ifdef HAVE_VOP_ADVLOCK
 1182 int
 1183 xfs_advlock(struct vop_advlock_args *v)
 1184 {
 1185     struct vop_advlock_args *ap = v;
 1186 #if defined(HAVE_KERNEL_LF_ADVLOCK) && !defined(__APPLE__)
 1187     struct xfs_node *xn = VNODE_TO_XNODE(ap->a_vp);
 1188  
 1189     return (lf_advlock(&xn->lockf, xn->attr.va_size, ap->a_id, ap->a_op,
 1190             ap->a_fl, ap->a_flags));
 1191 #else
 1192      return EOPNOTSUPP;
 1193 #endif
 1194 }
 1195 #endif /* HAVE_VOP_ADVOCK */
 1196 
 1197 #ifdef HAVE_VOP_REVOKE
 1198 int
 1199 xfs_revoke(struct vop_revoke_args *v)
 1200 {
 1201 #if defined(HAVE_KERNEL_GENFS_REVOKE)
 1202     return genfs_revoke (v);
 1203 #elif defined(HAVE_KERNEL_VOP_REVOKE)
 1204     return vop_revoke (v);
 1205 #else
 1206     return EOPNOTSUPP;
 1207 #endif
 1208 }
 1209 #endif /* HAVE_VOP_REVOKE */
 1210 
 1211 #ifdef HAVE_VOP_PAGEIN
 1212 int
 1213 xfs_pagein(struct vop_pagein_args *ap)
 1214 {
 1215 #ifdef __APPLE__
 1216     struct uio uio;
 1217     struct iovec iov;
 1218     int ret;
 1219 
 1220     kernel_upl_map(kernel_map, ap->a_pl, &iov.iov_base);
 1221     iov.iov_base+=ap->a_pl_offset;
 1222     iov.iov_len=ap->a_size;
 1223 
 1224     uio.uio_iov=&iov;
 1225     uio.uio_iovcnt=1;
 1226     uio.uio_offset=ap->a_f_offset;
 1227     uio.uio_resid=ap->a_size;
 1228     uio.uio_segflg=UIO_SYSSPACE; /* XXX what is it? */
 1229     uio.uio_rw=UIO_READ;
 1230     uio.uio_procp=xfs_curproc();
 1231 
 1232     ret = VOP_READ(ap->a_vp, &uio, 0, ap->a_cred);
 1233 
 1234     /* Zero out rest of last page if there wasn't enough data in the file */
 1235     if (ret == 0 && uio.uio_resid > 0)
 1236         bzero(iov.iov_base, uio.uio_resid);
 1237     
 1238     kernel_upl_unmap(kernel_map, ap->a_pl);
 1239 
 1240     if (ret) {
 1241         kernel_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size,
 1242                                UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
 1243     } else {
 1244         kernel_upl_commit_range(ap->a_pl, ap->a_pl_offset, ap->a_size,
 1245                                 UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY,
 1246                                 UPL_GET_INTERNAL_PAGE_LIST(ap->a_pl));
 1247     }
 1248 
 1249     return ret;
 1250 #else
 1251 #error pagein on non apple ?
 1252 #endif
 1253 }
 1254   
 1255 #endif
 1256 
 1257 #ifdef HAVE_VOP_PAGEOUT
 1258 int
 1259 xfs_pageout(struct vop_pageout_args *ap)
 1260 {
 1261 #ifdef __APPLE__
 1262     struct uio uio;
 1263     struct iovec iov;
 1264     int ret;
 1265 
 1266     kernel_upl_map(kernel_map, ap->a_pl, &iov.iov_base);
 1267     iov.iov_base+=ap->a_pl_offset;
 1268     iov.iov_len=ap->a_size;
 1269 
 1270     uio.uio_iov=&iov;
 1271     uio.uio_iovcnt=1;
 1272     uio.uio_offset=ap->a_f_offset;
 1273     uio.uio_resid=ap->a_size;
 1274     uio.uio_segflg=UIO_SYSSPACE; /* XXX what is it? */
 1275     uio.uio_rw=UIO_WRITE;
 1276     uio.uio_procp=xfs_curproc();
 1277 
 1278     ret = VOP_WRITE(ap->a_vp, &uio, 0, ap->a_cred);
 1279 
 1280     kernel_upl_unmap(kernel_map, ap->a_pl);
 1281 
 1282     if (ret) {
 1283         kernel_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size,
 1284                                UPL_ABORT_FREE_ON_EMPTY);
 1285     } else {
 1286         kernel_upl_commit_range(ap->a_pl, ap->a_pl_offset, ap->a_size,
 1287                                 UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY,
 1288                                 UPL_GET_INTERNAL_PAGE_LIST(ap->a_pl));
 1289     }
 1290 
 1291     return ret;
 1292 #else
 1293 #error pageout on non apple ?
 1294 #endif
 1295 }
 1296 #endif
 1297 
 1298 #ifdef HAVE_VOP_CREATEVOBJECT
 1299 int
 1300 xfs_createvobject(struct vop_createvobject_args *ap)
 1301 /*
 1302 struct vop_createvobject_args {
 1303         struct vnode *vp;
 1304         struct ucred *cred;
 1305         struct proc *p;
 1306 };
 1307  */
 1308 {
 1309     NNPFSDEB(XDEBVNOPS, ("xfs_createvobject\n"));
 1310 
 1311     return vop_stdcreatevobject (ap);
 1312 }
 1313 #endif /* HAVE_VOP_CREATEVOBJECT */
 1314 
 1315 #ifdef HAVE_VOP_DESTROYVOBJECT
 1316 int
 1317 xfs_destroyvobject(struct vop_destroyvobject_args *ap)
 1318 /*
 1319 struct vop_destroyvobject_args {
 1320         struct vnode *vp;
 1321 };
 1322  */
 1323 {
 1324     NNPFSDEB(XDEBVNOPS, ("xfs_destroyvobject\n"));
 1325 
 1326     return vop_stddestroyvobject (ap);
 1327 }
 1328 #endif /* HAVE_VOP_DESTROYVOBJECT */
 1329 
 1330 #ifdef HAVE_VOP_GETVOBJECT
 1331 int
 1332 xfs_getvobject(struct vop_getvobject_args *ap)
 1333 /*
 1334 struct vop_getvobject_args {
 1335         struct vnode *vp;
 1336         struct vm_object **objpp;
 1337 };
 1338  */
 1339 {
 1340     NNPFSDEB(XDEBVNOPS, ("xfs_getvobject\n"));
 1341 
 1342     return vop_stdgetvobject (ap);
 1343 }
 1344 #endif /* HAVE_VOP_GETVOBJECT */
 1345 
 1346 #ifdef HAVE_VOP_PATHCONF
 1347 int
 1348 xfs_pathconf(struct vop_pathconf_args *ap)
 1349 /*
 1350 struct vop_pathconf_args {
 1351         struct vnodeop_desc *a_desc;
 1352         struct vnode *a_vp;
 1353         int a_name;
 1354 };
 1355 */
 1356 {
 1357     NNPFSDEB(XDEBVNOPS, ("xfs_pathconf\n"));
 1358 
 1359 #ifdef HAVE_KERNEL_VOP_STDPATHCONF
 1360     return vop_stdpathconf(ap);
 1361 #else
 1362     return EOPNOTSUPP;
 1363 #endif
 1364 }
 1365 #endif
 1366 
 1367 
 1368 
 1369 vop_t **xfs_vnodeop_p;
 1370 
 1371 int
 1372 xfs_eopnotsupp (struct vop_generic_args *ap)
 1373 {
 1374     NNPFSDEB(XDEBVNOPS, ("xfs_eopnotsupp %s\n", ap->a_desc->vdesc_name));
 1375     return EOPNOTSUPP;
 1376 }
 1377 
 1378 int
 1379 xfs_returnzero (struct vop_generic_args *ap)
 1380 {
 1381     NNPFSDEB(XDEBVNOPS, ("xfs_returnzero %s\n", ap->a_desc->vdesc_name));
 1382     return 0;
 1383 }
 1384 
 1385 void
 1386 xfs_pushdirty(struct vnode *vp, struct ucred *cred, d_thread_t *p)
 1387 {
 1388 #if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 105280000
 1389     VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES|PGO_SYNCIO|PGO_CLEANIT);
 1390 #elif defined(__APPLE__)
 1391     ubc_pushdirty(vp);
 1392 #endif
 1393 }
 1394 
 1395 
 1396 
 1397 static struct vnodeopv_entry_desc xfs_vnodeop_entries[] = {
 1398     {&vop_default_desc, (vop_t *) xfs_eopnotsupp},
 1399 #ifdef HAVE_VOP_LOOKUP
 1400 #ifdef HAVE_KERNEL_VFS_CACHE_LOOKUP
 1401     {&vop_lookup_desc, (vop_t *) vfs_cache_lookup },
 1402 #else
 1403     {&vop_lookup_desc, (vop_t *) xfs_lookup },
 1404 #endif
 1405 #endif
 1406 #ifdef HAVE_VOP_CACHEDLOOKUP
 1407     {&vop_cachedlookup_desc, (vop_t *) xfs_cachedlookup },
 1408 #endif
 1409 #ifdef HAVE_VOP_OPEN
 1410     {&vop_open_desc, (vop_t *) xfs_open },
 1411 #endif
 1412 #ifdef HAVE_VOP_FSYNC
 1413     {&vop_fsync_desc, (vop_t *) xfs_fsync },
 1414 #endif
 1415 #ifdef HAVE_VOP_CLOSE
 1416     {&vop_close_desc, (vop_t *) xfs_close },
 1417 #endif
 1418 #ifdef HAVE_VOP_READ
 1419     {&vop_read_desc, (vop_t *) xfs_read },
 1420 #endif
 1421 #ifdef HAVE_VOP_WRITE
 1422     {&vop_write_desc, (vop_t *) xfs_write },
 1423 #endif
 1424 #ifdef HAVE_VOP_MMAP
 1425     {&vop_mmap_desc, (vop_t *) xfs_mmap },
 1426 #endif
 1427 #ifdef HAVE_VOP_BMAP
 1428     {&vop_bmap_desc, (vop_t *) xfs_bmap },
 1429 #endif
 1430 #ifdef HAVE_VOP_IOCTL
 1431     {&vop_ioctl_desc, (vop_t *) xfs_ioctl },
 1432 #endif
 1433 #ifdef HAVE_VOP_SELECT
 1434     {&vop_select_desc, (vop_t *) xfs_select },
 1435 #endif
 1436 #ifdef HAVE_VOP_SEEK
 1437     {&vop_seek_desc, (vop_t *) xfs_seek },
 1438 #endif
 1439 #ifdef HAVE_VOP_POLL
 1440     {&vop_poll_desc, (vop_t *) xfs_poll },
 1441 #endif
 1442 #ifdef HAVE_VOP_GETATTR
 1443     {&vop_getattr_desc, (vop_t *) xfs_getattr },
 1444 #endif
 1445 #ifdef HAVE_VOP_SETATTR
 1446     {&vop_setattr_desc, (vop_t *) xfs_setattr },
 1447 #endif
 1448 #ifdef HAVE_VOP_ACCESS
 1449     {&vop_access_desc, (vop_t *) xfs_access },
 1450 #endif
 1451 #ifdef HAVE_VOP_CREATE
 1452     {&vop_create_desc, (vop_t *) xfs_create },
 1453 #endif
 1454 #ifdef HAVE_VOP_REMOVE
 1455     {&vop_remove_desc, (vop_t *) xfs_remove },
 1456 #endif
 1457 #ifdef HAVE_VOP_LINK
 1458     {&vop_link_desc, (vop_t *) xfs_link },
 1459 #endif
 1460 #ifdef HAVE_VOP_RENAME
 1461     {&vop_rename_desc, (vop_t *) xfs_rename },
 1462 #endif
 1463 #ifdef HAVE_VOP_MKDIR
 1464     {&vop_mkdir_desc, (vop_t *) xfs_mkdir },
 1465 #endif
 1466 #ifdef HAVE_VOP_RMDIR
 1467     {&vop_rmdir_desc, (vop_t *) xfs_rmdir },
 1468 #endif
 1469 #ifdef HAVE_VOP_READDIR
 1470     {&vop_readdir_desc, (vop_t *) xfs_readdir },
 1471 #endif
 1472 #ifdef HAVE_VOP_SYMLINK
 1473     {&vop_symlink_desc, (vop_t *) xfs_symlink },
 1474 #endif
 1475 #ifdef HAVE_VOP_READLINK
 1476     {&vop_readlink_desc, (vop_t *) xfs_readlink },
 1477 #endif
 1478 #ifdef HAVE_VOP_INACTIVE
 1479     {&vop_inactive_desc, (vop_t *) xfs_inactive },
 1480 #endif
 1481 #ifdef HAVE_VOP_RECLAIM
 1482     {&vop_reclaim_desc, (vop_t *) xfs_reclaim },
 1483 #endif
 1484 #ifdef HAVE_VOP_LOCK
 1485     {&vop_lock_desc, (vop_t *) xfs_lock },
 1486 #endif
 1487 #ifdef HAVE_VOP_UNLOCK
 1488     {&vop_unlock_desc, (vop_t *) xfs_unlock },
 1489 #endif
 1490 #ifdef HAVE_VOP_ISLOCKED
 1491     {&vop_islocked_desc, (vop_t *) xfs_islocked },
 1492 #endif
 1493 #ifdef HAVE_VOP_ABORTOP
 1494     {&vop_abortop_desc, (vop_t *) xfs_abortop },
 1495 #endif
 1496 #ifdef HAVE_VOP_GETPAGES
 1497     {&vop_getpages_desc, (vop_t *) xfs_getpages },
 1498 #endif
 1499 #ifdef HAVE_VOP_PUTPAGES
 1500     {&vop_putpages_desc, (vop_t *) xfs_putpages },
 1501 #endif
 1502 #ifdef HAVE_VOP_REVOKE
 1503     {&vop_revoke_desc, (vop_t *) xfs_revoke },
 1504 #endif
 1505 #ifdef HAVE_VOP_PRINT
 1506     {&vop_print_desc, (vop_t *) xfs_print}, 
 1507 #endif
 1508 #ifdef HAVE_VOP_ADVLOCK
 1509     {&vop_advlock_desc, (vop_t *) xfs_advlock },
 1510 #endif
 1511 #ifdef HAVE_VOP_PAGEIN
 1512     {&vop_pagein_desc, (vop_t *) xfs_pagein },
 1513 #endif
 1514 #ifdef HAVE_VOP_PAGEOUT
 1515     {&vop_pageout_desc, (vop_t *) xfs_pageout },
 1516 #endif
 1517 #ifdef HAVE_VOP_CREATEVOBJECT
 1518     {&vop_createvobject_desc, (vop_t *) xfs_createvobject },
 1519 #endif
 1520 #ifdef HAVE_VOP_DESTROYVOBJECT
 1521     {&vop_destroyvobject_desc, (vop_t *) xfs_destroyvobject },
 1522 #endif
 1523 #ifdef HAVE_VOP_GETVOBJECT
 1524     {&vop_getvobject_desc, (vop_t *) xfs_getvobject },
 1525 #endif
 1526 #ifdef HAVE_VOP_PATHCONF
 1527     {&vop_pathconf_desc, (vop_t *) xfs_pathconf },
 1528 #endif
 1529     {(struct vnodeop_desc *) NULL, (int (*) (void *)) NULL}
 1530 };
 1531 
 1532 struct vnodeopv_desc xfs_vnodeop_opv_desc =
 1533 {&xfs_vnodeop_p, xfs_vnodeop_entries};
 1534 
 1535 #ifdef VNODEOP_SET
 1536 VNODEOP_SET(xfs_vnodeop_opv_desc);
 1537 #endif

Cache object: 5cca4965c24f250e414b8750a92a13c0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.