[readdir] convert reiserfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
956ce2083c
commit
4acf381e1b
3 changed files with 19 additions and 23 deletions
|
@ -13,14 +13,14 @@
|
||||||
|
|
||||||
extern const struct reiserfs_key MIN_KEY;
|
extern const struct reiserfs_key MIN_KEY;
|
||||||
|
|
||||||
static int reiserfs_readdir(struct file *, void *, filldir_t);
|
static int reiserfs_readdir(struct file *, struct dir_context *);
|
||||||
static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
|
static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
|
||||||
int datasync);
|
int datasync);
|
||||||
|
|
||||||
const struct file_operations reiserfs_dir_operations = {
|
const struct file_operations reiserfs_dir_operations = {
|
||||||
.llseek = generic_file_llseek,
|
.llseek = generic_file_llseek,
|
||||||
.read = generic_read_dir,
|
.read = generic_read_dir,
|
||||||
.readdir = reiserfs_readdir,
|
.iterate = reiserfs_readdir,
|
||||||
.fsync = reiserfs_dir_fsync,
|
.fsync = reiserfs_dir_fsync,
|
||||||
.unlocked_ioctl = reiserfs_ioctl,
|
.unlocked_ioctl = reiserfs_ioctl,
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
|
@ -58,8 +58,7 @@ static inline bool is_privroot_deh(struct dentry *dir,
|
||||||
deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
|
deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
int reiserfs_readdir_dentry(struct dentry *dentry, struct dir_context *ctx)
|
||||||
filldir_t filldir, loff_t *pos)
|
|
||||||
{
|
{
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
|
struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
|
||||||
|
@ -81,7 +80,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
||||||
|
|
||||||
/* form key for search the next directory entry using f_pos field of
|
/* form key for search the next directory entry using f_pos field of
|
||||||
file structure */
|
file structure */
|
||||||
make_cpu_key(&pos_key, inode, *pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3);
|
make_cpu_key(&pos_key, inode, ctx->pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3);
|
||||||
next_pos = cpu_key_k_offset(&pos_key);
|
next_pos = cpu_key_k_offset(&pos_key);
|
||||||
|
|
||||||
path_to_entry.reada = PATH_READA;
|
path_to_entry.reada = PATH_READA;
|
||||||
|
@ -126,7 +125,6 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
||||||
entry_num++, deh++) {
|
entry_num++, deh++) {
|
||||||
int d_reclen;
|
int d_reclen;
|
||||||
char *d_name;
|
char *d_name;
|
||||||
off_t d_off;
|
|
||||||
ino_t d_ino;
|
ino_t d_ino;
|
||||||
|
|
||||||
if (!de_visible(deh))
|
if (!de_visible(deh))
|
||||||
|
@ -158,8 +156,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
||||||
if (is_privroot_deh(dentry, deh))
|
if (is_privroot_deh(dentry, deh))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
d_off = deh_offset(deh);
|
ctx->pos = deh_offset(deh);
|
||||||
*pos = d_off;
|
|
||||||
d_ino = deh_objectid(deh);
|
d_ino = deh_objectid(deh);
|
||||||
if (d_reclen <= 32) {
|
if (d_reclen <= 32) {
|
||||||
local_buf = small_buf;
|
local_buf = small_buf;
|
||||||
|
@ -187,9 +184,9 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
||||||
* the write lock here for other waiters
|
* the write lock here for other waiters
|
||||||
*/
|
*/
|
||||||
reiserfs_write_unlock(inode->i_sb);
|
reiserfs_write_unlock(inode->i_sb);
|
||||||
if (filldir
|
if (!dir_emit
|
||||||
(dirent, local_buf, d_reclen, d_off, d_ino,
|
(ctx, local_buf, d_reclen, d_ino,
|
||||||
DT_UNKNOWN) < 0) {
|
DT_UNKNOWN)) {
|
||||||
reiserfs_write_lock(inode->i_sb);
|
reiserfs_write_lock(inode->i_sb);
|
||||||
if (local_buf != small_buf) {
|
if (local_buf != small_buf) {
|
||||||
kfree(local_buf);
|
kfree(local_buf);
|
||||||
|
@ -237,7 +234,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
end:
|
end:
|
||||||
*pos = next_pos;
|
ctx->pos = next_pos;
|
||||||
pathrelse(&path_to_entry);
|
pathrelse(&path_to_entry);
|
||||||
reiserfs_check_path(&path_to_entry);
|
reiserfs_check_path(&path_to_entry);
|
||||||
out:
|
out:
|
||||||
|
@ -245,10 +242,9 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reiserfs_readdir(struct file *file, void *dirent, filldir_t filldir)
|
static int reiserfs_readdir(struct file *file, struct dir_context *ctx)
|
||||||
{
|
{
|
||||||
struct dentry *dentry = file->f_path.dentry;
|
return reiserfs_readdir_dentry(file->f_path.dentry, ctx);
|
||||||
return reiserfs_readdir_dentry(dentry, dirent, filldir, &file->f_pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compose directory item containing "." and ".." entries (entries are
|
/* compose directory item containing "." and ".." entries (entries are
|
||||||
|
|
|
@ -2709,7 +2709,7 @@ extern const struct inode_operations reiserfs_dir_inode_operations;
|
||||||
extern const struct inode_operations reiserfs_symlink_inode_operations;
|
extern const struct inode_operations reiserfs_symlink_inode_operations;
|
||||||
extern const struct inode_operations reiserfs_special_inode_operations;
|
extern const struct inode_operations reiserfs_special_inode_operations;
|
||||||
extern const struct file_operations reiserfs_dir_operations;
|
extern const struct file_operations reiserfs_dir_operations;
|
||||||
int reiserfs_readdir_dentry(struct dentry *, void *, filldir_t, loff_t *);
|
int reiserfs_readdir_dentry(struct dentry *, struct dir_context *);
|
||||||
|
|
||||||
/* tail_conversion.c */
|
/* tail_conversion.c */
|
||||||
int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
|
int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
|
||||||
|
|
|
@ -171,6 +171,7 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
|
||||||
* modifying extended attributes. This includes operations such as permissions
|
* modifying extended attributes. This includes operations such as permissions
|
||||||
* or ownership changes, object deletions, etc. */
|
* or ownership changes, object deletions, etc. */
|
||||||
struct reiserfs_dentry_buf {
|
struct reiserfs_dentry_buf {
|
||||||
|
struct dir_context ctx;
|
||||||
struct dentry *xadir;
|
struct dentry *xadir;
|
||||||
int count;
|
int count;
|
||||||
struct dentry *dentries[8];
|
struct dentry *dentries[8];
|
||||||
|
@ -223,9 +224,8 @@ static int reiserfs_for_each_xattr(struct inode *inode,
|
||||||
{
|
{
|
||||||
struct dentry *dir;
|
struct dentry *dir;
|
||||||
int i, err = 0;
|
int i, err = 0;
|
||||||
loff_t pos = 0;
|
|
||||||
struct reiserfs_dentry_buf buf = {
|
struct reiserfs_dentry_buf buf = {
|
||||||
.count = 0,
|
.ctx.actor = fill_with_dentries,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Skip out, an xattr has no xattrs associated with it */
|
/* Skip out, an xattr has no xattrs associated with it */
|
||||||
|
@ -249,7 +249,7 @@ static int reiserfs_for_each_xattr(struct inode *inode,
|
||||||
reiserfs_write_lock(inode->i_sb);
|
reiserfs_write_lock(inode->i_sb);
|
||||||
|
|
||||||
buf.xadir = dir;
|
buf.xadir = dir;
|
||||||
err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos);
|
err = reiserfs_readdir_dentry(dir, &buf.ctx);
|
||||||
while ((err == 0 || err == -ENOSPC) && buf.count) {
|
while ((err == 0 || err == -ENOSPC) && buf.count) {
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
|
@ -266,8 +266,7 @@ static int reiserfs_for_each_xattr(struct inode *inode,
|
||||||
}
|
}
|
||||||
buf.count = 0;
|
buf.count = 0;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reiserfs_readdir_dentry(dir, &buf,
|
err = reiserfs_readdir_dentry(dir, &buf.ctx);
|
||||||
fill_with_dentries, &pos);
|
|
||||||
}
|
}
|
||||||
mutex_unlock(&dir->d_inode->i_mutex);
|
mutex_unlock(&dir->d_inode->i_mutex);
|
||||||
|
|
||||||
|
@ -800,6 +799,7 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct listxattr_buf {
|
struct listxattr_buf {
|
||||||
|
struct dir_context ctx;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -845,8 +845,8 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
struct dentry *dir;
|
struct dentry *dir;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
loff_t pos = 0;
|
|
||||||
struct listxattr_buf buf = {
|
struct listxattr_buf buf = {
|
||||||
|
.ctx.actor = listxattr_filler,
|
||||||
.dentry = dentry,
|
.dentry = dentry,
|
||||||
.buf = buffer,
|
.buf = buffer,
|
||||||
.size = buffer ? size : 0,
|
.size = buffer ? size : 0,
|
||||||
|
@ -868,7 +868,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
|
mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
|
||||||
err = reiserfs_readdir_dentry(dir, &buf, listxattr_filler, &pos);
|
err = reiserfs_readdir_dentry(dir, &buf.ctx);
|
||||||
mutex_unlock(&dir->d_inode->i_mutex);
|
mutex_unlock(&dir->d_inode->i_mutex);
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue