summaryrefslogtreecommitdiff
path: root/sys/nfs
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-01-10 20:06:54 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-01-10 20:06:54 +0000
commit052b43163f6e0a3b05a14c19b4e3f3de80fe7162 (patch)
tree9bbac4d5ddb71c7e883f33d09fff5be469f30ce6 /sys/nfs
parent72cf5c5e2022b91fc486d3ef569034cbcbdeb2a8 (diff)
Fix for creating files on a Solaris 7 server with NFSv3 (the request was
slightly garbled but older servers seemed to understand it); dfr@freebsd.org
Diffstat (limited to 'sys/nfs')
-rw-r--r--sys/nfs/nfs_vnops.c103
-rw-r--r--sys/nfs/nfsm_subs.h73
2 files changed, 80 insertions, 96 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 9aeb227b2e2..3804d47504d 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.22 1998/08/19 22:26:57 csapuntz Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.23 1999/01/10 20:06:51 millert Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -599,7 +599,7 @@ nfs_setattr(v)
case VFIFO:
if (vap->va_mtime.tv_sec == VNOVAL &&
vap->va_atime.tv_sec == VNOVAL &&
- vap->va_mode == (u_short)VNOVAL &&
+ vap->va_mode == (mode_t)VNOVAL &&
vap->va_uid == (uid_t)VNOVAL &&
vap->va_gid == (gid_t)VNOVAL)
return (0);
@@ -661,69 +661,12 @@ nfs_setattrrpc(vp, vap, cred, procp)
nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3));
nfsm_fhtom(vp, v3);
if (v3) {
- if (vap->va_mode != (u_short)VNOVAL) {
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- *tl = txdr_unsigned(vap->va_mode);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- }
- if (vap->va_uid != (uid_t)VNOVAL) {
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- *tl = txdr_unsigned(vap->va_uid);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- }
- if (vap->va_gid != (gid_t)VNOVAL) {
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- *tl = txdr_unsigned(vap->va_gid);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- }
- if (vap->va_size != VNOVAL) {
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- txdr_hyper(&vap->va_size, tl);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- }
- if (vap->va_atime.tv_sec != VNOVAL) {
- if (vap->va_atime.tv_sec != time.tv_sec) {
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
- txdr_nfsv3time(&vap->va_mtime, tl);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);
- }
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
- }
- if (vap->va_mtime.tv_sec != VNOVAL) {
- if (vap->va_mtime.tv_sec != time.tv_sec) {
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
- txdr_nfsv3time(&vap->va_mtime, tl);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER);
- }
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
- }
+ nfsm_v3attrbuild(vap, TRUE);
nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = nfs_false;
} else {
nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- if (vap->va_mode == (u_short)VNOVAL)
+ if (vap->va_mode == (mode_t)VNOVAL)
sp->sa_mode = nfs_xdrneg1;
else
sp->sa_mode = vtonfsv2_mode(vp->v_type, vap->va_mode);
@@ -1165,7 +1108,6 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
register struct vattr *vap;
{
register struct nfsv2_sattr *sp;
- register struct nfsv3_sattr *sp3;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
@@ -1193,10 +1135,9 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
nfsm_fhtom(dvp, v3);
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
if (v3) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3SRVSATTR);
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
*tl++ = vtonfsv3_type(vap->va_type);
- sp3 = (struct nfsv3_sattr *)tl;
- nfsm_v3sattr(sp3, vap);
+ nfsm_v3attrbuild(vap, FALSE);
if (vap->va_type == VCHR || vap->va_type == VBLK) {
nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(major(vap->va_rdev));
@@ -1286,7 +1227,6 @@ nfs_create(v)
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
register struct nfsv2_sattr *sp;
- register struct nfsv3_sattr *sp3;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
@@ -1316,18 +1256,16 @@ again:
if (v3) {
nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
if (fmode & O_EXCL) {
- *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
- nfsm_build(tl, u_int32_t *, NFSX_V3CREATEVERF);
- if (in_ifaddr.tqh_first)
- *tl++ = in_ifaddr.tqh_first->ia_addr.sin_addr.s_addr;
- else
- *tl++ = create_verf;
- *tl = ++create_verf;
+ *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
+ nfsm_build(tl, u_int32_t *, NFSX_V3CREATEVERF);
+ if (in_ifaddr.tqh_first)
+ *tl++ = in_ifaddr.tqh_first->ia_addr.sin_addr.s_addr;
+ else
+ *tl++ = create_verf;
+ *tl = ++create_verf;
} else {
- *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED);
- nfsm_build(tl, u_int32_t *, NFSX_V3SRVSATTR);
- sp3 = (struct nfsv3_sattr *)tl;
- nfsm_v3sattr(sp3, vap);
+ *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED);
+ nfsm_v3attrbuild(vap, FALSE);
}
} else {
nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
@@ -1708,7 +1646,6 @@ nfs_symlink(v)
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
register struct nfsv2_sattr *sp;
- register struct nfsv3_sattr *sp3;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
@@ -1724,10 +1661,8 @@ nfs_symlink(v)
nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + NFSX_SATTR(v3));
nfsm_fhtom(dvp, v3);
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- if (v3) {
- nfsm_build(sp3, struct nfsv3_sattr *, NFSX_V3SRVSATTR);
- nfsm_v3sattr(sp3, vap);
- }
+ if (v3)
+ nfsm_v3attrbuild(vap, FALSE);
nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN);
if (!v3) {
nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
@@ -1777,7 +1712,6 @@ nfs_mkdir(v)
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
register struct nfsv2_sattr *sp;
- register struct nfsv3_sattr *sp3;
register u_int32_t *tl;
register caddr_t cp;
register int32_t t1, t2;
@@ -1797,8 +1731,7 @@ nfs_mkdir(v)
nfsm_fhtom(dvp, v3);
nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
if (v3) {
- nfsm_build(sp3, struct nfsv3_sattr *, NFSX_V3SRVSATTR);
- nfsm_v3sattr(sp3, vap);
+ nfsm_v3attrbuild(vap, FALSE);
} else {
nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
sp->sa_mode = vtonfsv2_mode(VDIR, vap->va_mode);
diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h
index 9d4b420a546..c0df657bf0e 100644
--- a/sys/nfs/nfsm_subs.h
+++ b/sys/nfs/nfsm_subs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfsm_subs.h,v 1.8 1998/08/19 22:26:58 csapuntz Exp $ */
+/* $OpenBSD: nfsm_subs.h,v 1.9 1999/01/10 20:06:53 millert Exp $ */
/* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */
/*
@@ -228,17 +228,68 @@
(f) = ttattrf; \
} }
-#define nfsm_v3sattr(s, a) \
- { (s)->sa_modetrue = nfs_true; \
- (s)->sa_mode = vtonfsv3_mode((a)->va_mode); \
- (s)->sa_uidfalse = nfs_false; \
- (s)->sa_gidfalse = nfs_false; \
- (s)->sa_sizefalse = nfs_false; \
- (s)->sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
- txdr_nfsv3time(&(a)->va_atime, &(s)->sa_atime); \
- (s)->sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
- txdr_nfsv3time(&(a)->va_mtime, &(s)->sa_mtime); \
+/* If full is true, set all fields, otherwise just set mode and time fields */
+#define nfsm_v3attrbuild(a, full) \
+ { if ((a)->va_mode != (mode_t)VNOVAL) { \
+ nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
+ *tl++ = nfs_true; \
+ *tl = txdr_unsigned((a)->va_mode); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = nfs_false; \
+ } \
+ if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \
+ nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
+ *tl++ = nfs_true; \
+ *tl = txdr_unsigned((a)->va_uid); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = nfs_false; \
+ } \
+ if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \
+ nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
+ *tl++ = nfs_true; \
+ *tl = txdr_unsigned((a)->va_gid); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = nfs_false; \
+ } \
+ if ((full) && (a)->va_size != VNOVAL) { \
+ nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
+ *tl++ = nfs_true; \
+ txdr_hyper(&(a)->va_size, tl); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = nfs_false; \
+ } \
+ if ((a)->va_atime.tv_sec != VNOVAL) { \
+ if ((a)->va_atime.tv_sec != time.tv_sec) { \
+ nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
+ *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
+ txdr_nfsv3time(&(a)->va_atime, tl); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
+ } \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
+ } \
+ if ((a)->va_mtime.tv_sec != VNOVAL) { \
+ if ((a)->va_mtime.tv_sec != time.tv_sec) { \
+ nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
+ *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); \
+ txdr_nfsv3time(&(a)->va_mtime, tl); \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
+ } \
+ } else { \
+ nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
+ *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
+ } \
}
+
#define nfsm_strsiz(s,m) \
{ nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \