^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/fs/ext4/dir.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1992, 1993, 1994, 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Remy Card (card@masi.ibp.fr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Laboratoire MASI - Institut Blaise Pascal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Universite Pierre et Marie Curie (Paris VI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * linux/fs/minix/dir.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (C) 1991, 1992 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * ext4 directory handling functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Big-endian to little-endian byte-swapping/bitmaps by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * David S. Miller (davem@caip.rutgers.edu), 1995
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Hash Tree Directory indexing (c) 2001 Daniel Phillips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/iversion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/unicode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "ext4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define DOTDOT_OFFSET 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static int ext4_dx_readdir(struct file *, struct dir_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * is_dx_dir() - check if a directory is using htree indexing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * @inode: directory inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Check if the given dir-inode refers to an htree-indexed directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * (or a directory which could potentially get converted to use htree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * indexing).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * Return 1 if it is a dx dir, 0 if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static int is_dx_dir(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (ext4_has_feature_dir_index(inode->i_sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) ((inode->i_size >> sb->s_blocksize_bits) == 1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) ext4_has_inline_data(inode)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static bool is_fake_entry(struct inode *dir, ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned int offset, unsigned int blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Entries in the first block before this value refer to . or .. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (lblk == 0 && offset <= DOTDOT_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* Check if this is likely the csum entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (ext4_has_metadata_csum(dir->i_sb) && offset % blocksize ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) blocksize - sizeof(struct ext4_dir_entry_tail))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Return 0 if the directory entry is OK, and 1 if there is a problem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * Note: this is the opposite of what ext2 and ext3 historically returned...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * bh passed here can be an inode block or a dir data block, depending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * on the inode inline data flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int __ext4_check_dir_entry(const char *function, unsigned int line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct inode *dir, struct file *filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct ext4_dir_entry_2 *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct buffer_head *bh, char *buf, int size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ext4_lblk_t lblk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) const char *error_msg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) const int rlen = ext4_rec_len_from_disk(de->rec_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) dir->i_sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) const int next_offset = ((char *) de - buf) + rlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned int blocksize = dir->i_sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) bool fake = is_fake_entry(dir, lblk, offset, blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) bool next_fake = is_fake_entry(dir, lblk, next_offset, blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (unlikely(rlen < ext4_dir_rec_len(1, fake ? NULL : dir)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) error_msg = "rec_len is smaller than minimal";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) else if (unlikely(rlen % 4 != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) error_msg = "rec_len % 4 != 0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) else if (unlikely(rlen < ext4_dir_rec_len(de->name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) fake ? NULL : dir)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) error_msg = "rec_len is too small for name_len";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) else if (unlikely(next_offset > size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) error_msg = "directory entry overrun";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) else if (unlikely(next_offset > size - ext4_dir_rec_len(1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) next_fake ? NULL : dir) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) next_offset != size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) error_msg = "directory entry too close to block end";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) else if (unlikely(le32_to_cpu(de->inode) >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) error_msg = "inode out of bounds";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ext4_error_file(filp, function, line, bh->b_blocknr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) "bad entry in directory: %s - offset=%u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "inode=%u, rec_len=%d, lblk=%d, size=%d fake=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) error_msg, offset, le32_to_cpu(de->inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) rlen, lblk, size, fake);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) ext4_error_inode(dir, function, line, bh->b_blocknr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) "bad entry in directory: %s - offset=%u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) "inode=%u, rec_len=%d, lblk=%d, size=%d fake=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) error_msg, offset, le32_to_cpu(de->inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) rlen, lblk, size, fake);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static int ext4_readdir(struct file *file, struct dir_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) unsigned int offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct ext4_dir_entry_2 *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct buffer_head *bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct fscrypt_str fstr = FSTR_INIT(NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) err = fscrypt_prepare_readdir(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (is_dx_dir(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) err = ext4_dx_readdir(file, ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (err != ERR_BAD_DX_DIR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Can we just clear INDEX flag to ignore htree information? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (!ext4_has_metadata_csum(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * We don't set the inode dirty flag since it's not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * critical that it gets flushed back to the disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ext4_clear_inode_flag(inode, EXT4_INODE_INDEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (ext4_has_inline_data(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int has_inline_data = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) err = ext4_read_inline_dir(file, ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) &has_inline_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (has_inline_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (IS_ENCRYPTED(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) err = fscrypt_fname_alloc_buffer(EXT4_NAME_LEN, &fstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) while (ctx->pos < inode->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct ext4_map_blocks map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (fatal_signal_pending(current)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) err = -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) goto errout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) offset = ctx->pos & (sb->s_blocksize - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) map.m_lblk = ctx->pos >> EXT4_BLOCK_SIZE_BITS(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) map.m_len = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) err = ext4_map_blocks(NULL, inode, &map, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* m_len should never be zero but let's avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * an infinite loop if it somehow is */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (map.m_len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) map.m_len = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ctx->pos += map.m_len * sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (err > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pgoff_t index = map.m_pblk >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) (PAGE_SHIFT - inode->i_blkbits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (!ra_has_index(&file->f_ra, index))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) page_cache_sync_readahead(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) sb->s_bdev->bd_inode->i_mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) &file->f_ra, file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) index, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) file->f_ra.prev_pos = (loff_t)index << PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) bh = ext4_bread(NULL, inode, map.m_lblk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (IS_ERR(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) err = PTR_ERR(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) goto errout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (!bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /* corrupt size? Maybe no more blocks to read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (ctx->pos > inode->i_blocks << 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) ctx->pos += sb->s_blocksize - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* Check the checksum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (!buffer_verified(bh) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) !ext4_dirblock_csum_verify(inode, bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) EXT4_ERROR_FILE(file, 0, "directory fails checksum "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) "at offset %llu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) (unsigned long long)ctx->pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ctx->pos += sb->s_blocksize - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) set_buffer_verified(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /* If the dir block has changed since the last call to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * readdir(2), then we might be pointing to an invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * dirent right now. Scan from the start of the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * to make sure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (!inode_eq_iversion(inode, file->f_version)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) for (i = 0; i < sb->s_blocksize && i < offset; ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) de = (struct ext4_dir_entry_2 *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) (bh->b_data + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) /* It's too expensive to do a full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * dirent test each time round this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * loop, but we do have to test at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * least that it is non-zero. A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * failure will be detected in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * dirent test below. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (ext4_rec_len_from_disk(de->rec_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) sb->s_blocksize) < ext4_dir_rec_len(1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) i += ext4_rec_len_from_disk(de->rec_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) offset = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) | offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) file->f_version = inode_query_iversion(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) while (ctx->pos < inode->i_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) && offset < sb->s_blocksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) de = (struct ext4_dir_entry_2 *) (bh->b_data + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (ext4_check_dir_entry(inode, file, de, bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) bh->b_data, bh->b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) map.m_lblk, offset)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * On error, skip to the next block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ctx->pos = (ctx->pos |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) (sb->s_blocksize - 1)) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) offset += ext4_rec_len_from_disk(de->rec_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (le32_to_cpu(de->inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) if (!IS_ENCRYPTED(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (!dir_emit(ctx, de->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) de->name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) le32_to_cpu(de->inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) get_dtype(sb, de->file_type)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) int save_len = fstr.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct fscrypt_str de_name =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) FSTR_INIT(de->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) de->name_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) /* Directory is encrypted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) err = fscrypt_fname_disk_to_usr(inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) EXT4_DIRENT_HASH(de),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) EXT4_DIRENT_MINOR_HASH(de),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) &de_name, &fstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) de_name = fstr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) fstr.len = save_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) goto errout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (!dir_emit(ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) de_name.name, de_name.len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) le32_to_cpu(de->inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) get_dtype(sb, de->file_type)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) ctx->pos += ext4_rec_len_from_disk(de->rec_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if ((ctx->pos < inode->i_size) && !dir_relax_shared(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) errout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) fscrypt_fname_free_buffer(&fstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static inline int is_32bit_api(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) return in_compat_syscall();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) return (BITS_PER_LONG == 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * These functions convert from the major/minor hash to an f_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * value for dx directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * Upper layer (for example NFS) should specify FMODE_32BITHASH or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * FMODE_64BITHASH explicitly. On the other hand, we allow ext4 to be mounted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * directly on both 32-bit and 64-bit nodes, under such case, neither
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * FMODE_32BITHASH nor FMODE_64BITHASH is specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static inline loff_t hash2pos(struct file *filp, __u32 major, __u32 minor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if ((filp->f_mode & FMODE_32BITHASH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) return major >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) return ((__u64)(major >> 1) << 32) | (__u64)minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) static inline __u32 pos2maj_hash(struct file *filp, loff_t pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if ((filp->f_mode & FMODE_32BITHASH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return (pos << 1) & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return ((pos >> 32) << 1) & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static inline __u32 pos2min_hash(struct file *filp, loff_t pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) if ((filp->f_mode & FMODE_32BITHASH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return pos & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * Return 32- or 64-bit end-of-file for dx directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) static inline loff_t ext4_get_htree_eof(struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if ((filp->f_mode & FMODE_32BITHASH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) (!(filp->f_mode & FMODE_64BITHASH) && is_32bit_api()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return EXT4_HTREE_EOF_32BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) return EXT4_HTREE_EOF_64BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * ext4_dir_llseek() calls generic_file_llseek_size to handle htree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * directories, where the "offset" is in terms of the filename hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * value instead of the byte offset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * Because we may return a 64-bit hash that is well beyond offset limits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * we need to pass the max hash as the maximum allowable offset in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * the htree directory case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * For non-htree, ext4_llseek already chooses the proper max offset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) struct inode *inode = file->f_mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int dx_dir = is_dx_dir(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) loff_t ret, htree_max = ext4_get_htree_eof(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (likely(dx_dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) ret = generic_file_llseek_size(file, offset, whence,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) htree_max, htree_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) ret = ext4_llseek(file, offset, whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) file->f_version = inode_peek_iversion(inode) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * This structure holds the nodes of the red-black tree used to store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * the directory entry in hash order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) struct fname {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) __u32 hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) __u32 minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) struct rb_node rb_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct fname *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) __u32 inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) __u8 name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) __u8 file_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) char name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * This functoin implements a non-recursive way of freeing all of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * nodes in the red-black tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) static void free_rb_tree_fname(struct rb_root *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) struct fname *fname, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) rbtree_postorder_for_each_entry_safe(fname, next, root, rb_hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) while (fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct fname *old = fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) fname = fname->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) kfree(old);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) *root = RB_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) loff_t pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) struct dir_private_info *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) p = kzalloc(sizeof(*p), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) p->curr_hash = pos2maj_hash(filp, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) p->curr_minor_hash = pos2min_hash(filp, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) void ext4_htree_free_dir_info(struct dir_private_info *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) free_rb_tree_fname(&p->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) kfree(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * Given a directory entry, enter it into the fname rb tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * When filename encryption is enabled, the dirent will hold the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * encrypted filename, while the htree will hold decrypted filename.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * The decrypted filename is passed in via ent_name. parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) __u32 minor_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) struct ext4_dir_entry_2 *dirent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct fscrypt_str *ent_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct rb_node **p, *parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct fname *fname, *new_fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) struct dir_private_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) info = dir_file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) p = &info->root.rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /* Create and allocate the fname structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) len = sizeof(struct fname) + ent_name->len + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) new_fn = kzalloc(len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) if (!new_fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) new_fn->hash = hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) new_fn->minor_hash = minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) new_fn->inode = le32_to_cpu(dirent->inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) new_fn->name_len = ent_name->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) new_fn->file_type = dirent->file_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) memcpy(new_fn->name, ent_name->name, ent_name->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) while (*p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) parent = *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) fname = rb_entry(parent, struct fname, rb_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * If the hash and minor hash match up, then we put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * them on a linked list. This rarely happens...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) if ((new_fn->hash == fname->hash) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) (new_fn->minor_hash == fname->minor_hash)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) new_fn->next = fname->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) fname->next = new_fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (new_fn->hash < fname->hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) p = &(*p)->rb_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) else if (new_fn->hash > fname->hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) p = &(*p)->rb_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) else if (new_fn->minor_hash < fname->minor_hash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) p = &(*p)->rb_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) else /* if (new_fn->minor_hash > fname->minor_hash) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) p = &(*p)->rb_right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) rb_link_node(&new_fn->rb_hash, parent, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) rb_insert_color(&new_fn->rb_hash, &info->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * This is a helper function for ext4_dx_readdir. It calls filldir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * for all entres on the fname linked list. (Normally there is only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * one entry on the linked list, unless there are 62 bit hash collisions.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) static int call_filldir(struct file *file, struct dir_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) struct fname *fname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) struct dir_private_info *info = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) if (!fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) ext4_msg(sb, KERN_ERR, "%s:%d: inode #%lu: comm %s: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) "called with null fname?!?", __func__, __LINE__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) inode->i_ino, current->comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) ctx->pos = hash2pos(file, fname->hash, fname->minor_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) while (fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (!dir_emit(ctx, fname->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) fname->name_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) fname->inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) get_dtype(sb, fname->file_type))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) info->extra_fname = fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) fname = fname->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) static int ext4_dx_readdir(struct file *file, struct dir_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) struct dir_private_info *info = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) struct fname *fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) info = ext4_htree_create_dir_info(file, ctx->pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) if (!info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) file->private_data = info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (ctx->pos == ext4_get_htree_eof(file))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) return 0; /* EOF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) /* Some one has messed with f_pos; reset the world */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) if (info->last_pos != ctx->pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) free_rb_tree_fname(&info->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) info->curr_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) info->extra_fname = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) info->curr_hash = pos2maj_hash(file, ctx->pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) info->curr_minor_hash = pos2min_hash(file, ctx->pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) * If there are any leftover names on the hash collision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) * chain, return them first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (info->extra_fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if (call_filldir(file, ctx, info->extra_fname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) info->extra_fname = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) goto next_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) } else if (!info->curr_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) info->curr_node = rb_first(&info->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * Fill the rbtree if we have no more entries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * or the inode has changed since we last read in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) * cached entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) if ((!info->curr_node) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) !inode_eq_iversion(inode, file->f_version)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) info->curr_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) free_rb_tree_fname(&info->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) file->f_version = inode_query_iversion(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) ret = ext4_htree_fill_tree(file, info->curr_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) info->curr_minor_hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) &info->next_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) ctx->pos = ext4_get_htree_eof(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) info->curr_node = rb_first(&info->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) fname = rb_entry(info->curr_node, struct fname, rb_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) info->curr_hash = fname->hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) info->curr_minor_hash = fname->minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) if (call_filldir(file, ctx, fname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) next_node:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) info->curr_node = rb_next(info->curr_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) if (info->curr_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) fname = rb_entry(info->curr_node, struct fname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) rb_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) info->curr_hash = fname->hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) info->curr_minor_hash = fname->minor_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (info->next_hash == ~0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) ctx->pos = ext4_get_htree_eof(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) info->curr_hash = info->next_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) info->curr_minor_hash = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) finished:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) info->last_pos = ctx->pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) return ret < 0 ? ret : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) static int ext4_release_dir(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) if (filp->private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) ext4_htree_free_dir_info(filp->private_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) int buf_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) struct ext4_dir_entry_2 *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) int rlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) unsigned int offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) char *top;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) de = (struct ext4_dir_entry_2 *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) top = buf + buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) while ((char *) de < top) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) if (ext4_check_dir_entry(dir, NULL, de, bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) buf, buf_size, 0, offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) return -EFSCORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) rlen = ext4_rec_len_from_disk(de->rec_len, buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) de = (struct ext4_dir_entry_2 *)((char *)de + rlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) offset += rlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) if ((char *) de > top)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) return -EFSCORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) const struct file_operations ext4_dir_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) .llseek = ext4_dir_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) .read = generic_read_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) .iterate_shared = ext4_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) .unlocked_ioctl = ext4_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) .compat_ioctl = ext4_compat_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) .fsync = ext4_sync_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .release = ext4_release_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) };