Unverified Commit f9835fa1 authored by Al Viro's avatar Al Viro Committed by Christian Brauner
Browse files

make use of anon_inode_getfile_fmode()



["fallen through the cracks" misc stuff]

A bunch of anon_inode_getfile() callers follow it with adjusting
->f_mode; we have a helper doing that now, so let's make use
of it.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250118014434.GT1977892@ZenIV


Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 822c1159
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -482,14 +482,13 @@ static long papr_vpd_create_handle(struct papr_location_code __user *ulc)
		goto free_blob;
	}

	file = anon_inode_getfile("[papr-vpd]", &papr_vpd_handle_ops,
				  (void *)blob, O_RDONLY);
	file = anon_inode_getfile_fmode("[papr-vpd]", &papr_vpd_handle_ops,
				  (void *)blob, O_RDONLY,
				  FMODE_LSEEK | FMODE_PREAD);
	if (IS_ERR(file)) {
		err = PTR_ERR(file);
		goto put_fd;
	}

	file->f_mode |= FMODE_LSEEK | FMODE_PREAD;
	fd_install(fd, file);
	return fd;
put_fd:
+2 −14
Original line number Diff line number Diff line
@@ -266,24 +266,12 @@ static struct file *vfio_device_open_file(struct vfio_device *device)
	if (ret)
		goto err_free;

	/*
	 * We can't use anon_inode_getfd() because we need to modify
	 * the f_mode flags directly to allow more than just ioctls
	 */
	filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
				   df, O_RDWR);
	filep = anon_inode_getfile_fmode("[vfio-device]", &vfio_device_fops,
				   df, O_RDWR, FMODE_PREAD | FMODE_PWRITE);
	if (IS_ERR(filep)) {
		ret = PTR_ERR(filep);
		goto err_close_device;
	}

	/*
	 * TODO: add an anon_inode interface to do this.
	 * Appears to be missing by lack of need rather than
	 * explicitly prevented.  Now there's need.
	 */
	filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);

	/*
	 * Use the pseudo fs inode on the device to link all mmaps
	 * to the same address space, allowing us to unmap all vmas
+3 −4
Original line number Diff line number Diff line
@@ -317,8 +317,9 @@ static int cachefiles_ondemand_get_fd(struct cachefiles_req *req,
		goto err_free_id;
	}

	anon_file->file = anon_inode_getfile("[cachefiles]",
				&cachefiles_ondemand_fd_fops, object, O_WRONLY);
	anon_file->file = anon_inode_getfile_fmode("[cachefiles]",
				&cachefiles_ondemand_fd_fops, object,
				O_WRONLY, FMODE_PWRITE | FMODE_LSEEK);
	if (IS_ERR(anon_file->file)) {
		ret = PTR_ERR(anon_file->file);
		goto err_put_fd;
@@ -333,8 +334,6 @@ static int cachefiles_ondemand_get_fd(struct cachefiles_req *req,
		goto err_put_file;
	}

	anon_file->file->f_mode |= FMODE_PWRITE | FMODE_LSEEK;

	load = (void *)req->msg.data;
	load->fd = anon_file->fd;
	object->ondemand->ondemand_id = object_id;
+2 −3
Original line number Diff line number Diff line
@@ -406,14 +406,13 @@ static int do_eventfd(unsigned int count, int flags)
	if (fd < 0)
		goto err;

	file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, flags);
	file = anon_inode_getfile_fmode("[eventfd]", &eventfd_fops,
					ctx, flags, FMODE_NOWAIT);
	if (IS_ERR(file)) {
		put_unused_fd(fd);
		fd = PTR_ERR(file);
		goto err;
	}

	file->f_mode |= FMODE_NOWAIT;
	fd_install(fd, file);
	return fd;
err:
+3 −4
Original line number Diff line number Diff line
@@ -277,15 +277,14 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags)
			return ufd;
		}

		file = anon_inode_getfile("[signalfd]", &signalfd_fops, ctx,
				       O_RDWR | (flags & O_NONBLOCK));
		file = anon_inode_getfile_fmode("[signalfd]", &signalfd_fops,
					ctx, O_RDWR | (flags & O_NONBLOCK),
					FMODE_NOWAIT);
		if (IS_ERR(file)) {
			put_unused_fd(ufd);
			kfree(ctx);
			return PTR_ERR(file);
		}
		file->f_mode |= FMODE_NOWAIT;

		fd_install(ufd, file);
	} else {
		CLASS(fd, f)(ufd);
Loading