Print this page
7203 unlinking a directory on tmpfs does not remove the directory entries
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Alexander Stetsenko <astetsenko@racktopsystems.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 ↓ 19 lines elided ↑ open up ↑
  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   27  /*
  28   28   * Copyright (c) 2015, Joyent, Inc. All rights reserved.
  29   29   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       30 + * Copyright 2016 RackTop Systems.
  30   31   */
  31   32  
  32   33  #include <sys/types.h>
  33   34  #include <sys/param.h>
  34   35  #include <sys/t_lock.h>
  35   36  #include <sys/systm.h>
  36   37  #include <sys/sysmacros.h>
  37   38  #include <sys/user.h>
  38   39  #include <sys/time.h>
  39   40  #include <sys/vfs.h>
↓ open down ↓ 1057 lines elided ↑ open up ↑
1097 1098          error = tdirlookup(parent, nm, &tp, cred);
1098 1099          if (error)
1099 1100                  return (error);
1100 1101  
1101 1102          ASSERT(tp);
1102 1103          rw_enter(&parent->tn_rwlock, RW_WRITER);
1103 1104          rw_enter(&tp->tn_rwlock, RW_WRITER);
1104 1105  
1105 1106          if (tp->tn_type != VDIR ||
1106 1107              (error = secpolicy_fs_linkdir(cred, dvp->v_vfsp)) == 0)
1107      -                error = tdirdelete(parent, tp, nm, DR_REMOVE, cred);
     1108 +                error = tdirdelete(parent, tp, nm, tp->tn_type == VDIR ?
     1109 +                    DR_RMDIR : DR_REMOVE, cred);
1108 1110  
1109 1111          rw_exit(&tp->tn_rwlock);
1110 1112          rw_exit(&parent->tn_rwlock);
1111 1113          vnevent_remove(TNTOV(tp), dvp, nm, ct);
1112 1114          tmpnode_rele(tp);
1113 1115  
1114 1116          TRACE_3(TR_FAC_TMPFS, TR_TMPFS_REMOVE,
1115 1117              "tmpfs remove:dvp %p nm %s error %d", dvp, nm, error);
1116 1118          return (error);
1117 1119  }
↓ open down ↓ 1352 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX