From 4cd91e9d81f8eee5a5ab7b6250d49c03383d1b96 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 12 Sep 2014 21:29:10 +0000 Subject: Fix various issues with invalid file operations: - Add invfo_rdwr() (for read and write), invfo_ioctl(), invfo_poll(), and invfo_kqfilter() for use by file types that do not support the respective operations. Home-grown versions of invfo_poll() were universally broken (they returned an errno value, invfo_poll() uses poll_no_poll() to return an appropriate event mask). Home-grown ioctl routines also tended to return an incorrect errno (invfo_ioctl returns ENOTTY). - Use the invfo_*() functions instead of local versions for unsupported file operations. - Reorder fileops members to match the order in the structure definition to make it easier to spot missing members. - Add several missing methods to linuxfileops used by the OFED shim layer: fo_write(), fo_truncate(), fo_kqfilter(), and fo_stat(). Most of these used invfo_*(), but a dummy fo_stat() implementation was added. --- sys/kern/sys_procdesc.c | 65 +++++-------------------------------------------- 1 file changed, 6 insertions(+), 59 deletions(-) (limited to 'sys/kern/sys_procdesc.c') diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 1039dac..9bdca9a 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -87,28 +87,22 @@ FEATURE(process_descriptors, "Process Descriptors"); static uma_zone_t procdesc_zone; -static fo_rdwr_t procdesc_read; -static fo_rdwr_t procdesc_write; -static fo_truncate_t procdesc_truncate; -static fo_ioctl_t procdesc_ioctl; static fo_poll_t procdesc_poll; static fo_kqfilter_t procdesc_kqfilter; static fo_stat_t procdesc_stat; static fo_close_t procdesc_close; -static fo_chmod_t procdesc_chmod; -static fo_chown_t procdesc_chown; static struct fileops procdesc_ops = { - .fo_read = procdesc_read, - .fo_write = procdesc_write, - .fo_truncate = procdesc_truncate, - .fo_ioctl = procdesc_ioctl, + .fo_read = invfo_rdwr, + .fo_write = invfo_rdwr, + .fo_truncate = invfo_truncate, + .fo_ioctl = invfo_ioctl, .fo_poll = procdesc_poll, .fo_kqfilter = procdesc_kqfilter, .fo_stat = procdesc_stat, .fo_close = procdesc_close, - .fo_chmod = procdesc_chmod, - .fo_chown = procdesc_chown, + .fo_chmod = invfo_chmod, + .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, .fo_flags = DFLAG_PASSABLE, }; @@ -413,38 +407,6 @@ procdesc_close(struct file *fp, struct thread *td) } static int -procdesc_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_ioctl(struct file *fp, u_long com, void *data, - struct ucred *active_cred, struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int procdesc_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td) { @@ -569,18 +531,3 @@ procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, return (0); } -static int -procdesc_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} - -static int -procdesc_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, - struct thread *td) -{ - - return (EOPNOTSUPP); -} -- cgit v1.1