mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
[readdir] simple local unixlike: switch to ->iterate()
ext2, ufs, minix, sysv Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
bb6f619b3a
commit
80886298c0
4 changed files with 59 additions and 75 deletions
|
|
@ -287,17 +287,17 @@ static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
|
|||
}
|
||||
|
||||
static int
|
||||
ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
|
||||
ext2_readdir(struct file *file, struct dir_context *ctx)
|
||||
{
|
||||
loff_t pos = filp->f_pos;
|
||||
struct inode *inode = file_inode(filp);
|
||||
loff_t pos = ctx->pos;
|
||||
struct inode *inode = file_inode(file);
|
||||
struct super_block *sb = inode->i_sb;
|
||||
unsigned int offset = pos & ~PAGE_CACHE_MASK;
|
||||
unsigned long n = pos >> PAGE_CACHE_SHIFT;
|
||||
unsigned long npages = dir_pages(inode);
|
||||
unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
|
||||
unsigned char *types = NULL;
|
||||
int need_revalidate = filp->f_version != inode->i_version;
|
||||
int need_revalidate = file->f_version != inode->i_version;
|
||||
|
||||
if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
|
||||
return 0;
|
||||
|
|
@ -314,16 +314,16 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
|
|||
ext2_error(sb, __func__,
|
||||
"bad page in #%lu",
|
||||
inode->i_ino);
|
||||
filp->f_pos += PAGE_CACHE_SIZE - offset;
|
||||
ctx->pos += PAGE_CACHE_SIZE - offset;
|
||||
return PTR_ERR(page);
|
||||
}
|
||||
kaddr = page_address(page);
|
||||
if (unlikely(need_revalidate)) {
|
||||
if (offset) {
|
||||
offset = ext2_validate_entry(kaddr, offset, chunk_mask);
|
||||
filp->f_pos = (n<<PAGE_CACHE_SHIFT) + offset;
|
||||
ctx->pos = (n<<PAGE_CACHE_SHIFT) + offset;
|
||||
}
|
||||
filp->f_version = inode->i_version;
|
||||
file->f_version = inode->i_version;
|
||||
need_revalidate = 0;
|
||||
}
|
||||
de = (ext2_dirent *)(kaddr+offset);
|
||||
|
|
@ -336,22 +336,19 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
|
|||
return -EIO;
|
||||
}
|
||||
if (de->inode) {
|
||||
int over;
|
||||
unsigned char d_type = DT_UNKNOWN;
|
||||
|
||||
if (types && de->file_type < EXT2_FT_MAX)
|
||||
d_type = types[de->file_type];
|
||||
|
||||
offset = (char *)de - kaddr;
|
||||
over = filldir(dirent, de->name, de->name_len,
|
||||
(n<<PAGE_CACHE_SHIFT) | offset,
|
||||
le32_to_cpu(de->inode), d_type);
|
||||
if (over) {
|
||||
if (!dir_emit(ctx, de->name, de->name_len,
|
||||
le32_to_cpu(de->inode),
|
||||
d_type)) {
|
||||
ext2_put_page(page);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
filp->f_pos += ext2_rec_len_from_disk(de->rec_len);
|
||||
ctx->pos += ext2_rec_len_from_disk(de->rec_len);
|
||||
}
|
||||
ext2_put_page(page);
|
||||
}
|
||||
|
|
@ -724,7 +721,7 @@ not_empty:
|
|||
const struct file_operations ext2_dir_operations = {
|
||||
.llseek = generic_file_llseek,
|
||||
.read = generic_read_dir,
|
||||
.readdir = ext2_readdir,
|
||||
.iterate = ext2_readdir,
|
||||
.unlocked_ioctl = ext2_ioctl,
|
||||
#ifdef CONFIG_COMPAT
|
||||
.compat_ioctl = ext2_compat_ioctl,
|
||||
|
|
|
|||
Loading…
Reference in a new issue