fs: ecryptfs: readdir: constify actor
[firefly-linux-kernel-4.4.55.git] / fs / ecryptfs / file.c
index 201f0a0d6b0a2a2be8a2983d2fb63ef27dacc0d8..faa26beb1e4e52b99e2bdaccdd99a59f24e064b0 100644 (file)
@@ -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;
@@ -115,18 +116,19 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
        int rc;
        struct file *lower_file;
        struct inode *inode;
-       struct ecryptfs_getdents_callback buf;
+       struct ecryptfs_getdents_callback buf = {
+               .dirent = dirent,
+               .dentry = file->f_path.dentry,
+               .filldir = filldir,
+               .filldir_called = 0,
+               .entries_written = 0,
+               .ctx.actor = ecryptfs_filldir
+       };
 
        lower_file = ecryptfs_file_to_lower(file);
        lower_file->f_pos = file->f_pos;
        inode = file_inode(file);
-       memset(&buf, 0, sizeof(buf));
-       buf.dirent = dirent;
-       buf.dentry = file->f_path.dentry;
-       buf.filldir = filldir;
-       buf.filldir_called = 0;
-       buf.entries_written = 0;
-       rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf);
+       rc = iterate_dir(lower_file, &buf.ctx);
        file->f_pos = lower_file->f_pos;
        if (rc < 0)
                goto out;
@@ -295,6 +297,12 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
 static int
 ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 {
+       int rc;
+
+       rc = filemap_write_and_wait(file->f_mapping);
+       if (rc)
+               return rc;
+
        return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
 }