BSD 4_3_Reno release
[unix-history] / usr / src / sys / nfs / nfsm_subs.h
index c7db2f2..d0edf1c 100644 (file)
@@ -5,19 +5,22 @@
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution is only permitted until one year after the first shipment
+ * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
+ * binary forms are permitted provided that: (1) source distributions retain
+ * this entire copyright notice and comment, and (2) distributions including
+ * binaries display the following acknowledgement:  This product includes
+ * software developed by the University of California, Berkeley and its
+ * contributors'' in the documentation or other materials provided with the
+ * distribution and in all advertising materials mentioning features or use
+ * of this software.  Neither the name of the University nor the names of
+ * its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  *
- *     @(#)nfsm_subs.h 7.3 (Berkeley) %G%
+ *     @(#)nfsm_subs.h 7.10 (Berkeley) 6/28/90
  */
 
 /*
  */
 
 /*
 /*
  * First define what the actual subs. return
  */
 /*
  * First define what the actual subs. return
  */
-struct mbuf *nfsm_reqh();
-struct vnode *nfs_fhtovp();
+extern struct mbuf *nfsm_reqh();
 
 
-/*
- * To try and deal with different variants of mbuf.h, I have used the
- * following defs. If M_HASCL is not defined in an older the 4.4bsd mbuf.h,
- * you will have to use a different ifdef
- */
-#ifdef M_HASCL
-#define        NFSMCLGET(m, w) MCLGET(m)
-#define        NFSMGETHDR(m)   MGET(m, M_WAIT, MT_DATA)
-#define        MHLEN           MLEN
-#define        NFSMINOFF(m) \
-               if (M_HASCL(m)) \
-                       (m)->m_off = ((int)MTOCL(m))-(int)(m); \
-               else \
-                       (m)->m_off = MMINOFF
-#define        NFSMADV(m, s)   (m)->m_off += (s)
-#define        NFSMSIZ(m)      ((M_HASCL(m))?MCLBYTES:MLEN)
-#define        m_nextpkt       m_act
-#define        NFSMCOPY(m, o, l, w)    m_copy((m), (o), (l))
-#else
 #define        M_HASCL(m)      ((m)->m_flags & M_EXT)
 #define        M_HASCL(m)      ((m)->m_flags & M_EXT)
-#define        NFSMCLGET       MCLGET
 #define        NFSMGETHDR(m) \
                MGETHDR(m, M_WAIT, MT_DATA); \
                (m)->m_pkthdr.len = 0; \
 #define        NFSMGETHDR(m) \
                MGETHDR(m, M_WAIT, MT_DATA); \
                (m)->m_pkthdr.len = 0; \
@@ -65,16 +47,6 @@ struct vnode *nfs_fhtovp();
 #define        NFSMADV(m, s)   (m)->m_data += (s)
 #define        NFSMSIZ(m)      ((M_HASCL(m))?MCLBYTES: \
                                (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
 #define        NFSMADV(m, s)   (m)->m_data += (s)
 #define        NFSMSIZ(m)      ((M_HASCL(m))?MCLBYTES: \
                                (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
-#define        NFSMCOPY        m_copym
-#endif
-
-#ifndef MCLBYTES
-#define        MCLBYTES        CLBYTES
-#endif
-
-#ifndef MT_CONTROL
-#define        MT_CONTROL      MT_RIGHTS
-#endif
 
 /*
  * Now for the macros that do the simple stuff and call the functions
 
 /*
  * Now for the macros that do the simple stuff and call the functions
@@ -89,6 +61,7 @@ struct vnode *nfs_fhtovp();
  * unions.
  */
 
  * unions.
  */
 
+#ifndef lint
 #define        nfsm_build(a,c,s) \
                t1 = NFSMSIZ(mb); \
                if ((s) > (t1-mb->m_len)) { \
 #define        nfsm_build(a,c,s) \
                t1 = NFSMSIZ(mb); \
                if ((s) > (t1-mb->m_len)) { \
@@ -103,6 +76,20 @@ struct vnode *nfs_fhtovp();
                (a) = (c)(bpos); \
                mb->m_len += (s); \
                bpos += (s)
                (a) = (c)(bpos); \
                mb->m_len += (s); \
                bpos += (s)
+#else /* lint */
+#define        nfsm_build(a,c,s) \
+               t1 = NFSMSIZ(mb); \
+               if ((s) > (t1-mb->m_len)) { \
+                       MGET(mb2, M_WAIT, MT_DATA); \
+                       mb->m_next = mb2; \
+                       mb = mb2; \
+                       mb->m_len = 0; \
+                       bpos = mtod(mb, caddr_t); \
+               } \
+               (a) = (c)(bpos); \
+               mb->m_len += (s); \
+               bpos += (s)
+#endif /* lint */
 
 #define        nfsm_disect(a,c,s) \
                t1 = mtod(md, caddr_t)+md->m_len-dpos; \
 
 #define        nfsm_disect(a,c,s) \
                t1 = mtod(md, caddr_t)+md->m_len-dpos; \
@@ -145,14 +132,15 @@ struct vnode *nfs_fhtovp();
                } \
                (v) = NFSTOV(np); \
                nfsm_loadattr(v, (struct vattr *)0); \
                } \
                (v) = NFSTOV(np); \
                nfsm_loadattr(v, (struct vattr *)0); \
-               (v)->v_type = np->n_vattr.va_type; \
                }
 
 #define        nfsm_loadattr(v,a) \
                }
 
 #define        nfsm_loadattr(v,a) \
-               if (error = nfs_loadattrcache(&(v), &md, &dpos, (a))) { \
+               { struct vnode *tvp = (v); \
+               if (error = nfs_loadattrcache(&tvp, &md, &dpos, (a))) { \
                        m_freem(mrep); \
                        goto nfsmout; \
                        m_freem(mrep); \
                        goto nfsmout; \
-               }
+               } \
+               (v) = tvp; }
 
 #define        nfsm_strsiz(s,m) \
                nfsm_disect(p,u_long *,NFSX_UNSIGNED); \
 
 #define        nfsm_strsiz(s,m) \
                nfsm_disect(p,u_long *,NFSX_UNSIGNED); \
@@ -169,13 +157,6 @@ struct vnode *nfs_fhtovp();
                        nfsm_reply(0); \
                }
 
                        nfsm_reply(0); \
                }
 
