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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/tmpfs/tmp_vnops.c
          +++ new/usr/src/uts/common/fs/tmpfs/tmp_vnops.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       29 + */
       30 +
  27   31  #include <sys/types.h>
  28   32  #include <sys/param.h>
  29   33  #include <sys/t_lock.h>
  30   34  #include <sys/systm.h>
  31   35  #include <sys/sysmacros.h>
  32   36  #include <sys/user.h>
  33   37  #include <sys/time.h>
  34   38  #include <sys/vfs.h>
  35   39  #include <sys/vfs_opreg.h>
  36   40  #include <sys/vnode.h>
↓ open down ↓ 934 lines elided ↑ open up ↑
 971  975           * Null component name is a synonym for directory being searched.
 972  976           */
 973  977          if (*nm == '\0') {
 974  978                  VN_HOLD(dvp);
 975  979                  oldtp = parent;
 976  980          } else {
 977  981                  error = tdirlookup(parent, nm, &oldtp, cred);
 978  982          }
 979  983  
 980  984          if (error == 0) {       /* name found */
      985 +                boolean_t trunc = B_FALSE;
      986 +
 981  987                  ASSERT(oldtp);
 982  988  
 983  989                  rw_enter(&oldtp->tn_rwlock, RW_WRITER);
 984  990  
 985  991                  /*
 986  992                   * if create/read-only an existing
 987  993                   * directory, allow it
 988  994                   */
 989  995                  if (exclusive == EXCL)
 990  996                          error = EEXIST;
↓ open down ↓ 7 lines elided ↑ open up ↑
 998 1004                          rw_exit(&oldtp->tn_rwlock);
 999 1005                          tmpnode_rele(oldtp);
1000 1006                          return (error);
1001 1007                  }
1002 1008                  *vpp = TNTOV(oldtp);
1003 1009                  if ((*vpp)->v_type == VREG && (vap->va_mask & AT_SIZE) &&
1004 1010                      vap->va_size == 0) {
1005 1011                          rw_enter(&oldtp->tn_contents, RW_WRITER);
1006 1012                          (void) tmpnode_trunc(tm, oldtp, 0);
1007 1013                          rw_exit(&oldtp->tn_contents);
     1014 +                        trunc = B_TRUE;
1008 1015                  }
1009 1016                  rw_exit(&oldtp->tn_rwlock);
1010 1017                  if (IS_DEVVP(*vpp)) {
1011 1018                          struct vnode *newvp;
1012 1019  
1013 1020                          newvp = specvp(*vpp, (*vpp)->v_rdev, (*vpp)->v_type,
1014 1021                              cred);
1015 1022                          VN_RELE(*vpp);
1016 1023                          if (newvp == NULL) {
1017 1024                                  return (ENOSYS);
1018 1025                          }
1019 1026                          *vpp = newvp;
1020 1027                  }
1021 1028  
1022      -                if (error == 0) {
     1029 +                if (trunc)
1023 1030                          vnevent_create(*vpp, ct);
1024      -                }
     1031 +
1025 1032                  return (0);
1026 1033          }
1027 1034  
1028 1035          if (error != ENOENT)
1029 1036                  return (error);
1030 1037  
1031 1038          rw_enter(&parent->tn_rwlock, RW_WRITER);
1032 1039          error = tdirenter(tm, parent, nm, DE_CREATE,
1033 1040              (struct tmpnode *)NULL, (struct tmpnode *)NULL,
1034 1041              vap, &self, cred, ct);
↓ open down ↓ 1409 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX