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

Commit 765927b2 authored by Al Viro's avatar Al Viro
Browse files

switch dentry_open() to struct path, make it grab references itself



Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent bf349a44
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
	return ret;
}

static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt)
static int spufs_context_open(struct path *path)
{
	int ret;
	struct file *filp;
@@ -326,11 +326,7 @@ static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt)
	if (ret < 0)
		return ret;

	/*
	 * get references for dget and mntget, will be released
	 * in error path of *_open().
	 */
	filp = dentry_open(dget(dentry), mntget(mnt), O_RDONLY, current_cred());
	filp = dentry_open(path, O_RDONLY, current_cred());
	if (IS_ERR(filp)) {
		put_unused_fd(ret);
		return PTR_ERR(filp);
@@ -452,6 +448,7 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
	int affinity;
	struct spu_gang *gang;
	struct spu_context *neighbor;
	struct path path = {.mnt = mnt, .dentry = dentry};

	ret = -EPERM;
	if ((flags & SPU_CREATE_NOSCHED) &&
@@ -494,7 +491,7 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
			put_spu_context(neighbor);
	}

	ret = spufs_context_open(dentry, mnt);
	ret = spufs_context_open(&path);
	if (ret < 0) {
		WARN_ON(spufs_rmdir(inode, dentry));
		if (affinity)
@@ -551,7 +548,7 @@ spufs_mkgang(struct inode *dir, struct dentry *dentry, umode_t mode)
	return ret;
}

static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt)
static int spufs_gang_open(struct path *path)
{
	int ret;
	struct file *filp;
@@ -564,7 +561,7 @@ static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt)
	 * get references for dget and mntget, will be released
	 * in error path of *_open().
	 */
	filp = dentry_open(dget(dentry), mntget(mnt), O_RDONLY, current_cred());
	filp = dentry_open(path, O_RDONLY, current_cred());
	if (IS_ERR(filp)) {
		put_unused_fd(ret);
		return PTR_ERR(filp);
@@ -579,13 +576,14 @@ static int spufs_create_gang(struct inode *inode,
			struct dentry *dentry,
			struct vfsmount *mnt, umode_t mode)
{
	struct path path = {.mnt = mnt, .dentry = dentry};
	int ret;

	ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO);
	if (ret)
		goto out;

	ret = spufs_gang_open(dentry, mnt);
	ret = spufs_gang_open(&path);
	if (ret < 0) {
		int err = simple_rmdir(inode, dentry);
		WARN_ON(err);
+2 −2
Original line number Diff line number Diff line
@@ -257,8 +257,8 @@ static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
		 * corresponding to the autofs fs we want to open.
		 */

		filp = dentry_open(path.dentry, path.mnt, O_RDONLY,
				   current_cred());
		filp = dentry_open(&path, O_RDONLY, current_cred());
		path_put(&path);
		if (IS_ERR(filp)) {
			err = PTR_ERR(filp);
			goto out;
+4 −4
Original line number Diff line number Diff line
@@ -891,6 +891,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
	struct cachefiles_cache *cache;
	mm_segment_t old_fs;
	struct file *file;
	struct path path;
	loff_t pos, eof;
	size_t len;
	void *data;
@@ -916,10 +917,9 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)

	/* write the page to the backing filesystem and let it store it in its
	 * own time */
	dget(object->backer);
	mntget(cache->mnt);
	file = dentry_open(object->backer, cache->mnt, O_RDWR,
			   cache->cache_cred);
	path.mnt = cache->mnt;
	path.dentry = object->backer;
	file = dentry_open(&path, O_RDWR, cache->cache_cred);
	if (IS_ERR(file)) {
		ret = PTR_ERR(file);
	} else {
+8 −13
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@

struct ecryptfs_open_req {
	struct file **lower_file;
	struct dentry *lower_dentry;
	struct vfsmount *lower_mnt;
	struct path path;
	struct completion done;
	struct list_head kthread_ctl_list;
};
@@ -74,10 +73,7 @@ static int ecryptfs_threadfn(void *ignored)
					       struct ecryptfs_open_req,
					       kthread_ctl_list);
			list_del(&req->kthread_ctl_list);
			dget(req->lower_dentry);
			mntget(req->lower_mnt);
			(*req->lower_file) = dentry_open(
				req->lower_dentry, req->lower_mnt,
			*req->lower_file = dentry_open(&req->path,
				(O_RDWR | O_LARGEFILE), current_cred());
			complete(&req->done);
		}
@@ -140,23 +136,22 @@ int ecryptfs_privileged_open(struct file **lower_file,
	int flags = O_LARGEFILE;
	int rc = 0;

	init_completion(&req.done);
	req.lower_file = lower_file;
	req.path.dentry = lower_dentry;
	req.path.mnt = lower_mnt;

	/* Corresponding dput() and mntput() are done when the
	 * lower file is fput() when all eCryptfs files for the inode are
	 * released. */
	dget(lower_dentry);
	mntget(lower_mnt);
	flags |= IS_RDONLY(lower_dentry->d_inode) ? O_RDONLY : O_RDWR;
	(*lower_file) = dentry_open(lower_dentry, lower_mnt, flags, cred);
	(*lower_file) = dentry_open(&req.path, flags, cred);
	if (!IS_ERR(*lower_file))
		goto out;
	if ((flags & O_ACCMODE) == O_RDONLY) {
		rc = PTR_ERR((*lower_file));
		goto out;
	}
	init_completion(&req.done);
	req.lower_file = lower_file;
	req.lower_dentry = lower_dentry;
	req.lower_mnt = lower_mnt;
	mutex_lock(&ecryptfs_kthread_ctl.mux);
	if (ecryptfs_kthread_ctl.flags & ECRYPTFS_KTHREAD_ZOMBIE) {
		rc = -EIO;
+6 −7
Original line number Diff line number Diff line
@@ -19,19 +19,19 @@
#define dprintk(fmt, args...) do{}while(0)


static int get_name(struct vfsmount *mnt, struct dentry *dentry, char *name,
		struct dentry *child);
static int get_name(const struct path *path, char *name, struct dentry *child);


static int exportfs_get_name(struct vfsmount *mnt, struct dentry *dir,
		char *name, struct dentry *child)
{
	const struct export_operations *nop = dir->d_sb->s_export_op;
	struct path path = {.mnt = mnt, .dentry = dir};

	if (nop->get_name)
		return nop->get_name(dir, name, child);
	else
		return get_name(mnt, dir, name, child);
		return get_name(&path, name, child);
}

/*
@@ -249,11 +249,10 @@ static int filldir_one(void * __buf, const char * name, int len,
 * calls readdir on the parent until it finds an entry with
 * the same inode number as the child, and returns that.
 */
static int get_name(struct vfsmount *mnt, struct dentry *dentry,
		char *name, struct dentry *child)
static int get_name(const struct path *path, char *name, struct dentry *child)
{
	const struct cred *cred = current_cred();
	struct inode *dir = dentry->d_inode;
	struct inode *dir = path->dentry->d_inode;
	int error;
	struct file *file;
	struct getdents_callback buffer;
@@ -267,7 +266,7 @@ static int get_name(struct vfsmount *mnt, struct dentry *dentry,
	/*
	 * Open the directory ...
	 */
	file = dentry_open(dget(dentry), mntget(mnt), O_RDONLY, cred);
	file = dentry_open(path, O_RDONLY, cred);
	error = PTR_ERR(file);
	if (IS_ERR(file))
		goto out;
Loading