-#define        nfsm_srvstrsizon(s,m) \
-               nfsm_disecton(p,u_long *,NFSX_UNSIGNED); \
-               if (((s) = fxdr_unsigned(long,*p)) > (m)) { \
-                       error = EBADRPC; \
-                       nfsm_reply(0); \
-               }
-
 #define nfsm_mtouio(p,s) \
                if ((s) > 0 && \
                   (error = nfsm_mbuftouio(&md,(p),(s),&dpos))) { \
 #define nfsm_mtouio(p,s) \
                if ((s) > 0 && \
                   (error = nfsm_mbuftouio(&md,(p),(s),&dpos))) { \
@@ -195,23 +176,13 @@ struct vnode *nfs_fhtovp();
                        goto nfsmout; \
                }
 
                        goto nfsmout; \
                }
 
-#define        nfsm_vars \
-               register u_long *p; \
-               register caddr_t cp; \
-               register long t1, t2; \
-               caddr_t bpos, dpos, cp2; \
-               u_long xid; \
-               int error = 0; \
-               long offs = 0; \
-               struct mbuf *mreq, *mrep, *md, *mb, *mb2
-
 #define nfsm_reqdone   m_freem(mrep); \
                nfsmout: 
 
 #define nfsm_rndup(a)  (((a)+3)&(~0x3))
 
 #define nfsm_reqdone   m_freem(mrep); \
                nfsmout: 
 
 #define nfsm_rndup(a)  (((a)+3)&(~0x3))
 
-#define        nfsm_request(v) \
-               if (error = nfs_request((v), mreq, xid, \
+#define        nfsm_request(v, t, p, h)        \
+               if (error = nfs_request((v), mreq, xid, (t), (p), (h), \
                   (v)->v_mount, &mrep, &md, &dpos)) \
                        goto nfsmout
 
                   (v)->v_mount, &mrep, &md, &dpos)) \
                        goto nfsmout
 
@@ -232,37 +203,38 @@ struct vnode *nfs_fhtovp();
                        goto nfsmout; \
                }
 
                        goto nfsmout; \
                }
 
