diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-17 07:25:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-17 07:25:52 +0000 |
commit | 445d92b5126efaafe35e9771f6cc5a0dd1b5e2e2 (patch) | |
tree | c40c0c3338339afd3dde504ff3d5b5c2b65edb9d /sys/compat/svr4/svr4_fcntl.c | |
parent | cb0afbd34bbf8f655182c3349418759b6c23e5c4 (diff) |
improve F_FREESP; now it might work
Diffstat (limited to 'sys/compat/svr4/svr4_fcntl.c')
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index 67340f878cb..355f6ccac8e 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_fcntl.c,v 1.11 1997/12/17 03:30:40 deraadt Exp $ */ +/* $OpenBSD: svr4_fcntl.c,v 1.12 1997/12/17 07:25:51 deraadt Exp $ */ /* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */ /* @@ -390,34 +390,39 @@ svr4_sys_fcntl(p, v, retval) if (error) return error; + SCARG(&ofst, fd) = SCARG(uap, fd); + SCARG(&ofst, sb) = stackgap_alloc(&sg, + sizeof(struct stat)); + if ((error = sys_fstat(p, &ofst, retval)) != 0) + return error; + if ((error = copyin(SCARG(&ofst, sb), &ost, + sizeof ost)) != 0) + return error; + + SCARG(&ols, fd) = SCARG(uap, fd); + SCARG(&ols, whence) = SEEK_CUR; + SCARG(&ols, offset) = 0; + if ((error = sys_lseek(p, &ols, (register_t *)&cur)) != 0) + return error; + off = (off_t)ifl.l_start; switch (ifl.l_whence) { case 0: off = (off_t)ifl.l_start; break; case 1: - SCARG(&ofst, fd) = SCARG(uap, fd); - SCARG(&ofst, sb) = stackgap_alloc(&sg, - sizeof(struct stat)); - if ((error = sys_fstat(p, &ofst, retval)) != 0) - return error; - if ((error = copyin(SCARG(&ofst, sb), &ost, - sizeof ost)) != 0) - return error; off = ost.st_size + (off_t)ifl.l_start; break; case 2: - SCARG(&ols, fd) = SCARG(uap, fd); - SCARG(&ols, whence) = SEEK_CUR; - SCARG(&ols, offset) = 0; - if ((error = sys_lseek(p, &ols, (register_t *)&cur)) != 0) - return error; off = cur - (off_t)ifl.l_start; break; default: return EINVAL; } + if (ifl.l_len != 0 && off + ifl.l_len != ost.st_size) + return EINVAL; /* Sorry, cannot truncate in middle */ + SCARG(&nuap, fd) = SCARG(uap, fd); SCARG(&nuap, length) = off; return (sys_ftruncate(p, &nuap, retval)); |