@@ -76,7 +76,8 @@ static int ovl_casefold(struct ovl_readdir_data *rdd, const char *str, int len,
7676 char * cf_name ;
7777 int cf_len ;
7878
79- if (!IS_ENABLED (CONFIG_UNICODE ) || !rdd -> map || is_dot_dotdot (str , len ))
79+ if (!IS_ENABLED (CONFIG_UNICODE ) || !rdd -> map ||
80+ name_is_dot_dotdot (str , len ))
8081 return 0 ;
8182
8283 cf_name = kmalloc (NAME_MAX , GFP_KERNEL );
@@ -153,7 +154,7 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd,
153154 return true;
154155
155156 /* Always recalc d_ino for parent */
156- if (strcmp (p -> name , ".." ) == 0 )
157+ if (name_is_dotdot (p -> name , p -> len ) )
157158 return true;
158159
159160 /* If this is lower, then native d_ino will do */
@@ -164,7 +165,7 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd,
164165 * Recalc d_ino for '.' and for all entries if dir is impure (contains
165166 * copied up entries)
166167 */
167- if ((p -> name [ 0 ] == '.' && p -> len == 1 ) ||
168+ if (name_is_dot (p -> name , p -> len ) ||
168169 ovl_test_flag (OVL_IMPURE , d_inode (rdd -> dentry )))
169170 return true;
170171
@@ -560,12 +561,12 @@ static int ovl_cache_update(const struct path *path, struct ovl_cache_entry *p,
560561 if (!ovl_same_dev (ofs ) && !p -> check_xwhiteout )
561562 goto out ;
562563
563- if (p -> name [ 0 ] == '.' ) {
564+ if (name_is_dot_dotdot ( p -> name , p -> len ) ) {
564565 if (p -> len == 1 ) {
565566 this = dget (dir );
566567 goto get ;
567568 }
568- if (p -> len == 2 && p -> name [ 1 ] == '.' ) {
569+ if (p -> len == 2 ) {
569570 /* we shall not be moved */
570571 this = dget (dir -> d_parent );
571572 goto get ;
@@ -665,8 +666,7 @@ static int ovl_dir_read_impure(const struct path *path, struct list_head *list,
665666 return err ;
666667
667668 list_for_each_entry_safe (p , n , list , l_node ) {
668- if (strcmp (p -> name , "." ) != 0 &&
669- strcmp (p -> name , ".." ) != 0 ) {
669+ if (!name_is_dot_dotdot (p -> name , p -> len )) {
670670 err = ovl_cache_update (path , p , true);
671671 if (err )
672672 return err ;
@@ -755,7 +755,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name,
755755 struct dir_context * orig_ctx = rdt -> orig_ctx ;
756756 bool res ;
757757
758- if (rdt -> parent_ino && strcmp (name , ".." ) == 0 ) {
758+ if (rdt -> parent_ino && name_is_dotdot (name , namelen ) ) {
759759 ino = rdt -> parent_ino ;
760760 } else if (rdt -> cache ) {
761761 struct ovl_cache_entry * p ;
@@ -1096,12 +1096,8 @@ int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
10961096 goto del_entry ;
10971097 }
10981098
1099- if (p -> name [0 ] == '.' ) {
1100- if (p -> len == 1 )
1101- goto del_entry ;
1102- if (p -> len == 2 && p -> name [1 ] == '.' )
1103- goto del_entry ;
1104- }
1099+ if (name_is_dot_dotdot (p -> name , p -> len ))
1100+ goto del_entry ;
11051101 err = - ENOTEMPTY ;
11061102 break ;
11071103
@@ -1145,7 +1141,7 @@ static bool ovl_check_d_type(struct dir_context *ctx, const char *name,
11451141 container_of (ctx , struct ovl_readdir_data , ctx );
11461142
11471143 /* Even if d_type is not supported, DT_DIR is returned for . and .. */
1148- if (! strncmp (name , "." , namelen ) || ! strncmp ( name , ".." , namelen ))
1144+ if (name_is_dot_dotdot (name , namelen ))
11491145 return true;
11501146
11511147 if (d_type != DT_UNKNOWN )
@@ -1208,11 +1204,8 @@ static int ovl_workdir_cleanup_recurse(struct ovl_fs *ofs, const struct path *pa
12081204 list_for_each_entry (p , & list , l_node ) {
12091205 struct dentry * dentry ;
12101206
1211- if (p -> name [0 ] == '.' ) {
1212- if (p -> len == 1 )
1213- continue ;
1214- if (p -> len == 2 && p -> name [1 ] == '.' )
1215- continue ;
1207+ if (name_is_dot_dotdot (p -> name , p -> len )) {
1208+ continue ;
12161209 } else if (incompat ) {
12171210 pr_err ("overlay with incompat feature '%s' cannot be mounted\n" ,
12181211 p -> name );
@@ -1277,12 +1270,8 @@ int ovl_indexdir_cleanup(struct ovl_fs *ofs)
12771270 goto out ;
12781271
12791272 list_for_each_entry (p , & list , l_node ) {
1280- if (p -> name [0 ] == '.' ) {
1281- if (p -> len == 1 )
1282- continue ;
1283- if (p -> len == 2 && p -> name [1 ] == '.' )
1284- continue ;
1285- }
1273+ if (name_is_dot_dotdot (p -> name , p -> len ))
1274+ continue ;
12861275 index = ovl_lookup_upper_unlocked (ofs , p -> name , indexdir , p -> len );
12871276 if (IS_ERR (index )) {
12881277 err = PTR_ERR (index );
0 commit comments