Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c0ba4e0 authored by Al Viro's avatar Al Viro
Browse files

[readdir] introduce iterate_dir() and dir_context



iterate_dir(): new helper, replacing vfs_readdir().

struct dir_context: contains the readdir callback (and will get more stuff
in it), embedded into whatever data that callback wants to deal with;
eventually, we'll be passing it to ->readdir() replacement instead of
(data,filldir) pair.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 83a87611
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -445,3 +445,6 @@ object doesn't exist. It's remote/distributed ones that might care...
[mandatory]
	FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
in your dentry operations instead.
--
[mandatory]
	vfs_readdir() is gone; switch to iterate_dir() instead
+3 −1
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ struct osf_dirent {
};

struct osf_dirent_callback {
	struct dir_context ctx;
	struct osf_dirent __user *dirent;
	long __user *basep;
	unsigned int count;
@@ -155,8 +156,9 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
	buf.basep = basep;
	buf.count = count;
	buf.error = 0;
	buf.ctx.actor = osf_filldir;

	error = vfs_readdir(arg.file, osf_filldir, &buf);
	error = iterate_dir(arg.file, &buf.ctx);
	if (error >= 0)
		error = buf.error;
	if (count != buf.count)
+3 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ struct hpux_dirent {
};

struct getdents_callback {
	struct dir_context ctx;
	struct hpux_dirent __user *current_dir;
	struct hpux_dirent __user *previous;
	int count;
@@ -121,8 +122,9 @@ int hpux_getdents(unsigned int fd, struct hpux_dirent __user *dirent, unsigned i
	buf.previous = NULL;
	buf.count = count;
	buf.error = 0;
	buf.ctx.actor = filldir;

	error = vfs_readdir(arg.file, filldir, &buf);
	error = iterate_dir(arg.file, &buf.ctx);
	if (error >= 0)
		error = buf.error;
	lastdirent = buf.previous;
+9 −3
Original line number Diff line number Diff line
@@ -832,6 +832,7 @@ struct compat_old_linux_dirent {
};

struct compat_readdir_callback {
	struct dir_context ctx;
	struct compat_old_linux_dirent __user *dirent;
	int result;
};
@@ -880,8 +881,9 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,

	buf.result = 0;
	buf.dirent = dirent;
	buf.ctx.actor = compat_fillonedir;

	error = vfs_readdir(f.file, compat_fillonedir, &buf);
	error = iterate_dir(f.file, &buf.ctx);
	if (buf.result)
		error = buf.result;

@@ -897,6 +899,7 @@ struct compat_linux_dirent {
};

struct compat_getdents_callback {
	struct dir_context ctx;
	struct compat_linux_dirent __user *current_dir;
	struct compat_linux_dirent __user *previous;
	int count;
@@ -965,8 +968,9 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
	buf.previous = NULL;
	buf.count = count;
	buf.error = 0;
	buf.ctx.actor = compat_filldir;

	error = vfs_readdir(f.file, compat_filldir, &buf);
	error = iterate_dir(f.file, &buf.ctx);
	if (error >= 0)
		error = buf.error;
	lastdirent = buf.previous;
@@ -983,6 +987,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
#ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64

struct compat_getdents_callback64 {
	struct dir_context ctx;
	struct linux_dirent64 __user *current_dir;
	struct linux_dirent64 __user *previous;
	int count;
@@ -1050,8 +1055,9 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
	buf.previous = NULL;
	buf.count = count;
	buf.error = 0;
	buf.ctx.actor = compat_filldir64;

	error = vfs_readdir(f.file, compat_filldir64, &buf);
	error = iterate_dir(f.file, &buf.ctx);
	if (error >= 0)
		error = buf.error;
	lastdirent = buf.previous;
+3 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb,
}

struct ecryptfs_getdents_callback {
	struct dir_context ctx;
	void *dirent;
	struct dentry *dentry;
	filldir_t filldir;
@@ -126,7 +127,8 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
	buf.filldir = filldir;
	buf.filldir_called = 0;
	buf.entries_written = 0;
	rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf);
	buf.ctx.actor = ecryptfs_filldir;
	rc = iterate_dir(lower_file, &buf.ctx);
	file->f_pos = lower_file->f_pos;
	if (rc < 0)
		goto out;
Loading