@@ -154,7 +154,7 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd,
154154 return true;
155155
156156 /* Always recalc d_ino for parent */
157- if (strcmp (p -> name , ".." ) == 0 )
157+ if (name_is_dotdot (p -> name , p -> len ) )
158158 return true;
159159
160160 /* If this is lower, then native d_ino will do */
@@ -165,7 +165,7 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd,
165165 * Recalc d_ino for '.' and for all entries if dir is impure (contains
166166 * copied up entries)
167167 */
168- if ((p -> name [ 0 ] == '.' && p -> len == 1 ) ||
168+ if (name_is_dot (p -> name , p -> len ) ||
169169 ovl_test_flag (OVL_IMPURE , d_inode (rdd -> dentry )))
170170 return true;
171171
@@ -561,12 +561,12 @@ static int ovl_cache_update(const struct path *path, struct ovl_cache_entry *p,
561561 if (!ovl_same_dev (ofs ) && !p -> check_xwhiteout )
562562 goto out ;
563563
564- if (p -> name [ 0 ] == '.' ) {
564+ if (name_is_dot_dotdot ( p -> name , p -> len ) ) {
565565 if (p -> len == 1 ) {
566566 this = dget (dir );
567567 goto get ;
568568 }
569- if (p -> len == 2 && p -> name [ 1 ] == '.' ) {
569+ if (p -> len == 2 ) {
570570 /* we shall not be moved */
571571 this = dget (dir -> d_parent );
572572 goto get ;
@@ -666,8 +666,7 @@ static int ovl_dir_read_impure(const struct path *path, struct list_head *list,
666666 return err ;
667667
668668 list_for_each_entry_safe (p , n , list , l_node ) {
669- if (strcmp (p -> name , "." ) != 0 &&
670- strcmp (p -> name , ".." ) != 0 ) {
669+ if (!name_is_dot_dotdot (p -> name , p -> len )) {
671670 err = ovl_cache_update (path , p , true);
672671 if (err )
673672 return err ;
@@ -756,7 +755,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name,
756755 struct dir_context * orig_ctx = rdt -> orig_ctx ;
757756 bool res ;
758757
759- if (rdt -> parent_ino && namelen == 2 && ! strncmp (name , ".." , 2 )) {
758+ if (rdt -> parent_ino && name_is_dotdot (name , namelen )) {
760759 ino = rdt -> parent_ino ;
761760 } else if (rdt -> cache ) {
762761 struct ovl_cache_entry * p ;
@@ -1097,12 +1096,8 @@ int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
10971096 goto del_entry ;
10981097 }
10991098
1100- if (p -> name [0 ] == '.' ) {
1101- if (p -> len == 1 )
1102- goto del_entry ;
1103- if (p -> len == 2 && p -> name [1 ] == '.' )
1104- goto del_entry ;
1105- }
1099+ if (name_is_dot_dotdot (p -> name , p -> len ))
1100+ goto del_entry ;
11061101 err = - ENOTEMPTY ;
11071102 break ;
11081103
@@ -1146,7 +1141,7 @@ static bool ovl_check_d_type(struct dir_context *ctx, const char *name,
11461141 container_of (ctx , struct ovl_readdir_data , ctx );
11471142
11481143 /* Even if d_type is not supported, DT_DIR is returned for . and .. */
1149- if (! strncmp (name , "." , namelen ) || ! strncmp ( name , ".." , namelen ))
1144+ if (name_is_dot_dotdot (name , namelen ))
11501145 return true;
11511146
11521147 if (d_type != DT_UNKNOWN )
@@ -1209,11 +1204,8 @@ static int ovl_workdir_cleanup_recurse(struct ovl_fs *ofs, const struct path *pa
12091204 list_for_each_entry (p , & list , l_node ) {
12101205 struct dentry * dentry ;
12111206
1212- if (p -> name [0 ] == '.' ) {
1213- if (p -> len == 1 )
1214- continue ;
1215- if (p -> len == 2 && p -> name [1 ] == '.' )
1216- continue ;
1207+ if (name_is_dot_dotdot (p -> name , p -> len )) {
1208+ continue ;
12171209 } else if (incompat ) {
12181210 pr_err ("overlay with incompat feature '%s' cannot be mounted\n" ,
12191211 p -> name );
@@ -1278,12 +1270,8 @@ int ovl_indexdir_cleanup(struct ovl_fs *ofs)
12781270 goto out ;
12791271
12801272 list_for_each_entry (p , & list , l_node ) {
1281- if (p -> name [0 ] == '.' ) {
1282- if (p -> len == 1 )
1283- continue ;
1284- if (p -> len == 2 && p -> name [1 ] == '.' )
1285- continue ;
1286- }
1273+ if (name_is_dot_dotdot (p -> name , p -> len ))
1274+ continue ;
12871275 index = ovl_lookup_upper_unlocked (ofs , p -> name , indexdir , p -> len );
12881276 if (IS_ERR (index )) {
12891277 err = PTR_ERR (index );
0 commit comments