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


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  23  *
  24  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
  25  *      All rights reserved.
  26  */
  27 




  28 #include <sys/param.h>
  29 #include <sys/types.h>
  30 #include <sys/systm.h>
  31 #include <sys/cred.h>
  32 #include <sys/time.h>
  33 #include <sys/vnode.h>
  34 #include <sys/vfs.h>
  35 #include <sys/vfs_opreg.h>
  36 #include <sys/file.h>
  37 #include <sys/filio.h>
  38 #include <sys/uio.h>
  39 #include <sys/buf.h>
  40 #include <sys/mman.h>
  41 #include <sys/pathname.h>
  42 #include <sys/dirent.h>
  43 #include <sys/debug.h>
  44 #include <sys/vmsystm.h>
  45 #include <sys/fcntl.h>
  46 #include <sys/flock.h>
  47 #include <sys/swap.h>


2013         }
2014         if (!error) {
2015                 if (exclusive == EXCL)
2016                         error = EEXIST;
2017                 else if (vp->v_type == VDIR && (mode & VWRITE))
2018                         error = EISDIR;
2019                 else {
2020                         /*
2021                          * If vnode is a device, create special vnode.
2022                          */
2023                         if (IS_DEVVP(vp)) {
2024                                 tempvp = vp;
2025                                 vp = specvp(vp, vp->v_rdev, vp->v_type, cr);
2026                                 VN_RELE(tempvp);
2027                         }
2028                         if (!(error = VOP_ACCESS(vp, mode, 0, cr, ct))) {
2029                                 if ((vattr.va_mask & AT_SIZE) &&
2030                                     vp->v_type == VREG) {
2031                                         vattr.va_mask = AT_SIZE;
2032                                         error = nfssetattr(vp, &vattr, 0, cr);







2033                                 }
2034                         }
2035                 }

2036                 nfs_rw_exit(&drp->r_rwlock);
2037                 if (error) {
2038                         VN_RELE(vp);
2039                 } else {
2040                         /*
2041                          * existing file got truncated, notify.
2042                          */
2043                         vnevent_create(vp, ct);
2044                         *vpp = vp;
2045                 }
2046                 return (error);
2047         }
2048 
2049         ASSERT(vattr.va_mask & AT_TYPE);
2050         if (vattr.va_type == VREG) {
2051                 ASSERT(vattr.va_mask & AT_MODE);
2052                 if (MANDMODE(vattr.va_mode)) {
2053                         nfs_rw_exit(&drp->r_rwlock);
2054                         return (EACCES);
2055                 }
2056         }
2057 
2058         dnlc_remove(dvp, nm);
2059 
2060         setdiropargs(&args.ca_da, nm, dvp);
2061 
2062         /*
2063          * Decide what the group-id of the created file should be.




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  23  *
  24  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
  25  *      All rights reserved.
  26  */
  27 
  28 /*
  29  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  30  */
  31 
  32 #include <sys/param.h>
  33 #include <sys/types.h>
  34 #include <sys/systm.h>
  35 #include <sys/cred.h>
  36 #include <sys/time.h>
  37 #include <sys/vnode.h>
  38 #include <sys/vfs.h>
  39 #include <sys/vfs_opreg.h>
  40 #include <sys/file.h>
  41 #include <sys/filio.h>
  42 #include <sys/uio.h>
  43 #include <sys/buf.h>
  44 #include <sys/mman.h>
  45 #include <sys/pathname.h>
  46 #include <sys/dirent.h>
  47 #include <sys/debug.h>
  48 #include <sys/vmsystm.h>
  49 #include <sys/fcntl.h>
  50 #include <sys/flock.h>
  51 #include <sys/swap.h>


2017         }
2018         if (!error) {
2019                 if (exclusive == EXCL)
2020                         error = EEXIST;
2021                 else if (vp->v_type == VDIR && (mode & VWRITE))
2022                         error = EISDIR;
2023                 else {
2024                         /*
2025                          * If vnode is a device, create special vnode.
2026                          */
2027                         if (IS_DEVVP(vp)) {
2028                                 tempvp = vp;
2029                                 vp = specvp(vp, vp->v_rdev, vp->v_type, cr);
2030                                 VN_RELE(tempvp);
2031                         }
2032                         if (!(error = VOP_ACCESS(vp, mode, 0, cr, ct))) {
2033                                 if ((vattr.va_mask & AT_SIZE) &&
2034                                     vp->v_type == VREG) {
2035                                         vattr.va_mask = AT_SIZE;
2036                                         error = nfssetattr(vp, &vattr, 0, cr);
2037 
2038                                         if (!error) {
2039                                                 /*
2040                                                  * Existing file was truncated;
2041                                                  * emit a create event.
2042                                                  */
2043                                                 vnevent_create(vp, ct);
2044                                         }
2045                                 }
2046                         }
2047                 }
2048                 nfs_rw_exit(&drp->r_rwlock);
2049                 if (error) {
2050                         VN_RELE(vp);
2051                 } else {




2052                         *vpp = vp;
2053                 }
2054                 return (error);
2055         }
2056 
2057         ASSERT(vattr.va_mask & AT_TYPE);
2058         if (vattr.va_type == VREG) {
2059                 ASSERT(vattr.va_mask & AT_MODE);
2060                 if (MANDMODE(vattr.va_mode)) {
2061                         nfs_rw_exit(&drp->r_rwlock);
2062                         return (EACCES);
2063                 }
2064         }
2065 
2066         dnlc_remove(dvp, nm);
2067 
2068         setdiropargs(&args.ca_da, nm, dvp);
2069 
2070         /*
2071          * Decide what the group-id of the created file should be.