projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ext4: don't save the error information if the block device is read-only
[firefly-linux-kernel-4.4.55.git]
/
fs
/
readdir.c
diff --git
a/fs/readdir.c
b/fs/readdir.c
index fee38e04fae4ab09440c05808e539f72133c6976..d46eca8567a413a8f081b4c8a5272a60a2039437 100644
(file)
--- a/
fs/readdir.c
+++ b/
fs/readdir.c
@@
-20,11
+20,11
@@
#include <asm/uaccess.h>
#include <asm/uaccess.h>
-int
vfs_readdir(struct file *file, filldir_t filler, void *buf
)
+int
iterate_dir(struct file *file, struct dir_context *ctx
)
{
struct inode *inode = file_inode(file);
int res = -ENOTDIR;
{
struct inode *inode = file_inode(file);
int res = -ENOTDIR;
- if (!file->f_op ||
!file->f_op->readdir
)
+ if (!file->f_op ||
(!file->f_op->readdir && !file->f_op->iterate)
)
goto out;
res = security_file_permission(file, MAY_READ);
goto out;
res = security_file_permission(file, MAY_READ);
@@
-37,15
+37,21
@@
int vfs_readdir(struct file *file, filldir_t filler, void *buf)
res = -ENOENT;
if (!IS_DEADDIR(inode)) {
res = -ENOENT;
if (!IS_DEADDIR(inode)) {
- res = file->f_op->readdir(file, buf, filler);
+ if (file->f_op->iterate) {
+ ctx->pos = file->f_pos;
+ res = file->f_op->iterate(file, ctx);
+ file->f_pos = ctx->pos;
+ } else {
+ res = file->f_op->readdir(file, ctx, ctx->actor);
+ ctx->pos = file->f_pos;
+ }
file_accessed(file);
}
mutex_unlock(&inode->i_mutex);
out:
return res;
}
file_accessed(file);
}
mutex_unlock(&inode->i_mutex);
out:
return res;
}
-
-EXPORT_SYMBOL(vfs_readdir);
+EXPORT_SYMBOL(iterate_dir);
/*
* Traditional linux readdir() handling..
/*
* Traditional linux readdir() handling..
@@
-66,6
+72,7
@@
struct old_linux_dirent {
};
struct readdir_callback {
};
struct readdir_callback {
+ struct dir_context ctx;
struct old_linux_dirent __user * dirent;
int result;
};
struct old_linux_dirent __user * dirent;
int result;
};
@@
-73,7
+80,7
@@
struct readdir_callback {
static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
u64 ino, unsigned int d_type)
{
static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
u64 ino, unsigned int d_type)
{
- struct readdir_callback *
buf = (struct readdir_callback *) __buf;
+ struct readdir_callback *buf = (struct readdir_callback *) __buf;
struct old_linux_dirent __user * dirent;
unsigned long d_ino;
struct old_linux_dirent __user * dirent;
unsigned long d_ino;
@@
-107,15
+114,15
@@
SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
{
int error;
struct fd f = fdget(fd);
{
int error;
struct fd f = fdget(fd);
- struct readdir_callback buf;
+ struct readdir_callback buf = {
+ .ctx.actor = fillonedir,
+ .dirent = dirent
+ };
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.result = 0;
- buf.dirent = dirent;
-
- error = vfs_readdir(f.file, fillonedir, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (buf.result)
error = buf.result;
if (buf.result)
error = buf.result;
@@
-137,6
+144,7
@@
struct linux_dirent {
};
struct getdents_callback {
};
struct getdents_callback {
+ struct dir_context ctx;
struct linux_dirent __user * current_dir;
struct linux_dirent __user * previous;
int count;
struct linux_dirent __user * current_dir;
struct linux_dirent __user * previous;
int count;
@@
-191,7
+199,11
@@
SYSCALL_DEFINE3(getdents, unsigned int, fd,
{
struct fd f;
struct linux_dirent __user * lastdirent;
{
struct fd f;
struct linux_dirent __user * lastdirent;
- struct getdents_callback buf;
+ struct getdents_callback buf = {
+ .ctx.actor = filldir,
+ .count = count,
+ .current_dir = dirent
+ };
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
@@
-201,17
+213,12
@@
SYSCALL_DEFINE3(getdents, unsigned int, fd,
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.current_dir = dirent;
- buf.previous = NULL;
- buf.count = count;
- buf.error = 0;
-
- error = vfs_readdir(f.file, filldir, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
- if (put_user(
f.file->f_
pos, &lastdirent->d_off))
+ if (put_user(
buf.ctx.
pos, &lastdirent->d_off))
error = -EFAULT;
else
error = count - buf.count;
error = -EFAULT;
else
error = count - buf.count;
@@
-221,6
+228,7
@@
SYSCALL_DEFINE3(getdents, unsigned int, fd,
}
struct getdents_callback64 {
}
struct getdents_callback64 {
+ struct dir_context ctx;
struct linux_dirent64 __user * current_dir;
struct linux_dirent64 __user * previous;
int count;
struct linux_dirent64 __user * current_dir;
struct linux_dirent64 __user * previous;
int count;
@@
-271,7
+279,11
@@
SYSCALL_DEFINE3(getdents64, unsigned int, fd,
{
struct fd f;
struct linux_dirent64 __user * lastdirent;
{
struct fd f;
struct linux_dirent64 __user * lastdirent;
- struct getdents_callback64 buf;
+ struct getdents_callback64 buf = {
+ .ctx.actor = filldir64,
+ .count = count,
+ .current_dir = dirent
+ };
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
int error;
if (!access_ok(VERIFY_WRITE, dirent, count))
@@
-281,17
+293,12
@@
SYSCALL_DEFINE3(getdents64, unsigned int, fd,
if (!f.file)
return -EBADF;
if (!f.file)
return -EBADF;
- buf.current_dir = dirent;
- buf.previous = NULL;
- buf.count = count;
- buf.error = 0;
-
- error = vfs_readdir(f.file, filldir64, &buf);
+ error = iterate_dir(f.file, &buf.ctx);
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
if (error >= 0)
error = buf.error;
lastdirent = buf.previous;
if (lastdirent) {
- typeof(lastdirent->d_off) d_off =
f.file->f_
pos;
+ typeof(lastdirent->d_off) d_off =
buf.ctx.
pos;
if (__put_user(d_off, &lastdirent->d_off))
error = -EFAULT;
else
if (__put_user(d_off, &lastdirent->d_off))
error = -EFAULT;
else