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


  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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
  28  *      All rights reserved.
  29  */
  30 




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


2281                         }
2282                         if (!(error = VOP_ACCESS(vp, mode, 0, cr, ct))) {
2283                                 if ((vattr.va_mask & AT_SIZE) &&
2284                                     vp->v_type == VREG) {
2285                                         rp = VTOR(vp);
2286                                         /*
2287                                          * Check here for large file handled
2288                                          * by LF-unaware process (as
2289                                          * ufs_create() does)
2290                                          */
2291                                         if (!(lfaware & FOFFMAX)) {
2292                                                 mutex_enter(&rp->r_statelock);
2293                                                 if (rp->r_size > MAXOFF32_T)
2294                                                         error = EOVERFLOW;
2295                                                 mutex_exit(&rp->r_statelock);
2296                                         }
2297                                         if (!error) {
2298                                                 vattr.va_mask = AT_SIZE;
2299                                                 error = nfs3setattr(vp,
2300                                                     &vattr, 0, cr);






2301                                         }
2302                                 }
2303                         }
2304                 }
2305                 nfs_rw_exit(&drp->r_rwlock);
2306                 if (error) {
2307                         VN_RELE(vp);
2308                 } else {
2309                         /*
2310                          * existing file got truncated, notify.
2311                          */
2312                         vnevent_create(vp, ct);
2313                         *vpp = vp;
2314                 }

2315                 return (error);
2316         }
2317 
2318         dnlc_remove(dvp, nm);
2319 
2320         /*
2321          * Decide what the group-id of the created file should be.
2322          * Set it in attribute list as advisory...
2323          */
2324         error = setdirgid(dvp, &vattr.va_gid, cr);
2325         if (error) {
2326                 nfs_rw_exit(&drp->r_rwlock);
2327                 return (error);
2328         }
2329         vattr.va_mask |= AT_GID;
2330 
2331         ASSERT(vattr.va_mask & AT_TYPE);
2332         if (vattr.va_type == VREG) {
2333                 ASSERT(vattr.va_mask & AT_MODE);
2334                 if (MANDMODE(vattr.va_mode)) {




  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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
  28  *      All rights reserved.
  29  */
  30 
  31 /*
  32  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  33  */
  34 
  35 #include <sys/param.h>
  36 #include <sys/types.h>
  37 #include <sys/systm.h>
  38 #include <sys/cred.h>
  39 #include <sys/time.h>
  40 #include <sys/vnode.h>
  41 #include <sys/vfs.h>
  42 #include <sys/vfs_opreg.h>
  43 #include <sys/file.h>
  44 #include <sys/filio.h>
  45 #include <sys/uio.h>
  46 #include <sys/buf.h>
  47 #include <sys/mman.h>
  48 #include <sys/pathname.h>
  49 #include <sys/dirent.h>
  50 #include <sys/debug.h>
  51 #include <sys/vmsystm.h>
  52 #include <sys/fcntl.h>
  53 #include <sys/flock.h>
  54 #include <sys/swap.h>


2285                         }
2286                         if (!(error = VOP_ACCESS(vp, mode, 0, cr, ct))) {
2287                                 if ((vattr.va_mask & AT_SIZE) &&
2288                                     vp->v_type == VREG) {
2289                                         rp = VTOR(vp);
2290                                         /*
2291                                          * Check here for large file handled
2292                                          * by LF-unaware process (as
2293                                          * ufs_create() does)
2294                                          */
2295                                         if (!(lfaware & FOFFMAX)) {
2296                                                 mutex_enter(&rp->r_statelock);
2297                                                 if (rp->r_size > MAXOFF32_T)
2298                                                         error = EOVERFLOW;
2299                                                 mutex_exit(&rp->r_statelock);
2300                                         }
2301                                         if (!error) {
2302                                                 vattr.va_mask = AT_SIZE;
2303                                                 error = nfs3setattr(vp,
2304                                                     &vattr, 0, cr);
2305 
2306                                                 /*
2307                                                  * Existing file was truncated;
2308                                                  * emit a create event.
2309                                                  */
2310                                                 vnevent_create(vp, ct);
2311                                         }
2312                                 }
2313                         }
2314                 }
2315                 nfs_rw_exit(&drp->r_rwlock);
2316                 if (error) {
2317                         VN_RELE(vp);
2318                 } else {




2319                         *vpp = vp;
2320                 }
2321 
2322                 return (error);
2323         }
2324 
2325         dnlc_remove(dvp, nm);
2326 
2327         /*
2328          * Decide what the group-id of the created file should be.
2329          * Set it in attribute list as advisory...
2330          */
2331         error = setdirgid(dvp, &vattr.va_gid, cr);
2332         if (error) {
2333                 nfs_rw_exit(&drp->r_rwlock);
2334                 return (error);
2335         }
2336         vattr.va_mask |= AT_GID;
2337 
2338         ASSERT(vattr.va_mask & AT_TYPE);
2339         if (vattr.va_type == VREG) {
2340                 ASSERT(vattr.va_mask & AT_MODE);
2341                 if (MANDMODE(vattr.va_mode)) {