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 */
/* 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 */

View file

@ -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;

View file

@ -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));
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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));
}