Message type for VFS_FCNTL

Change-Id: I079f3d7902cf5501fbc594a5610acd370abea095
This commit is contained in:
Lionel Sambuc 2014-05-12 14:58:20 +02:00
parent bb2b07940c
commit 6d903b914c
6 changed files with 29 additions and 22 deletions

View file

@ -232,12 +232,6 @@
#define NR_VFS_CALLS 49 /* highest number from base plus one */ #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. */ /* Field names for the mknod(2) call. */
#define VFS_MKNOD_NAME m1_p1 /* const char * */ #define VFS_MKNOD_NAME m1_p1 /* const char * */
#define VFS_MKNOD_LEN m1_i1 /* size_t */ #define VFS_MKNOD_LEN m1_i1 /* size_t */

View file

@ -146,6 +146,16 @@ typedef struct {
} mess_sigcalls; } mess_sigcalls;
_ASSERT_MSG_SIZE(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 { typedef struct {
int fd; int fd;
vir_bytes buf; /* struct stat * */ vir_bytes buf; /* struct stat * */
@ -777,6 +787,7 @@ typedef struct {
mess_fs_vfs_readsuper m_fs_vfs_readsuper; mess_fs_vfs_readsuper m_fs_vfs_readsuper;
mess_fs_vfs_readwrite m_fs_vfs_readwrite; 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_fstat m_lc_vfs_fstat;
mess_lc_vfs_fsync m_lc_vfs_fsync; mess_lc_vfs_fsync m_lc_vfs_fsync;
mess_lc_vfs_getvfsstat m_lc_vfs_getvfsstat; mess_lc_vfs_getvfsstat m_lc_vfs_getvfsstat;

View file

@ -23,19 +23,19 @@ int fcntl(int fd, int cmd, ...)
case F_DUPFD: case F_DUPFD:
case F_SETFD: case F_SETFD:
case F_SETFL: case F_SETFL:
m.VFS_FCNTL_ARG_INT = va_arg(argp, int); m.m_lc_vfs_fcntl.arg_int = va_arg(argp, int);
break; break;
case F_GETLK: case F_GETLK:
case F_SETLK: case F_SETLK:
case F_SETLKW: case F_SETLKW:
case F_FREESP: 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; break;
} }
/* Clean up and make the system call. */ /* Clean up and make the system call. */
va_end(argp); va_end(argp);
m.VFS_FCNTL_FD = fd; m.m_lc_vfs_fcntl.fd = fd;
m.VFS_FCNTL_CMD = cmd; m.m_lc_vfs_fcntl.cmd = cmd;
return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m)); return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m));
} }

View file

@ -31,7 +31,7 @@ int req; /* either F_SETLK or F_SETLKW */
struct file_lock *flp, *flp2, *empty; struct file_lock *flp, *flp2, *empty;
/* Fetch the flock structure from user space. */ /* 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)); (vir_bytes) &flock, sizeof(flock));
if (r != OK) return(EINVAL); 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. */ /* Copy the flock structure back to the caller. */
r = sys_datacopy_wrapper(VFS_PROC_NR, (vir_bytes) &flock, who_e, 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); return(r);
} }

View file

@ -828,10 +828,10 @@ struct fproc *rfp;
break; break;
case VFS_FCNTL: case VFS_FCNTL:
assert(blocked_on == FP_BLOCKED_ON_LOCK); assert(blocked_on == FP_BLOCKED_ON_LOCK);
m_in.VFS_FCNTL_FD = scratch(rfp).file.fd_nr; m_in.m_lc_vfs_fcntl.fd = scratch(rfp).file.fd_nr;
m_in.VFS_FCNTL_CMD = scratch(rfp).io.io_nbytes; m_in.m_lc_vfs_fcntl.cmd = scratch(rfp).io.io_nbytes;
m_in.VFS_FCNTL_ARG_PTR = scratch(rfp).io.io_buffer; m_in.m_lc_vfs_fcntl.arg_ptr = (vir_bytes)scratch(rfp).io.io_buffer;
assert(m_in.VFS_FCNTL_CMD == F_SETLKW); assert(m_in.m_lc_vfs_fcntl.cmd == F_SETLKW);
break; break;
default: default:
panic("unblocking call %d blocked on %d ??", m_in.m_type, blocked_on); panic("unblocking call %d blocked on %d ??", m_in.m_type, blocked_on);

View file

@ -103,11 +103,13 @@ int do_fcntl(void)
int new_fd, fl, r = OK, fcntl_req, fcntl_argx; int new_fd, fl, r = OK, fcntl_req, fcntl_argx;
tll_access_t locktype; tll_access_t locktype;
scratch(fp).file.fd_nr = job_m_in.VFS_FCNTL_FD; scratch(fp).file.fd_nr = job_m_in.m_lc_vfs_fcntl.fd;
scratch(fp).io.io_buffer = job_m_in.VFS_FCNTL_ARG_PTR; /* LSC: io_buffer is used everywhere as a valid VFS memory space pointer.
scratch(fp).io.io_nbytes = job_m_in.VFS_FCNTL_CMD; * Seems downright scary to me. */
fcntl_req = job_m_in.VFS_FCNTL_CMD; scratch(fp).io.io_buffer = (char *)job_m_in.m_lc_vfs_fcntl.arg_ptr;
fcntl_argx = job_m_in.VFS_FCNTL_ARG_INT; 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? */ /* Is the file descriptor valid? */
locktype = (fcntl_req == F_FREESP) ? VNODE_WRITE : VNODE_READ; 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 if (!(f->filp_mode & W_BIT)) r = EBADF;
else { else {
/* Copy flock data from userspace. */ /* 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)); SELF, (vir_bytes) &flock_arg, sizeof(flock_arg));
} }