]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfsm_subs.h
xnu-517.12.7.tar.gz
[apple/xnu.git] / bsd / nfs / nfsm_subs.h
index 75f019ce0e5a051113765a4ffbb49a53aec77425..cc1ac71b2ddecead02d11ba9dd3dfb4dd3032858 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -63,7 +63,9 @@
 #ifndef _NFS_NFSM_SUBS_H_
 #define _NFS_NFSM_SUBS_H_
 
+#include <sys/appleapiopts.h>
 
+#ifdef __APPLE_API_PRIVATE
 /*
  * These macros do strange and peculiar things to mbuf chains for
  * the assistance of the nfs code. To attempt to use them for any
@@ -170,7 +172,7 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
                }
 
-#define nfsm_mtofh(d, v, v3, f) \
+#define nfsm_mtofh(d, v, v3, f, x) \
                { struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
                if (v3) { \
                        nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
@@ -195,7 +197,7 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                                nfsm_adv(NFSX_V3FATTR); \
                } \
                if (f) \
-                       nfsm_loadattr((v), (struct vattr *)0); \
+                       nfsm_loadattr((v), (struct vattr *)0, (x)); \
                }
 
 #define nfsm_getfh(f, s, v3) \
@@ -211,48 +213,43 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                        (s) = NFSX_V2FH; \
                nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); }
 
-#define        nfsm_loadattr(v, a) \
+#define        nfsm_loadattr(v, a, x) \
                { struct vnode *ttvp = (v); \
-               if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a)))) { \
+               if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a), 0, \
+                                           (x)))) { \
                        error = t1; \
                        m_freem(mrep); \
                        goto nfsmout; \
                } \
                (v) = ttvp; }
 
-#define        nfsm_postop_attr(v, f) \
+#define        nfsm_postop_attr(v, f, x) \
                { struct vnode *ttvp = (v); \
                nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
                if (((f) = fxdr_unsigned(int, *tl))) { \
                        if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
-                               (struct vattr *)0))) { \
+                                       (struct vattr *)0, 1, (x)))) { \
                                error = t1; \
                                (f) = 0; \
                                m_freem(mrep); \
                                goto nfsmout; \
                        } \
+                       if (*(x) == 0) \
+                               (f) = 0; \
                        (v) = ttvp; \
                } }
 
-/* Used as (f) for nfsm_wcc_data() */
-#define NFSV3_WCCRATTR 0
-#define NFSV3_WCCCHK   1
-
-#define        nfsm_wcc_data(v, f) \
-               { int ttattrf, ttretf = 0; \
+#define        nfsm_wcc_data(v, premtime, newpostattr, x) \
+               { \
                nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
                if (*tl == nfs_true) { \
                        nfsm_dissect(tl, u_long *, 6 * NFSX_UNSIGNED); \
-                       if (f) \
-                               ttretf = (VTONFS(v)->n_mtime == \
-                                       fxdr_unsigned(u_long, *(tl + 2))); \
-               } \
-               nfsm_postop_attr((v), ttattrf); \
-               if (f) { \
-                       (f) = ttretf; \
+                       (premtime) = fxdr_unsigned(time_t, *(tl + 2)); \
                } else { \
-                       (f) = ttattrf; \
-               } }
+                       (premtime) = 0; \
+               } \
+               nfsm_postop_attr((v), (newpostattr), (x)); \
+               }
 
 #define nfsm_v3sattr(s, a, u, g) \
                { (s)->sa_modetrue = nfs_true; \
@@ -324,21 +321,21 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
 * m_freem(mrep). Wondering if some of our freeing problems could be
 * due to nfsv3 calling nfsm_reqdone unlike nfsv2. Separate problem.
 */
-#define        nfsm_request(v, t, p, c)        \
+#define        nfsm_request(v, t, p, c, x)     \
                 { \
-                int nfsv3 = (VFSTONFS((v)->v_mount))->nm_flag & NFSMNT_NFSV3; \
+                int nfsv3; \
+               if (!VFSTONFS((v)->v_mount)) { \
+                       error = ENXIO; \
+                       goto nfsmout; \
+               } \
+                nfsv3 = (VFSTONFS((v)->v_mount))->nm_flag & NFSMNT_NFSV3; \
                if ((error = nfs_request((v), mreq, (t), (p), \
-                  (c), &mrep, &md, &dpos))) { \
+                  (c), &mrep, &md, &dpos, (x)))) { \
                        if (error & NFSERR_RETERR) \
                                error &= ~NFSERR_RETERR; \
                        else \
                                goto nfsmout; \
                } \
-                else if ((v)->v_type==VBAD) { \
-                    error = EINVAL; \
-                    if (!nfsv3) \
-                        goto nfsmout; \
-                } \
                 }
 
 #define        nfsm_strtom(a,s,m) \
@@ -373,6 +370,7 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                   (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
                        mrq, &mb, &bpos); \
                m_freem(mrep); \
+               mrep = NULL; \
                mreq = *mrq; \
                if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
                        error == EBADRPC)) \
@@ -438,7 +436,9 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos)
 
 #define nfsm_srvsattr(a) \
-               { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
+               { \
+               struct timeval now; \
+               nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
                if (*tl == nfs_true) { \
                        nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
                        (a)->va_mode = nfstov_mode(*tl); \
@@ -459,14 +459,15 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                        fxdr_hyper(tl, &(a)->va_size); \
                } \
                nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
+               microtime(&now); \
                switch (fxdr_unsigned(int, *tl)) { \
                case NFSV3SATTRTIME_TOCLIENT: \
                        nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); \
                        fxdr_nfsv3time(tl, &(a)->va_atime); \
                        break; \
                case NFSV3SATTRTIME_TOSERVER: \
-                       (a)->va_atime.tv_sec = time.tv_sec; \
-                       (a)->va_atime.tv_nsec = time.tv_usec * 1000; \
+                       (a)->va_atime.tv_sec = now.tv_sec; \
+                       (a)->va_atime.tv_nsec = now.tv_usec * 1000; \
                        break; \
                }; \
                nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); \
@@ -476,9 +477,10 @@ struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
                        fxdr_nfsv3time(tl, &(a)->va_mtime); \
                        break; \
                case NFSV3SATTRTIME_TOSERVER: \
-                       (a)->va_mtime.tv_sec = time.tv_sec; \
-                       (a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
+                       (a)->va_mtime.tv_sec = now.tv_sec; \
+                       (a)->va_mtime.tv_nsec = now.tv_usec * 1000; \
                        break; \
                }; }
 
-#endif
+#endif /* __APPLE_API_PRIVATE */
+#endif /* _NFS_NFSM_SUBS_H_ */