Message type for VFS_TRUNCATE

Change-Id: I6f51c979c8986660883221d3acfa07d1c1b25dff
This commit is contained in:
Lionel Sambuc 2014-05-12 13:24:16 +02:00
parent 268d670a85
commit befa020a9e
5 changed files with 22 additions and 16 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 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. */ /* Field names for the pipe2(2) call. */
#define VFS_PIPE2_FD0 m1_i1 /* int */ #define VFS_PIPE2_FD0 m1_i1 /* int */
#define VFS_PIPE2_FD1 m1_i2 /* int */ #define VFS_PIPE2_FD1 m1_i2 /* int */

View file

@ -225,6 +225,17 @@ typedef struct {
} mess_lc_vfs_statvfs1; } mess_lc_vfs_statvfs1;
_ASSERT_MSG_SIZE(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 { typedef struct {
vir_bytes name; vir_bytes name;
size_t namelen; size_t namelen;
@ -720,6 +731,7 @@ typedef struct {
mess_lc_vfs_mount m_lc_vfs_mount; mess_lc_vfs_mount m_lc_vfs_mount;
mess_lc_vfs_select m_lc_vfs_select; mess_lc_vfs_select m_lc_vfs_select;
mess_lc_vfs_statvfs1 m_lc_vfs_statvfs1; 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_lc_vfs_umount m_lc_vfs_umount;
mess_lsys_vfs_checkperms m_lsys_vfs_checkperms; mess_lsys_vfs_checkperms m_lsys_vfs_checkperms;

View file

@ -15,8 +15,8 @@ int ftruncate(int _fd, off_t _length)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.VFS_TRUNCATE_OFF = _length; m.m_lc_vfs_truncate.offset = _length;
m.VFS_TRUNCATE_FD = _fd; m.m_lc_vfs_truncate.fd = _fd;
return(_syscall(VFS_PROC_NR, VFS_FTRUNCATE, &m)); return(_syscall(VFS_PROC_NR, VFS_FTRUNCATE, &m));
} }

View file

@ -11,9 +11,9 @@ int truncate(const char *_path, off_t _length)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.VFS_TRUNCATE_NAME = (char *) __UNCONST(_path); m.m_lc_vfs_truncate.name = (vir_bytes)_path;
m.VFS_TRUNCATE_LEN = strlen(_path)+1; m.m_lc_vfs_truncate.len = strlen(_path)+1;
m.VFS_TRUNCATE_OFF = _length; m.m_lc_vfs_truncate.offset = _length;
return(_syscall(VFS_PROC_NR, VFS_TRUNCATE, &m)); return(_syscall(VFS_PROC_NR, VFS_TRUNCATE, &m));
} }

View file

@ -290,14 +290,14 @@ int do_truncate(void)
vir_bytes vname; vir_bytes vname;
size_t vname_length; size_t vname_length;
vname = (vir_bytes) job_m_in.VFS_TRUNCATE_NAME; vname = job_m_in.m_lc_vfs_truncate.name;
vname_length = job_m_in.VFS_TRUNCATE_LEN; vname_length = job_m_in.m_lc_vfs_truncate.len;
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
resolve.l_vmnt_lock = VMNT_READ; resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_WRITE; 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); if (length < 0) return(EINVAL);
/* Temporarily open file */ /* Temporarily open file */
@ -333,9 +333,9 @@ int do_ftruncate(void)
int r; int r;
off_t length; 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); if (length < 0) return(EINVAL);
/* File is already opened; get a vnode pointer from filp */ /* File is already opened; get a vnode pointer from filp */