Re: [PATCH v17 04/10] fs/ntfs3: Add file operations and implementation
From: Matthew Wilcox
Date: Sun Jan 03 2021 - 21:49:11 EST
On Thu, Dec 31, 2020 at 06:23:55PM +0300, Konstantin Komarov wrote:
> +/*
> + * file_operations::iterate_shared
> + *
> + * Use non sorted enumeration.
> + * We have an example of broken volume where sorted enumeration
> + * counts each name twice
> + */
> +static int ntfs_readdir(struct file *file, struct dir_context *ctx)
> +{
> + const struct INDEX_ROOT *root;
> + u64 vbo;
> + size_t bit;
> + loff_t eod;
> + int err = 0;
> + struct inode *dir = file_inode(file);
> + struct ntfs_inode *ni = ntfs_i(dir);
> + struct super_block *sb = dir->i_sb;
> + struct ntfs_sb_info *sbi = sb->s_fs_info;
> + loff_t i_size = i_size_read(dir);
> + u32 pos = ctx->pos;
> + u8 *name = NULL;
> + struct indx_node *node = NULL;
> + u8 index_bits = ni->dir.index_bits;
> +
> + /* name is a buffer of PATH_MAX length */
> + static_assert(NTFS_NAME_LEN * 4 < PATH_MAX);
> +
> + eod = i_size + sbi->record_size;
> +
> + if (pos >= eod)
> + return 0;
> +
> + if (!dir_emit_dots(file, ctx))
> + return 0;
> +
> + /* allocate PATH_MAX bytes */
> + name = __getname();
> + if (!name)
> + return -ENOMEM;
> +
> + ni_lock(ni);
What is this lock protecting?