The branch main has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5d3fe02c5a7649d35b9eaae1357376a643addb70

commit 5d3fe02c5a7649d35b9eaae1357376a643addb70
Author:     Rick Macklem <rmack...@freebsd.org>
AuthorDate: 2022-06-22 20:20:32 +0000
Commit:     Rick Macklem <rmack...@freebsd.org>
CommitDate: 2022-06-22 20:20:32 +0000

    nfsd: Clean up the code by not using the vnode_vtype() macro
    
    The vnode_vtype() macro was used to make the code compatible
    with Mac OSX, for the Mac OSX port.
    For FreeBSD, this macro just obscured the code, so
    avoid using it to clean up the code.
    
    This commit should not result in a semantics change.
---
 sys/fs/nfsserver/nfs_nfsdserv.c  | 46 ++++++++++++++++++++--------------------
 sys/fs/nfsserver/nfs_nfsdstate.c |  4 ++--
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 4cc14340d7d1..db1075596b91 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -198,7 +198,7 @@ nfsrvd_access(struct nfsrv_descript *nd, __unused int 
isdgram,
                    NFSACCCHK_NOOVERRIDE, NFSACCCHK_VPISLOCKED, &supported))
                        nfsmode &= ~NFSACCESS_DELETE;
        }
-       if (vnode_vtype(vp) == VDIR)
+       if (vp->v_type == VDIR)
                testmode = NFSACCESS_LOOKUP;
        else
                testmode = NFSACCESS_EXECUTE;
@@ -441,7 +441,7 @@ nfsrvd_setattr(struct nfsrv_descript *nd, __unused int 
isdgram,
                            (vp->v_mount->mnt_flag & MNT_RDONLY))
                                nd->nd_repstat = EROFS;
                } else {
-                       if (vnode_vtype(vp) != VREG)
+                       if (vp->v_type != VREG)
                                nd->nd_repstat = EINVAL;
                        else if (nva2.na_uid != nd->nd_cred->cr_uid ||
                            NFSVNO_EXSTRICTACCESS(exp))
@@ -698,7 +698,7 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused int 
isdgram,
                nfsrv_postopattr(nd, getret, &nva);
                goto out;
        }
-       if (vnode_vtype(vp) != VLNK) {
+       if (vp->v_type != VLNK) {
                if (nd->nd_flag & ND_NFSV2)
                        nd->nd_repstat = ENXIO;
                else
@@ -833,11 +833,11 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int 
isdgram,
                if (lop->lo_end < off)
                        lop->lo_end = NFS64BITSSET;
        }
-       if (vnode_vtype(vp) != VREG) {
+       if (vp->v_type != VREG) {
                if (nd->nd_flag & ND_NFSV3)
                        nd->nd_repstat = EINVAL;
                else
-                       nd->nd_repstat = (vnode_vtype(vp) == VDIR) ? EISDIR :
+                       nd->nd_repstat = (vp->v_type == VDIR) ? EISDIR :
                            EINVAL;
        }
        getret = nfsvno_getattr(vp, &nva, nd, p, 1, NULL);
@@ -1042,11 +1042,11 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int 
isdgram,
 
        if (retlen > nfs_srvmaxio || retlen < 0)
                nd->nd_repstat = EIO;
-       if (vnode_vtype(vp) != VREG && !nd->nd_repstat) {
+       if (vp->v_type != VREG && !nd->nd_repstat) {
                if (nd->nd_flag & ND_NFSV3)
                        nd->nd_repstat = EINVAL;
                else
-                       nd->nd_repstat = (vnode_vtype(vp) == VDIR) ? EISDIR :
+                       nd->nd_repstat = (vp->v_type == VDIR) ? EISDIR :
                            EINVAL;
        }
        NFSZERO_ATTRBIT(&attrbits);
@@ -1567,7 +1567,7 @@ nfsrvd_remove(struct nfsrv_descript *nd, __unused int 
isdgram,
        }
        if (!nd->nd_repstat) {
                if (nd->nd_flag & ND_NFSV4) {
-                       if (vnode_vtype(named.ni_vp) == VDIR)
+                       if (named.ni_vp->v_type == VDIR)
                                nd->nd_repstat = nfsvno_rmdirsub(&named, 1,
                                    nd->nd_cred, p, exp);
                        else
@@ -1740,7 +1740,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram,
                nfsvno_relpathbuf(&tond);
                goto out;
        }
-       if (vnode_vtype(fromnd.ni_vp) == VDIR)
+       if (fromnd.ni_vp->v_type == VDIR)
                tond.ni_cnd.cn_flags |= WILLBEDIR;
        nd->nd_repstat = nfsvno_namei(nd, &tond, tdp, 0, &tnes, &tdirp);
        nd->nd_repstat = nfsvno_rename(&fromnd, &tond, nd->nd_repstat,
@@ -1798,7 +1798,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram,
                goto out;
        }
        NFSVOPUNLOCK(vp);
-       if (vnode_vtype(vp) == VDIR) {
+       if (vp->v_type == VDIR) {
                if (nd->nd_flag & ND_NFSV4)
                        nd->nd_repstat = NFSERR_ISDIR;
                else
@@ -2499,8 +2499,8 @@ nfsrvd_lock(struct nfsrv_descript *nd, __unused int 
isdgram,
        /*
         * Do basic access checking.
         */
-       if (!nd->nd_repstat && vnode_vtype(vp) != VREG) {
-           if (vnode_vtype(vp) == VDIR)
+       if (!nd->nd_repstat && vp->v_type != VREG) {
+           if (vp->v_type == VDIR)
                nd->nd_repstat = NFSERR_ISDIR;
            else
                nd->nd_repstat = NFSERR_INVAL;
@@ -2643,8 +2643,8 @@ nfsrvd_lockt(struct nfsrv_descript *nd, __unused int 
isdgram,
        error = nfsrv_mtostr(nd, stp->ls_owner, stp->ls_ownerlen);
        if (error)
                goto nfsmout;
-       if (!nd->nd_repstat && vnode_vtype(vp) != VREG) {
-           if (vnode_vtype(vp) == VDIR)
+       if (!nd->nd_repstat && vp->v_type != VREG) {
+           if (vp->v_type == VDIR)
                nd->nd_repstat = NFSERR_ISDIR;
            else
                nd->nd_repstat = NFSERR_INVAL;
@@ -2775,8 +2775,8 @@ nfsrvd_locku(struct nfsrv_descript *nd, __unused int 
isdgram,
                nd->nd_flag |= ND_IMPLIEDCLID;
                nd->nd_clientid.qval = clientid.qval;
        }
-       if (!nd->nd_repstat && vnode_vtype(vp) != VREG) {
-           if (vnode_vtype(vp) == VDIR)
+       if (!nd->nd_repstat && vp->v_type != VREG) {
+           if (vp->v_type == VDIR)
                nd->nd_repstat = NFSERR_ISDIR;
            else
                nd->nd_repstat = NFSERR_INVAL;
@@ -3112,7 +3112,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int 
isdgram,
        /*
         * Do basic access checking.
         */
-       if (!nd->nd_repstat && vnode_vtype(vp) != VREG) {
+       if (!nd->nd_repstat && vp->v_type != VREG) {
                /*
                 * The IETF working group decided that this is the correct
                 * error return for all non-regular files.
@@ -5411,7 +5411,7 @@ nfsrvd_allocate(struct nfsrv_descript *nd, __unused int 
isdgram,
            OFF_MAX || lop->lo_end < lop->lo_first))
                nd->nd_repstat = NFSERR_INVAL;
 
-       if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG)
+       if (nd->nd_repstat == 0 && vp->v_type != VREG)
                nd->nd_repstat = NFSERR_WRONGTYPE;
        NFSZERO_ATTRBIT(&attrbits);
        NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_OWNER);
@@ -5519,7 +5519,7 @@ nfsrvd_deallocate(struct nfsrv_descript *nd, __unused int 
isdgram,
                        nd->nd_repstat = NFSERR_INVAL;
        }
 
-       if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG)
+       if (nd->nd_repstat == 0 && vp->v_type != VREG)
                nd->nd_repstat = NFSERR_WRONGTYPE;
        NFSZERO_ATTRBIT(&attrbits);
        NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_OWNER);
@@ -5633,7 +5633,7 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, 
__unused int isdgram,
            outlop->lo_first))
                nd->nd_repstat = NFSERR_INVAL;
 
-       if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG)
+       if (nd->nd_repstat == 0 && vp->v_type != VREG)
                nd->nd_repstat = NFSERR_WRONGTYPE;
 
        /* Check permissions for the input file. */
@@ -5657,7 +5657,7 @@ nfsrvd_copy_file_range(struct nfsrv_descript *nd, 
__unused int isdgram,
        error = NFSVOPLOCK(tovp, LK_SHARED);
        if (error != 0)
                goto out;
-       if (vnode_vtype(tovp) != VREG)
+       if (tovp->v_type != VREG)
                nd->nd_repstat = NFSERR_WRONGTYPE;
 
        /* For the output file, we only need the Owner attribute. */
@@ -5799,9 +5799,9 @@ nfsrvd_seek(struct nfsrv_descript *nd, __unused int 
isdgram,
                cmd = FIOSEEKHOLE;
        else
                nd->nd_repstat = NFSERR_BADXDR;
-       if (nd->nd_repstat == 0 && vnode_vtype(vp) == VDIR)
+       if (nd->nd_repstat == 0 && vp->v_type == VDIR)
                nd->nd_repstat = NFSERR_ISDIR;
-       if (nd->nd_repstat == 0 && vnode_vtype(vp) != VREG)
+       if (nd->nd_repstat == 0 && vp->v_type != VREG)
                nd->nd_repstat = NFSERR_WRONGTYPE;
        if (nd->nd_repstat == 0 && off < 0)
                nd->nd_repstat = NFSERR_NXIO;
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index 353ca80bc97e..419851895c7a 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -3471,8 +3471,8 @@ nfsrv_openupdate(vnode_t vp, struct nfsstate *new_stp, 
nfsquad_t clientid,
             ((nd->nd_flag & ND_NFSV41) != 0 &&
              new_stp->ls_stateid.seqid != 0)))
                error = NFSERR_OLDSTATEID;
-       if (!error && vnode_vtype(vp) != VREG) {
-               if (vnode_vtype(vp) == VDIR)
+       if (!error && vp->v_type != VREG) {
+               if (vp->v_type == VDIR)
                        error = NFSERR_ISDIR;
                else
                        error = NFSERR_INVAL;

Reply via email to