Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: introduce dot and dotdot name check

This patch adds an inline function to check dot and dotdot names.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

+12 -2
+11
fs/f2fs/f2fs.h
··· 1454 1454 sbi->sb->s_flags |= MS_RDONLY; 1455 1455 } 1456 1456 1457 + static inline bool is_dot_dotdot(const struct qstr *str) 1458 + { 1459 + if (str->len == 1 && str->name[0] == '.') 1460 + return true; 1461 + 1462 + if (str->len == 2 && str->name[0] == '.' && str->name[1] == '.') 1463 + return true; 1464 + 1465 + return false; 1466 + } 1467 + 1457 1468 #define get_inode_mode(i) \ 1458 1469 ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \ 1459 1470 (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
+1 -2
fs/f2fs/hash.c
··· 79 79 const unsigned char *name = name_info->name; 80 80 size_t len = name_info->len; 81 81 82 - if ((len <= 2) && (name[0] == '.') && 83 - (name[1] == '.' || name[1] == '\0')) 82 + if (is_dot_dotdot(name_info)) 84 83 return 0; 85 84 86 85 /* Initialize the default seed for the hash checksum functions */