diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-03-02 23:58:05 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-03-18 08:00:35 -0400 |
commit | 5a20d339c785d98d8b050b9afc098e4184a6098c (patch) | |
tree | 444a543268e5bf03d42926da8db7f9c43ba5c4bd | |
parent | 3aa770a9c9d077283b1aa07e8549a4fdc41fc5ed (diff) |
f2fs: align f2fs maximum name length to linux based filesystem
The maximum filename length supported in linux is 255 characters.
So let's follow that.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/dir.c | 3 | ||||
-rw-r--r-- | fs/f2fs/namei.c | 2 | ||||
-rw-r--r-- | fs/f2fs/super.c | 2 | ||||
-rw-r--r-- | include/linux/f2fs_fs.h | 17 |
4 files changed, 14 insertions, 10 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index a1f38443ecee..2851ae6948a1 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -189,6 +189,9 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, | |||
189 | unsigned int max_depth; | 189 | unsigned int max_depth; |
190 | unsigned int level; | 190 | unsigned int level; |
191 | 191 | ||
192 | if (namelen > F2FS_NAME_LEN) | ||
193 | return NULL; | ||
194 | |||
192 | if (npages == 0) | 195 | if (npages == 0) |
193 | return NULL; | 196 | return NULL; |
194 | 197 | ||
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 1a49b881bac0..d4a171b1a68b 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -197,7 +197,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, | |||
197 | struct f2fs_dir_entry *de; | 197 | struct f2fs_dir_entry *de; |
198 | struct page *page; | 198 | struct page *page; |
199 | 199 | ||
200 | if (dentry->d_name.len > F2FS_MAX_NAME_LEN) | 200 | if (dentry->d_name.len > F2FS_NAME_LEN) |
201 | return ERR_PTR(-ENAMETOOLONG); | 201 | return ERR_PTR(-ENAMETOOLONG); |
202 | 202 | ||
203 | de = f2fs_find_entry(dir, &dentry->d_name, &page); | 203 | de = f2fs_find_entry(dir, &dentry->d_name, &page); |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8c117649a035..1c7f595ca47c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -180,7 +180,7 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
180 | buf->f_files = sbi->total_node_count; | 180 | buf->f_files = sbi->total_node_count; |
181 | buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi); | 181 | buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi); |
182 | 182 | ||
183 | buf->f_namelen = F2FS_MAX_NAME_LEN; | 183 | buf->f_namelen = F2FS_NAME_LEN; |
184 | buf->f_fsid.val[0] = (u32)id; | 184 | buf->f_fsid.val[0] = (u32)id; |
185 | buf->f_fsid.val[1] = (u32)(id >> 32); | 185 | buf->f_fsid.val[1] = (u32)(id >> 32); |
186 | 186 | ||
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h index f9a12f6243a5..df6fab82f87e 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h | |||
@@ -139,7 +139,7 @@ struct f2fs_extent { | |||
139 | __le32 len; /* lengh of the extent */ | 139 | __le32 len; /* lengh of the extent */ |
140 | } __packed; | 140 | } __packed; |
141 | 141 | ||
142 | #define F2FS_MAX_NAME_LEN 256 | 142 | #define F2FS_NAME_LEN 255 |
143 | #define ADDRS_PER_INODE 923 /* Address Pointers in an Inode */ | 143 | #define ADDRS_PER_INODE 923 /* Address Pointers in an Inode */ |
144 | #define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */ | 144 | #define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */ |
145 | #define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */ | 145 | #define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */ |
@@ -165,7 +165,8 @@ struct f2fs_inode { | |||
165 | __le32 i_flags; /* file attributes */ | 165 | __le32 i_flags; /* file attributes */ |
166 | __le32 i_pino; /* parent inode number */ | 166 | __le32 i_pino; /* parent inode number */ |
167 | __le32 i_namelen; /* file name length */ | 167 | __le32 i_namelen; /* file name length */ |
168 | __u8 i_name[F2FS_MAX_NAME_LEN]; /* file name for SPOR */ | 168 | __u8 i_name[F2FS_NAME_LEN]; /* file name for SPOR */ |
169 | __u8 i_reserved2; /* for backward compatibility */ | ||
169 | 170 | ||
170 | struct f2fs_extent i_ext; /* caching a largest extent */ | 171 | struct f2fs_extent i_ext; /* caching a largest extent */ |
171 | 172 | ||
@@ -362,10 +363,10 @@ struct f2fs_summary_block { | |||
362 | typedef __le32 f2fs_hash_t; | 363 | typedef __le32 f2fs_hash_t; |
363 | 364 | ||
364 | /* One directory entry slot covers 8bytes-long file name */ | 365 | /* One directory entry slot covers 8bytes-long file name */ |
365 | #define F2FS_NAME_LEN 8 | 366 | #define F2FS_SLOT_LEN 8 |
366 | #define F2FS_NAME_LEN_BITS 3 | 367 | #define F2FS_SLOT_LEN_BITS 3 |
367 | 368 | ||
368 | #define GET_DENTRY_SLOTS(x) ((x + F2FS_NAME_LEN - 1) >> F2FS_NAME_LEN_BITS) | 369 | #define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS) |
369 | 370 | ||
370 | /* the number of dentry in a block */ | 371 | /* the number of dentry in a block */ |
371 | #define NR_DENTRY_IN_BLOCK 214 | 372 | #define NR_DENTRY_IN_BLOCK 214 |
@@ -377,10 +378,10 @@ typedef __le32 f2fs_hash_t; | |||
377 | #define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \ | 378 | #define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \ |
378 | BITS_PER_BYTE) | 379 | BITS_PER_BYTE) |
379 | #define SIZE_OF_RESERVED (PAGE_SIZE - ((SIZE_OF_DIR_ENTRY + \ | 380 | #define SIZE_OF_RESERVED (PAGE_SIZE - ((SIZE_OF_DIR_ENTRY + \ |
380 | F2FS_NAME_LEN) * \ | 381 | F2FS_SLOT_LEN) * \ |
381 | NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP)) | 382 | NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP)) |
382 | 383 | ||
383 | /* One directory entry slot representing F2FS_NAME_LEN-sized file name */ | 384 | /* One directory entry slot representing F2FS_SLOT_LEN-sized file name */ |
384 | struct f2fs_dir_entry { | 385 | struct f2fs_dir_entry { |
385 | __le32 hash_code; /* hash code of file name */ | 386 | __le32 hash_code; /* hash code of file name */ |
386 | __le32 ino; /* inode number */ | 387 | __le32 ino; /* inode number */ |
@@ -394,7 +395,7 @@ struct f2fs_dentry_block { | |||
394 | __u8 dentry_bitmap[SIZE_OF_DENTRY_BITMAP]; | 395 | __u8 dentry_bitmap[SIZE_OF_DENTRY_BITMAP]; |
395 | __u8 reserved[SIZE_OF_RESERVED]; | 396 | __u8 reserved[SIZE_OF_RESERVED]; |
396 | struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK]; | 397 | struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK]; |
397 | __u8 filename[NR_DENTRY_IN_BLOCK][F2FS_NAME_LEN]; | 398 | __u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; |
398 | } __packed; | 399 | } __packed; |
399 | 400 | ||
400 | /* file types used in inode_info->flags */ | 401 | /* file types used in inode_info->flags */ |