From: David van Moolenbroek Date: Thu, 14 Jan 2016 18:29:20 +0000 (+0000) Subject: VFS: start off cleanup of pipe2 IPC message X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-coverage.html?a=commitdiff_plain;h=c33d6ef39285e101533230264f0905e546e2296c;p=minix.git VFS: start off cleanup of pipe2 IPC message There is no reason to use a single message for nonoverlapping requests and replies combined, and in fact splitting them out allows reuse of messages and avoids various problems with field layouts. Since the upcoming socketpair(2) system call will be using the same reply as pipe2(2), split up the single message used for the latter. In order to keep the used parts of messages at the front, start a transitional phase to move the pipe(2) flags field to the front of its request. Change-Id: If3f1c3d348ec7e27b7f5b7147ce1b9ef490dfab9 --- diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index 00e25add8..ac4e7e2a2 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -760,9 +760,14 @@ typedef struct { _ASSERT_MSG_SIZE(mess_lc_vfs_path); typedef struct { - int fd0; - int fd1; + /* + * We are in the process of cleaning up this message, by moving the + * flags value from the third integer into the first. Once enough time + * has passed, we can get rid of the second and third integer fields. + */ int flags; + int _unused; + int oflags; uint8_t padding[44]; } mess_lc_vfs_pipe2; @@ -1949,6 +1954,14 @@ typedef struct { } mess_vfs_fs_utime; _ASSERT_MSG_SIZE(mess_vfs_fs_utime); +typedef struct { + int fd0; + int fd1; + + uint8_t padding[48]; +} mess_vfs_lc_fdpair; +_ASSERT_MSG_SIZE(mess_vfs_lc_fdpair); + typedef struct { off_t offset; @@ -2262,6 +2275,7 @@ typedef struct noxfer_message { mess_vfs_fs_statvfs m_vfs_fs_statvfs; mess_vfs_fs_unlink m_vfs_fs_unlink; mess_vfs_fs_utime m_vfs_fs_utime; + mess_vfs_lc_fdpair m_vfs_lc_fdpair; mess_vfs_lc_lseek m_vfs_lc_lseek; mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel; mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose; diff --git a/minix/lib/libc/sys/pipe.c b/minix/lib/libc/sys/pipe.c index 38e79664b..15dbf236c 100644 --- a/minix/lib/libc/sys/pipe.c +++ b/minix/lib/libc/sys/pipe.c @@ -16,10 +16,11 @@ pipe2(int fild[2], int flags) memset(&m, 0, sizeof(m)); m.m_lc_vfs_pipe2.flags = flags; + m.m_lc_vfs_pipe2.oflags = flags; /* backward compatibility */ if (_syscall(VFS_PROC_NR, VFS_PIPE2, &m) < 0) return(-1); - fild[0] = m.m_lc_vfs_pipe2.fd0; - fild[1] = m.m_lc_vfs_pipe2.fd1; + fild[0] = m.m_vfs_lc_fdpair.fd0; + fild[1] = m.m_vfs_lc_fdpair.fd1; return(0); } diff --git a/minix/servers/vfs/pipe.c b/minix/servers/vfs/pipe.c index 2aee4ac5c..795023fe1 100644 --- a/minix/servers/vfs/pipe.c +++ b/minix/servers/vfs/pipe.c @@ -43,11 +43,12 @@ int do_pipe2(void) int fil_des[2]; /* reply goes here */ flags = job_m_in.m_lc_vfs_pipe2.flags; + flags |= job_m_in.m_lc_vfs_pipe2.oflags; /* backward compatibility */ r = create_pipe(fil_des, flags); if (r == OK) { - job_m_out.m_lc_vfs_pipe2.fd0 = fil_des[0]; - job_m_out.m_lc_vfs_pipe2.fd1 = fil_des[1]; + job_m_out.m_vfs_lc_fdpair.fd0 = fil_des[0]; + job_m_out.m_vfs_lc_fdpair.fd1 = fil_des[1]; } return r; diff --git a/minix/usr.bin/trace/service/vfs.c b/minix/usr.bin/trace/service/vfs.c index c928f2e26..ed4791dfc 100644 --- a/minix/usr.bin/trace/service/vfs.c +++ b/minix/usr.bin/trace/service/vfs.c @@ -678,8 +678,8 @@ vfs_pipe2_in(struct trace_proc * proc, const message * m_out, if (!failed) { put_open(proc, "fd", PF_NONAME, "[", ", "); - put_fd(proc, "rfd", m_in->m_lc_vfs_pipe2.fd0); - put_fd(proc, "wfd", m_in->m_lc_vfs_pipe2.fd1); + put_fd(proc, "rfd", m_in->m_vfs_lc_fdpair.fd0); + put_fd(proc, "wfd", m_in->m_vfs_lc_fdpair.fd1); put_close(proc, "]"); } else put_field(proc, "fd", "&..");