mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-13 03:30:34 +03:00
Use SEEK_{SET,CUR,END} for file seek "whence"
Use either SEEK_* or 0,1,2..., but not both. Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Closes #8656
This commit is contained in:
parent
f4c594da94
commit
126d0fa733
@ -426,7 +426,7 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag,
|
|||||||
int fstrans;
|
int fstrans;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cmd != F_FREESP || bfp->l_whence != 0)
|
if (cmd != F_FREESP || bfp->l_whence != SEEK_SET)
|
||||||
return (EOPNOTSUPP);
|
return (EOPNOTSUPP);
|
||||||
|
|
||||||
ASSERT(vp);
|
ASSERT(vp);
|
||||||
|
@ -255,7 +255,7 @@ vdev_file_io_start(zio_t *zio)
|
|||||||
flck.l_type = F_FREESP;
|
flck.l_type = F_FREESP;
|
||||||
flck.l_start = zio->io_offset;
|
flck.l_start = zio->io_offset;
|
||||||
flck.l_len = zio->io_size;
|
flck.l_len = zio->io_size;
|
||||||
flck.l_whence = 0;
|
flck.l_whence = SEEK_SET;
|
||||||
|
|
||||||
zio->io_error = VOP_SPACE(vf->vf_vnode, F_FREESP, &flck,
|
zio->io_error = VOP_SPACE(vf->vf_vnode, F_FREESP, &flck,
|
||||||
0, 0, kcred, NULL);
|
0, 0, kcred, NULL);
|
||||||
|
@ -792,7 +792,7 @@ zfs_replay_truncate(void *arg1, void *arg2, boolean_t byteswap)
|
|||||||
|
|
||||||
bzero(&fl, sizeof (fl));
|
bzero(&fl, sizeof (fl));
|
||||||
fl.l_type = F_WRLCK;
|
fl.l_type = F_WRLCK;
|
||||||
fl.l_whence = 0;
|
fl.l_whence = SEEK_SET;
|
||||||
fl.l_start = lr->lr_offset;
|
fl.l_start = lr->lr_offset;
|
||||||
fl.l_len = lr->lr_length;
|
fl.l_len = lr->lr_length;
|
||||||
|
|
||||||
|
@ -4867,19 +4867,19 @@ convoff(struct inode *ip, flock64_t *lckdat, int whence, offset_t offset)
|
|||||||
vattr_t vap;
|
vattr_t vap;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if ((lckdat->l_whence == 2) || (whence == 2)) {
|
if ((lckdat->l_whence == SEEK_END) || (whence == SEEK_END)) {
|
||||||
if ((error = zfs_getattr(ip, &vap, 0, CRED())))
|
if ((error = zfs_getattr(ip, &vap, 0, CRED())))
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lckdat->l_whence) {
|
switch (lckdat->l_whence) {
|
||||||
case 1:
|
case SEEK_CUR:
|
||||||
lckdat->l_start += offset;
|
lckdat->l_start += offset;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case SEEK_END:
|
||||||
lckdat->l_start += vap.va_size;
|
lckdat->l_start += vap.va_size;
|
||||||
/* FALLTHRU */
|
/* FALLTHRU */
|
||||||
case 0:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (SET_ERROR(EINVAL));
|
return (SET_ERROR(EINVAL));
|
||||||
@ -4889,13 +4889,13 @@ convoff(struct inode *ip, flock64_t *lckdat, int whence, offset_t offset)
|
|||||||
return (SET_ERROR(EINVAL));
|
return (SET_ERROR(EINVAL));
|
||||||
|
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case 1:
|
case SEEK_CUR:
|
||||||
lckdat->l_start -= offset;
|
lckdat->l_start -= offset;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case SEEK_END:
|
||||||
lckdat->l_start -= vap.va_size;
|
lckdat->l_start -= vap.va_size;
|
||||||
/* FALLTHRU */
|
/* FALLTHRU */
|
||||||
case 0:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (SET_ERROR(EINVAL));
|
return (SET_ERROR(EINVAL));
|
||||||
@ -4950,7 +4950,7 @@ zfs_space(struct inode *ip, int cmd, flock64_t *bfp, int flag,
|
|||||||
return (SET_ERROR(EROFS));
|
return (SET_ERROR(EROFS));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = convoff(ip, bfp, 0, offset))) {
|
if ((error = convoff(ip, bfp, SEEK_SET, offset))) {
|
||||||
ZFS_EXIT(zfsvfs);
|
ZFS_EXIT(zfsvfs);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len)
|
|||||||
if (offset + len > olen)
|
if (offset + len > olen)
|
||||||
len = olen - offset;
|
len = olen - offset;
|
||||||
bf.l_type = F_WRLCK;
|
bf.l_type = F_WRLCK;
|
||||||
bf.l_whence = 0;
|
bf.l_whence = SEEK_SET;
|
||||||
bf.l_start = offset;
|
bf.l_start = offset;
|
||||||
bf.l_len = len;
|
bf.l_len = len;
|
||||||
bf.l_pid = 0;
|
bf.l_pid = 0;
|
||||||
|
@ -636,7 +636,7 @@ zpl_truncate_range(struct inode *ip, loff_t start, loff_t end)
|
|||||||
crhold(cr);
|
crhold(cr);
|
||||||
|
|
||||||
bf.l_type = F_WRLCK;
|
bf.l_type = F_WRLCK;
|
||||||
bf.l_whence = 0;
|
bf.l_whence = SEEK_SET;
|
||||||
bf.l_start = start;
|
bf.l_start = start;
|
||||||
bf.l_len = end - start;
|
bf.l_len = end - start;
|
||||||
bf.l_pid = 0;
|
bf.l_pid = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user