]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Use SEEK_{SET,CUR,END} for file seek "whence"
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 25 Apr 2019 17:17:28 +0000 (02:17 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 25 Apr 2019 17:17:27 +0000 (10:17 -0700)
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

module/spl/spl-vnode.c
module/zfs/vdev_file.c
module/zfs/zfs_replay.c
module/zfs/zfs_vnops.c
module/zfs/zpl_file.c
module/zfs/zpl_inode.c

index 855c642c989372b136bb58dd841718b9dc00dc61..ef5f605404449fc18e9600cc2acb126a580f0d88 100644 (file)
@@ -426,7 +426,7 @@ int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag,
        int fstrans;
 #endif
 
-       if (cmd != F_FREESP || bfp->l_whence != 0)
+       if (cmd != F_FREESP || bfp->l_whence != SEEK_SET)
                return (EOPNOTSUPP);
 
        ASSERT(vp);
index c04f40ca452ce5fe9cfb24b43be635729006eb99..c155057852a302eb35a957eaeba11a1bdd8ead1c 100644 (file)
@@ -255,7 +255,7 @@ vdev_file_io_start(zio_t *zio)
                flck.l_type = F_FREESP;
                flck.l_start = zio->io_offset;
                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,
                    0, 0, kcred, NULL);
index ba103084f0c51e28465dac6f09cccd0a6bfecfef..1443817690590ec0bf0573b7cbce0f3d1d8bba46 100644 (file)
@@ -792,7 +792,7 @@ zfs_replay_truncate(void *arg1, void *arg2, boolean_t byteswap)
 
        bzero(&fl, sizeof (fl));
        fl.l_type = F_WRLCK;
-       fl.l_whence = 0;
+       fl.l_whence = SEEK_SET;
        fl.l_start = lr->lr_offset;
        fl.l_len = lr->lr_length;
 
index 18dfc5a680824bae55da06f6677fb3c540a2e627..281f58249ad54b43a8cb103963ac5a47099ea1d1 100644 (file)
@@ -4867,19 +4867,19 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
        vattr_t vap;
        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())))
                        return (error);
        }
 
        switch (lckdat->l_whence) {
-       case 1:
+       case SEEK_CUR:
                lckdat->l_start += offset;
                break;
-       case 2:
+       case SEEK_END:
                lckdat->l_start += vap.va_size;
                /* FALLTHRU */
-       case 0:
+       case SEEK_SET:
                break;
        default:
                return (SET_ERROR(EINVAL));
@@ -4889,13 +4889,13 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
                return (SET_ERROR(EINVAL));
 
        switch (whence) {
-       case 1:
+       case SEEK_CUR:
                lckdat->l_start -= offset;
                break;
-       case 2:
+       case SEEK_END:
                lckdat->l_start -= vap.va_size;
                /* FALLTHRU */
-       case 0:
+       case SEEK_SET:
                break;
        default:
                return (SET_ERROR(EINVAL));
@@ -4950,7 +4950,7 @@ zfs_space(struct inode *ip, int cmd, flock64_t *bfp, int flag,
                return (SET_ERROR(EROFS));
        }
 
-       if ((error = convoff(ip, bfp, 0, offset))) {
+       if ((error = convoff(ip, bfp, SEEK_SET, offset))) {
                ZFS_EXIT(zfsvfs);
                return (error);
        }
index 45e82c80d5ed387a6619b15e848cf587ec8c59d8..9c231d9502c4df70761d08dbde21f67c65127edd 100644 (file)
@@ -771,7 +771,7 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len)
        if (offset + len > olen)
                len = olen - offset;
        bf.l_type = F_WRLCK;
-       bf.l_whence = 0;
+       bf.l_whence = SEEK_SET;
        bf.l_start = offset;
        bf.l_len = len;
        bf.l_pid = 0;
index 41b91cabcb9689a428843175043a5c7e70063b05..720330a8b7d4b490120b0f1cd432797949973665 100644 (file)
@@ -636,7 +636,7 @@ zpl_truncate_range(struct inode *ip, loff_t start, loff_t end)
        crhold(cr);
 
        bf.l_type = F_WRLCK;
-       bf.l_whence = 0;
+       bf.l_whence = SEEK_SET;
        bf.l_start = start;
        bf.l_len = end - start;
        bf.l_pid = 0;