mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
nilfs2: avoid rec_len overflow with 64KB block size
With 64KB blocksize, a directory entry can have size 64KB which does not fit into 16 bits we have for entry length. So this patch stores 0xffff instead and converts value when read from / written to disk. Nilfs derives its directory implementation from ext2 filesystem, and this draws upon the corresponding change on ext2. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
c28e69d933
commit
6cda9fa257
2 changed files with 32 additions and 12 deletions
|
@ -326,7 +326,25 @@ enum {
|
|||
#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1)
|
||||
#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \
|
||||
~NILFS_DIR_ROUND)
|
||||
#define NILFS_MAX_REC_LEN ((1<<16)-1)
|
||||
|
||||
static inline unsigned nilfs_rec_len_from_disk(__le16 dlen)
|
||||
{
|
||||
unsigned len = le16_to_cpu(dlen);
|
||||
|
||||
if (len == NILFS_MAX_REC_LEN)
|
||||
return 1 << 16;
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline __le16 nilfs_rec_len_to_disk(unsigned len)
|
||||
{
|
||||
if (len == (1 << 16))
|
||||
return cpu_to_le16(NILFS_MAX_REC_LEN);
|
||||
else if (len > (1 << 16))
|
||||
BUG();
|
||||
return cpu_to_le16(len);
|
||||
}
|
||||
|
||||
/**
|
||||
* struct nilfs_finfo - file information
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue