tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
adding linux syscall fallocate
Hi All,
I'm trying to add and map the linux syscall fallocate to posix_fallocate so I modified sys/compat/linux/common/linux_file.c like:
int linux_sys_fallocate(struct lwp *l, const struct linux_sys_fallocate_args *uap, register_t *retval){
int mode = SCARG(uap, mode);
printf("\nCalling linux_sys_fallocate, mode is:%d\n",mode);
if(mode == 0){
struct sys_posix_fallocate_args fall;
SCARG(&fall, fd) = SCARG(uap, fd);
// Is PAD necessary? Compiles with and without as well but it's there in sys/kern/syscalls.master
// and sys/kern/systrace_args.c but not in sys/kern/vfs_syscalls.c
SCARG(&fall, PAD) = 0;
SCARG(&fall, pos) = SCARG(uap, offset);
SCARG(&fall, len) = SCARG(uap, len);
int result = sys_posix_fallocate(l, &fall, retval);
printf("result:%d\n",result);
return result;
}
return EOPNOTSUPP;
}
This seems to compile but when tested it didn't work out so I added some printfs to sys/kern/vfs_syscalls.c:
int sys_posix_fallocate(struct lwp *l, const struct sys_posix_fallocate_args *uap,
register_t *retval)
{
/* {
syscallarg(int) fd;
syscallarg(off_t) pos;
syscallarg(off_t) len;
} */
int fd;
off_t pos, len;
struct file *fp;
struct vnode *vp;
int error;
fd = SCARG(uap, fd);
pos = SCARG(uap, pos);
len = SCARG(uap, len);
if (pos < 0 || len < 0 || len > OFF_T_MAX - pos) {
printf("posix_fallocate line 4718\n");
*retval = EINVAL;
return 0;
}
error = fd_getvnode(fd, &fp);
if (error) {
printf("posix_fallocate line 4725\n");
*retval = error;
return 0;
}
if ((fp->f_flag & FWRITE) == 0) {
printf("posix_fallocate line 4730\n");
error = EBADF;
goto fail;
}
vp = fp->f_vnode;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_type == VDIR) {
printf("posix_fallocate line 4738\n");
error = EISDIR;
} else {
printf("posix_fallocate line 4741\n");
error = VOP_FALLOCATE(vp, pos, len);
}
VOP_UNLOCK(vp);
fail:
fd_putfile(fd);
*retval = error;
return 0;
}
As you can see on the attached screenshot, "line 4741" gets printed out. So I went on to check what happens in VOP_FALLOCATE but it gets really internal there.
Does anyone have any hint?
Thanks,
r0ller
Attachment:
fallocate_result2.JPG
Description: JPEG image
Home |
Main Index |
Thread Index |
Old Index