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

@@ -23,10 +23,14 @@
  *
  *      Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
  *      All rights reserved.
  */
 
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ */
+
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/cred.h>
 #include <sys/time.h>

@@ -2028,21 +2032,25 @@
                         if (!(error = VOP_ACCESS(vp, mode, 0, cr, ct))) {
                                 if ((vattr.va_mask & AT_SIZE) &&
                                     vp->v_type == VREG) {
                                         vattr.va_mask = AT_SIZE;
                                         error = nfssetattr(vp, &vattr, 0, cr);
+
+                                        if (!error) {
+                                                /*
+                                                 * Existing file was truncated;
+                                                 * emit a create event.
+                                                 */
+                                                vnevent_create(vp, ct);
                                 }
                         }
                 }
+                }
                 nfs_rw_exit(&drp->r_rwlock);
                 if (error) {
                         VN_RELE(vp);
                 } else {
-                        /*
-                         * existing file got truncated, notify.
-                         */
-                        vnevent_create(vp, ct);
                         *vpp = vp;
                 }
                 return (error);
         }