From: Lionel Sambuc Date: Mon, 12 May 2014 11:24:16 +0000 (+0200) Subject: Message type for VFS_TRUNCATE X-Git-Tag: v3.3.0~313 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch06.html?a=commitdiff_plain;h=befa020a9e6437d2aa01601a2e90e7ca632c17fd;p=minix.git Message type for VFS_TRUNCATE Change-Id: I6f51c979c8986660883221d3acfa07d1c1b25dff --- diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 04f1de2b2..048e4db56 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 truncate(2) and ftruncate(2) calls. */ -#define VFS_TRUNCATE_FD m2_i1 /* int */ -#define VFS_TRUNCATE_NAME m2_p1 /* const char * */ -#define VFS_TRUNCATE_LEN m2_i1 /* size_t */ -#define VFS_TRUNCATE_OFF m2_ll1 /* off_t */ - /* Field names for the pipe2(2) call. */ #define VFS_PIPE2_FD0 m1_i1 /* int */ #define VFS_PIPE2_FD1 m1_i2 /* int */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 032e86fab..8f4077462 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -225,6 +225,17 @@ typedef struct { } mess_lc_vfs_statvfs1; _ASSERT_MSG_SIZE(mess_lc_vfs_statvfs1); +typedef struct { + off_t offset; + + int fd; + vir_bytes name; + size_t len; + + uint8_t padding[36]; +} mess_lc_vfs_truncate; +_ASSERT_MSG_SIZE(mess_lc_vfs_truncate); + typedef struct { vir_bytes name; size_t namelen; @@ -720,6 +731,7 @@ typedef struct { mess_lc_vfs_mount m_lc_vfs_mount; mess_lc_vfs_select m_lc_vfs_select; mess_lc_vfs_statvfs1 m_lc_vfs_statvfs1; + mess_lc_vfs_truncate m_lc_vfs_truncate; mess_lc_vfs_umount m_lc_vfs_umount; mess_lsys_vfs_checkperms m_lsys_vfs_checkperms; diff --git a/lib/libc/sys-minix/ftruncate.c b/lib/libc/sys-minix/ftruncate.c index 7886bb27e..1e4d67142 100644 --- a/lib/libc/sys-minix/ftruncate.c +++ b/lib/libc/sys-minix/ftruncate.c @@ -15,8 +15,8 @@ int ftruncate(int _fd, off_t _length) message m; memset(&m, 0, sizeof(m)); - m.VFS_TRUNCATE_OFF = _length; - m.VFS_TRUNCATE_FD = _fd; + m.m_lc_vfs_truncate.offset = _length; + m.m_lc_vfs_truncate.fd = _fd; return(_syscall(VFS_PROC_NR, VFS_FTRUNCATE, &m)); } diff --git a/lib/libc/sys-minix/truncate.c b/lib/libc/sys-minix/truncate.c index 73932c21d..4249fc298 100644 --- a/lib/libc/sys-minix/truncate.c +++ b/lib/libc/sys-minix/truncate.c @@ -11,9 +11,9 @@ int truncate(const char *_path, off_t _length) message m; memset(&m, 0, sizeof(m)); - m.VFS_TRUNCATE_NAME = (char *) __UNCONST(_path); - m.VFS_TRUNCATE_LEN = strlen(_path)+1; - m.VFS_TRUNCATE_OFF = _length; + m.m_lc_vfs_truncate.name = (vir_bytes)_path; + m.m_lc_vfs_truncate.len = strlen(_path)+1; + m.m_lc_vfs_truncate.offset = _length; return(_syscall(VFS_PROC_NR, VFS_TRUNCATE, &m)); } diff --git a/servers/vfs/link.c b/servers/vfs/link.c index 8d4d50e04..c69a67a5c 100644 --- a/servers/vfs/link.c +++ b/servers/vfs/link.c @@ -290,14 +290,14 @@ int do_truncate(void) vir_bytes vname; size_t vname_length; - vname = (vir_bytes) job_m_in.VFS_TRUNCATE_NAME; - vname_length = job_m_in.VFS_TRUNCATE_LEN; + vname = job_m_in.m_lc_vfs_truncate.name; + vname_length = job_m_in.m_lc_vfs_truncate.len; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; resolve.l_vnode_lock = VNODE_WRITE; - length = (off_t) job_m_in.VFS_TRUNCATE_OFF; + length = job_m_in.m_lc_vfs_truncate.offset; if (length < 0) return(EINVAL); /* Temporarily open file */ @@ -333,9 +333,9 @@ int do_ftruncate(void) int r; off_t length; - scratch(fp).file.fd_nr = job_m_in.VFS_TRUNCATE_FD; + scratch(fp).file.fd_nr = job_m_in.m_lc_vfs_truncate.fd; - length = (off_t) job_m_in.VFS_TRUNCATE_OFF; + length = job_m_in.m_lc_vfs_truncate.offset; if (length < 0) return(EINVAL); /* File is already opened; get a vnode pointer from filp */