From 6d903b914cda5d42950e0c7b3d0c8030fb5b5db6 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Mon, 12 May 2014 14:58:20 +0200 Subject: [PATCH] Message type for VFS_FCNTL Change-Id: I079f3d7902cf5501fbc594a5610acd370abea095 --- include/minix/callnr.h | 6 ------ include/minix/ipc.h | 11 +++++++++++ lib/libc/sys-minix/fcntl.c | 8 ++++---- servers/vfs/lock.c | 4 ++-- servers/vfs/main.c | 8 ++++---- servers/vfs/misc.c | 14 ++++++++------ 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 4501b012a..1b1ec4b61 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -232,12 +232,6 @@ #define NR_VFS_CALLS 49 /* highest number from base plus one */ -/* Field names for the fcntl(2) call. */ -#define VFS_FCNTL_FD m1_i1 /* int */ -#define VFS_FCNTL_CMD m1_i2 /* int */ -#define VFS_FCNTL_ARG_INT m1_i3 /* int */ -#define VFS_FCNTL_ARG_PTR m1_p1 /* struct flock * */ - /* Field names for the mknod(2) call. */ #define VFS_MKNOD_NAME m1_p1 /* const char * */ #define VFS_MKNOD_LEN m1_i1 /* size_t */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 5721a6337..bfb2c0ef4 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -146,6 +146,16 @@ typedef struct { } mess_sigcalls; _ASSERT_MSG_SIZE(mess_sigcalls); +typedef struct { + int fd; + int cmd; + int arg_int; + vir_bytes arg_ptr; /* struct flock * */ + + uint8_t padding[40]; +} mess_lc_vfs_fcntl; +_ASSERT_MSG_SIZE(mess_lc_vfs_fcntl); + typedef struct { int fd; vir_bytes buf; /* struct stat * */ @@ -777,6 +787,7 @@ typedef struct { mess_fs_vfs_readsuper m_fs_vfs_readsuper; mess_fs_vfs_readwrite m_fs_vfs_readwrite; + mess_lc_vfs_fcntl m_lc_vfs_fcntl; mess_lc_vfs_fstat m_lc_vfs_fstat; mess_lc_vfs_fsync m_lc_vfs_fsync; mess_lc_vfs_getvfsstat m_lc_vfs_getvfsstat; diff --git a/lib/libc/sys-minix/fcntl.c b/lib/libc/sys-minix/fcntl.c index 514dfe007..496dd9a5b 100644 --- a/lib/libc/sys-minix/fcntl.c +++ b/lib/libc/sys-minix/fcntl.c @@ -23,19 +23,19 @@ int fcntl(int fd, int cmd, ...) case F_DUPFD: case F_SETFD: case F_SETFL: - m.VFS_FCNTL_ARG_INT = va_arg(argp, int); + m.m_lc_vfs_fcntl.arg_int = va_arg(argp, int); break; case F_GETLK: case F_SETLK: case F_SETLKW: case F_FREESP: - m.VFS_FCNTL_ARG_PTR = (char *) va_arg(argp, struct flock *); + m.m_lc_vfs_fcntl.arg_ptr = va_arg(argp, struct flock *); break; } /* Clean up and make the system call. */ va_end(argp); - m.VFS_FCNTL_FD = fd; - m.VFS_FCNTL_CMD = cmd; + m.m_lc_vfs_fcntl.fd = fd; + m.m_lc_vfs_fcntl.cmd = cmd; return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m)); } diff --git a/servers/vfs/lock.c b/servers/vfs/lock.c index e9c63fcdd..197d5d0c4 100644 --- a/servers/vfs/lock.c +++ b/servers/vfs/lock.c @@ -31,7 +31,7 @@ int req; /* either F_SETLK or F_SETLKW */ struct file_lock *flp, *flp2, *empty; /* Fetch the flock structure from user space. */ - r = sys_datacopy_wrapper(who_e, (vir_bytes) scratch(fp).io.io_buffer, VFS_PROC_NR, + r = sys_datacopy_wrapper(who_e, (vir_bytes)scratch(fp).io.io_buffer, VFS_PROC_NR, (vir_bytes) &flock, sizeof(flock)); if (r != OK) return(EINVAL); @@ -142,7 +142,7 @@ int req; /* either F_SETLK or F_SETLKW */ /* Copy the flock structure back to the caller. */ r = sys_datacopy_wrapper(VFS_PROC_NR, (vir_bytes) &flock, who_e, - (vir_bytes) scratch(fp).io.io_buffer, sizeof(flock)); + (vir_bytes)scratch(fp).io.io_buffer, sizeof(flock)); return(r); } diff --git a/servers/vfs/main.c b/servers/vfs/main.c index e781a4997..70877605b 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -828,10 +828,10 @@ struct fproc *rfp; break; case VFS_FCNTL: assert(blocked_on == FP_BLOCKED_ON_LOCK); - m_in.VFS_FCNTL_FD = scratch(rfp).file.fd_nr; - m_in.VFS_FCNTL_CMD = scratch(rfp).io.io_nbytes; - m_in.VFS_FCNTL_ARG_PTR = scratch(rfp).io.io_buffer; - assert(m_in.VFS_FCNTL_CMD == F_SETLKW); + m_in.m_lc_vfs_fcntl.fd = scratch(rfp).file.fd_nr; + m_in.m_lc_vfs_fcntl.cmd = scratch(rfp).io.io_nbytes; + m_in.m_lc_vfs_fcntl.arg_ptr = (vir_bytes)scratch(rfp).io.io_buffer; + assert(m_in.m_lc_vfs_fcntl.cmd == F_SETLKW); break; default: panic("unblocking call %d blocked on %d ??", m_in.m_type, blocked_on); diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 0775a4b4e..d41d54786 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -103,11 +103,13 @@ int do_fcntl(void) int new_fd, fl, r = OK, fcntl_req, fcntl_argx; tll_access_t locktype; - scratch(fp).file.fd_nr = job_m_in.VFS_FCNTL_FD; - scratch(fp).io.io_buffer = job_m_in.VFS_FCNTL_ARG_PTR; - scratch(fp).io.io_nbytes = job_m_in.VFS_FCNTL_CMD; - fcntl_req = job_m_in.VFS_FCNTL_CMD; - fcntl_argx = job_m_in.VFS_FCNTL_ARG_INT; + scratch(fp).file.fd_nr = job_m_in.m_lc_vfs_fcntl.fd; + /* LSC: io_buffer is used everywhere as a valid VFS memory space pointer. + * Seems downright scary to me. */ + scratch(fp).io.io_buffer = (char *)job_m_in.m_lc_vfs_fcntl.arg_ptr; + scratch(fp).io.io_nbytes = job_m_in.m_lc_vfs_fcntl.cmd; + fcntl_req = job_m_in.m_lc_vfs_fcntl.cmd; + fcntl_argx = job_m_in.m_lc_vfs_fcntl.arg_int; /* Is the file descriptor valid? */ locktype = (fcntl_req == F_FREESP) ? VNODE_WRITE : VNODE_READ; @@ -170,7 +172,7 @@ int do_fcntl(void) else if (!(f->filp_mode & W_BIT)) r = EBADF; else { /* Copy flock data from userspace. */ - r = sys_datacopy_wrapper(who_e, (vir_bytes) scratch(fp).io.io_buffer, + r = sys_datacopy_wrapper(who_e, (vir_bytes)scratch(fp).io.io_buffer, SELF, (vir_bytes) &flock_arg, sizeof(flock_arg)); } -- 2.44.0