-#define        nfsm_srverr \
-               { \
-                       m_freem(mrep); \
-                       return(ENOBUFS); \
-               }
-
-#define        nfsm_srvars \
-               register caddr_t cp; \
-               register u_long *p; \
-               register long t1, t2; \
-               caddr_t bpos; \
-               long offs = 0; \
-               int error = 0; \
-               char *cp2; \
-               struct mbuf *mb, *mb2, *mreq
-
 #define        nfsm_srvdone \
                nfsmout: \
                return(error)
 
 #define        nfsm_srvdone \
                nfsmout: \
                return(error)
 
+#ifndef lint
+#define        nfsm_reply(s) \
+               { \
+               *repstat = error; \
+               if (error) \
+                       nfs_rephead(0, xid, error, mrq, &mb, &bpos); \
+               else \
+                       nfs_rephead((s), xid, error, mrq, &mb, &bpos); \
+               m_freem(mrep); \
+               mreq = *mrq; \
+               if (error) \
+                       return(0); \
+               }
+#else  /* lint */
 #define        nfsm_reply(s) \
                { \
 #define        nfsm_reply(s) \
                { \
+               *repstat = error; \
                if (error) \
                        nfs_rephead(0, xid, error, mrq, &mb, &bpos); \
                else \
                        nfs_rephead((s), xid, error, mrq, &mb, &bpos); \
                m_freem(mrep); \
                mreq = *mrq; \
                if (error) \
                        nfs_rephead(0, xid, error, mrq, &mb, &bpos); \
                else \
                        nfs_rephead((s), xid, error, mrq, &mb, &bpos); \
                m_freem(mrep); \
                mreq = *mrq; \
+               mrep = mreq; \
                if (error) \
                        return(0); \
                }
                if (error) \
                        return(0); \
                }
+#endif /* lint */
 
 #define        nfsm_adv(s) \
                t1 = mtod(md, caddr_t)+md->m_len-dpos; \
 
 #define        nfsm_adv(s) \
                t1 = mtod(md, caddr_t)+md->m_len-dpos; \
@@ -280,7 +252,7 @@ struct vnode *nfs_fhtovp();
 #define        nfsm_clget \
                if (bp >= be) { \
                        MGET(mp, M_WAIT, MT_DATA); \
 #define        nfsm_clget \
                if (bp >= be) { \
                        MGET(mp, M_WAIT, MT_DATA); \
-                       NFSMCLGET(mp, M_WAIT); \
+                       MCLGET(mp, M_WAIT); \
                        mp->m_len = NFSMSIZ(mp); \
                        if (mp3 == NULL) \
                                mp3 = mp2 = mp; \
                        mp->m_len = NFSMSIZ(mp); \
                        if (mp3 == NULL) \
                                mp3 = mp2 = mp; \
@@ -293,3 +265,24 @@ struct vnode *nfs_fhtovp();
                } \
                p = (u_long *)bp
 
                } \
                p = (u_long *)bp
 
+#define        nfsm_srvfillattr \
+       fp->fa_type = vtonfs_type(vap->va_type); \
+       fp->fa_mode = vtonfs_mode(vap->va_type, vap->va_mode); \
+       fp->fa_nlink = txdr_unsigned(vap->va_nlink); \
+       fp->fa_uid = txdr_unsigned(vap->va_uid); \
+       fp->fa_gid = txdr_unsigned(vap->va_gid); \
+       fp->fa_size = txdr_unsigned(vap->va_size); \
+       fp->fa_blocksize = txdr_unsigned(vap->va_blocksize); \
+       if (vap->va_type == VFIFO) \
+               fp->fa_rdev = 0xffffffff; \
+       else \
+               fp->fa_rdev = txdr_unsigned(vap->va_rdev); \
+       fp->fa_blocks = txdr_unsigned(vap->va_bytes / NFS_FABLKSIZE); \
+       fp->fa_fsid = txdr_unsigned(vap->va_fsid); \
+       fp->fa_fileid = txdr_unsigned(vap->va_fileid); \
+       fp->fa_atime.tv_sec = txdr_unsigned(vap->va_atime.tv_sec); \
+       fp->fa_atime.tv_usec = txdr_unsigned(vap->va_flags); \
+       txdr_time(&vap->va_mtime, &fp->fa_mtime); \
+       fp->fa_ctime.tv_sec = txdr_unsigned(vap->va_ctime.tv_sec); \
+       fp->fa_ctime.tv_usec = txdr_unsigned(vap->va_gen)
+