Print this page
3484 enhance and document tail follow support
Reviewed by: Joshua M. Clulow <jmc@joyent.com>


  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  27  */
  28 
  29 /*
  30  *      Copyright 1983,1984,1985,1986,1987,1988,1989 AT&T.
  31  *      All Rights Reserved
  32  */
  33 




  34 #include <sys/param.h>
  35 #include <sys/types.h>
  36 #include <sys/systm.h>
  37 #include <sys/cred.h>
  38 #include <sys/time.h>
  39 #include <sys/vnode.h>
  40 #include <sys/vfs.h>
  41 #include <sys/vfs_opreg.h>
  42 #include <sys/file.h>
  43 #include <sys/filio.h>
  44 #include <sys/uio.h>
  45 #include <sys/buf.h>
  46 #include <sys/mman.h>
  47 #include <sys/pathname.h>
  48 #include <sys/dirent.h>
  49 #include <sys/debug.h>
  50 #include <sys/vmsystm.h>
  51 #include <sys/fcntl.h>
  52 #include <sys/flock.h>
  53 #include <sys/swap.h>


6636                                                         mutex_exit(
6637                                                             &rp->r_statelock);
6638                                                 }
6639                                         }
6640                                         vattr.va_mask = (AT_SIZE |
6641                                             AT_TYPE | AT_MODE);
6642                                         vattr.va_type = VREG;
6643                                         createmode = UNCHECKED4;
6644                                         truncating = 1;
6645                                         goto create_otw;
6646                                 }
6647                         }
6648                 }
6649         }
6650         nfs_rw_exit(&drp->r_rwlock);
6651         if (error) {
6652                 VN_RELE(vp);
6653         } else {
6654                 vnode_t *tvp;
6655                 rnode4_t *trp;
6656                 /*
6657                  * existing file got truncated, notify.
6658                  */
6659                 tvp = vp;
6660                 if (vp->v_type == VREG) {
6661                         trp = VTOR4(vp);
6662                         if (IS_SHADOW(vp, trp))
6663                                 tvp = RTOV4(trp);
6664                 }





6665                 vnevent_create(tvp, ct);


6666                 *vpp = vp;
6667         }
6668         return (error);
6669 
6670 create_otw:
6671         dnlc_remove(dvp, nm);
6672 
6673         ASSERT(vattr.va_mask & AT_TYPE);
6674 
6675         /*
6676          * If not a regular file let nfs4mknod() handle it.
6677          */
6678         if (vattr.va_type != VREG) {
6679                 error = nfs4mknod(dvp, nm, &vattr, exclusive, mode, vpp, cr);
6680                 nfs_rw_exit(&drp->r_rwlock);
6681                 return (error);
6682         }
6683 
6684         /*
6685          * It _is_ a regular file.




  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  27  */
  28 
  29 /*
  30  *      Copyright 1983,1984,1985,1986,1987,1988,1989 AT&T.
  31  *      All Rights Reserved
  32  */
  33 
  34 /*
  35  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  36  */
  37 
  38 #include <sys/param.h>
  39 #include <sys/types.h>
  40 #include <sys/systm.h>
  41 #include <sys/cred.h>
  42 #include <sys/time.h>
  43 #include <sys/vnode.h>
  44 #include <sys/vfs.h>
  45 #include <sys/vfs_opreg.h>
  46 #include <sys/file.h>
  47 #include <sys/filio.h>
  48 #include <sys/uio.h>
  49 #include <sys/buf.h>
  50 #include <sys/mman.h>
  51 #include <sys/pathname.h>
  52 #include <sys/dirent.h>
  53 #include <sys/debug.h>
  54 #include <sys/vmsystm.h>
  55 #include <sys/fcntl.h>
  56 #include <sys/flock.h>
  57 #include <sys/swap.h>


6640                                                         mutex_exit(
6641                                                             &rp->r_statelock);
6642                                                 }
6643                                         }
6644                                         vattr.va_mask = (AT_SIZE |
6645                                             AT_TYPE | AT_MODE);
6646                                         vattr.va_type = VREG;
6647                                         createmode = UNCHECKED4;
6648                                         truncating = 1;
6649                                         goto create_otw;
6650                                 }
6651                         }
6652                 }
6653         }
6654         nfs_rw_exit(&drp->r_rwlock);
6655         if (error) {
6656                 VN_RELE(vp);
6657         } else {
6658                 vnode_t *tvp;
6659                 rnode4_t *trp;



6660                 tvp = vp;
6661                 if (vp->v_type == VREG) {
6662                         trp = VTOR4(vp);
6663                         if (IS_SHADOW(vp, trp))
6664                                 tvp = RTOV4(trp);
6665                 }
6666 
6667                 if (must_trunc) {
6668                         /*
6669                          * existing file got truncated, notify.
6670                          */
6671                         vnevent_create(tvp, ct);
6672                 }
6673 
6674                 *vpp = vp;
6675         }
6676         return (error);
6677 
6678 create_otw:
6679         dnlc_remove(dvp, nm);
6680 
6681         ASSERT(vattr.va_mask & AT_TYPE);
6682 
6683         /*
6684          * If not a regular file let nfs4mknod() handle it.
6685          */
6686         if (vattr.va_type != VREG) {
6687                 error = nfs4mknod(dvp, nm, &vattr, exclusive, mode, vpp, cr);
6688                 nfs_rw_exit(&drp->r_rwlock);
6689                 return (error);
6690         }
6691 
6692         /*
6693          * It _is_ a regular file.