diff options
Diffstat (limited to 'fs/ext4/namei.c')
| -rw-r--r-- | fs/ext4/namei.c | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index a43e6617b351..314c0d3b3fa9 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
| @@ -179,30 +179,6 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, | |||
| 179 | static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | 179 | static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, |
| 180 | struct inode *inode); | 180 | struct inode *inode); |
| 181 | 181 | ||
| 182 | unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) | ||
| 183 | { | ||
| 184 | unsigned len = le16_to_cpu(dlen); | ||
| 185 | |||
| 186 | if (len == EXT4_MAX_REC_LEN || len == 0) | ||
| 187 | return blocksize; | ||
| 188 | return (len & 65532) | ((len & 3) << 16); | ||
| 189 | } | ||
| 190 | |||
| 191 | __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) | ||
| 192 | { | ||
| 193 | if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)) | ||
| 194 | BUG(); | ||
| 195 | if (len < 65536) | ||
| 196 | return cpu_to_le16(len); | ||
| 197 | if (len == blocksize) { | ||
| 198 | if (blocksize == 65536) | ||
| 199 | return cpu_to_le16(EXT4_MAX_REC_LEN); | ||
| 200 | else | ||
| 201 | return cpu_to_le16(0); | ||
| 202 | } | ||
| 203 | return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); | ||
| 204 | } | ||
| 205 | |||
| 206 | /* | 182 | /* |
| 207 | * p is at least 6 bytes before the end of page | 183 | * p is at least 6 bytes before the end of page |
| 208 | */ | 184 | */ |
| @@ -605,7 +581,7 @@ static int htree_dirblock_to_tree(struct file *dir_file, | |||
| 605 | dir->i_sb->s_blocksize - | 581 | dir->i_sb->s_blocksize - |
| 606 | EXT4_DIR_REC_LEN(0)); | 582 | EXT4_DIR_REC_LEN(0)); |
| 607 | for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { | 583 | for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { |
| 608 | if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh, | 584 | if (!ext4_check_dir_entry(dir, de, bh, |
| 609 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) | 585 | (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) |
| 610 | +((char *)de - bh->b_data))) { | 586 | +((char *)de - bh->b_data))) { |
| 611 | /* On error, skip the f_pos to the next block. */ | 587 | /* On error, skip the f_pos to the next block. */ |
| @@ -844,8 +820,7 @@ static inline int search_dirblock(struct buffer_head *bh, | |||
| 844 | if ((char *) de + namelen <= dlimit && | 820 | if ((char *) de + namelen <= dlimit && |
| 845 | ext4_match (namelen, name, de)) { | 821 | ext4_match (namelen, name, de)) { |
| 846 | /* found a match - just to be sure, do a full check */ | 822 | /* found a match - just to be sure, do a full check */ |
| 847 | if (!ext4_check_dir_entry("ext4_find_entry", | 823 | if (!ext4_check_dir_entry(dir, de, bh, offset)) |
| 848 | dir, de, bh, offset)) | ||
| 849 | return -1; | 824 | return -1; |
| 850 | *res_dir = de; | 825 | *res_dir = de; |
| 851 | return 1; | 826 | return 1; |
| @@ -1019,7 +994,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q | |||
| 1019 | int off = (block << EXT4_BLOCK_SIZE_BITS(sb)) | 994 | int off = (block << EXT4_BLOCK_SIZE_BITS(sb)) |
| 1020 | + ((char *) de - bh->b_data); | 995 | + ((char *) de - bh->b_data); |
| 1021 | 996 | ||
| 1022 | if (!ext4_check_dir_entry(__func__, dir, de, bh, off)) { | 997 | if (!ext4_check_dir_entry(dir, de, bh, off)) { |
| 1023 | brelse(bh); | 998 | brelse(bh); |
| 1024 | *err = ERR_BAD_DX_DIR; | 999 | *err = ERR_BAD_DX_DIR; |
| 1025 | goto errout; | 1000 | goto errout; |
| @@ -1088,7 +1063,6 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru | |||
| 1088 | struct dentry *ext4_get_parent(struct dentry *child) | 1063 | struct dentry *ext4_get_parent(struct dentry *child) |
| 1089 | { | 1064 | { |
| 1090 | __u32 ino; | 1065 | __u32 ino; |
| 1091 | struct inode *inode; | ||
| 1092 | static const struct qstr dotdot = { | 1066 | static const struct qstr dotdot = { |
| 1093 | .name = "..", | 1067 | .name = "..", |
| 1094 | .len = 2, | 1068 | .len = 2, |
| @@ -1097,7 +1071,6 @@ struct dentry *ext4_get_parent(struct dentry *child) | |||
| 1097 | struct buffer_head *bh; | 1071 | struct buffer_head *bh; |
| 1098 | 1072 | ||
| 1099 | bh = ext4_find_entry(child->d_inode, &dotdot, &de); | 1073 | bh = ext4_find_entry(child->d_inode, &dotdot, &de); |
| 1100 | inode = NULL; | ||
| 1101 | if (!bh) | 1074 | if (!bh) |
| 1102 | return ERR_PTR(-ENOENT); | 1075 | return ERR_PTR(-ENOENT); |
| 1103 | ino = le32_to_cpu(de->inode); | 1076 | ino = le32_to_cpu(de->inode); |
| @@ -1305,8 +1278,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
| 1305 | de = (struct ext4_dir_entry_2 *)bh->b_data; | 1278 | de = (struct ext4_dir_entry_2 *)bh->b_data; |
| 1306 | top = bh->b_data + blocksize - reclen; | 1279 | top = bh->b_data + blocksize - reclen; |
| 1307 | while ((char *) de <= top) { | 1280 | while ((char *) de <= top) { |
| 1308 | if (!ext4_check_dir_entry("ext4_add_entry", dir, de, | 1281 | if (!ext4_check_dir_entry(dir, de, bh, offset)) |
| 1309 | bh, offset)) | ||
| 1310 | return -EIO; | 1282 | return -EIO; |
| 1311 | if (ext4_match(namelen, name, de)) | 1283 | if (ext4_match(namelen, name, de)) |
| 1312 | return -EEXIST; | 1284 | return -EEXIST; |
| @@ -1673,7 +1645,7 @@ static int ext4_delete_entry(handle_t *handle, | |||
| 1673 | pde = NULL; | 1645 | pde = NULL; |
| 1674 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1646 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
| 1675 | while (i < bh->b_size) { | 1647 | while (i < bh->b_size) { |
| 1676 | if (!ext4_check_dir_entry("ext4_delete_entry", dir, de, bh, i)) | 1648 | if (!ext4_check_dir_entry(dir, de, bh, i)) |
| 1677 | return -EIO; | 1649 | return -EIO; |
| 1678 | if (de == de_del) { | 1650 | if (de == de_del) { |
| 1679 | BUFFER_TRACE(bh, "get_write_access"); | 1651 | BUFFER_TRACE(bh, "get_write_access"); |
| @@ -1956,7 +1928,7 @@ static int empty_dir(struct inode *inode) | |||
| 1956 | } | 1928 | } |
| 1957 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1929 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
| 1958 | } | 1930 | } |
| 1959 | if (!ext4_check_dir_entry("empty_dir", inode, de, bh, offset)) { | 1931 | if (!ext4_check_dir_entry(inode, de, bh, offset)) { |
| 1960 | de = (struct ext4_dir_entry_2 *)(bh->b_data + | 1932 | de = (struct ext4_dir_entry_2 *)(bh->b_data + |
| 1961 | sb->s_blocksize); | 1933 | sb->s_blocksize); |
| 1962 | offset = (offset | (sb->s_blocksize - 1)) + 1; | 1934 | offset = (offset | (sb->s_blocksize - 1)) + 1; |
