[OpenAFS-port-darwin] Building on Mavericks

Ken Hornstein kenh@pobox.com
Tue, 19 Nov 2013 13:24:26 -0500


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <96667.1384885310.1@zoolander.cmf.nrl.navy.mil>

>I still have the symlink kernel panics with 10.9 but I have been able
>to successfully build and package using these patches (I am using
>openafs-stable-1_6_5_x branch):

Thanks to the hint from someone who will remain nameless, I figured out
the symlink issue.  When I build with all of Matt's patches and the following
patch, then I can create symlinks fine on Mavericks.  If this works for
people I'll submit it to Gerrit.

--Ken

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <96667.1384885310.2@zoolander.cmf.nrl.navy.mil>
Content-Disposition: attachment; filename="0001-Add-support-for-an-extra-argument-to-afs_symlink-to-.patch"

>From c24278a4e3dee522e3d3d865b375b70f0ea12d26 Mon Sep 17 00:00:00 2001
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
Date: Tue, 19 Nov 2013 13:17:13 -0500
Subject: [PATCH] Add support for an extra argument to afs_symlink() to return
 the newly-created symlink vnode if requested (this is
 needed on OS X Mavericks).

On OS X Mavericks return the symlink vnode in the symlink vnops functions,
on all other platforms ignore it.
---
 src/afs/AIX/osi_vnodeops.c       |    2 +-
 src/afs/DARWIN/osi_vnodeops.c    |   20 +++++++++++++++++---
 src/afs/FBSD/osi_vnodeops.c      |    3 ++-
 src/afs/HPUX/osi_vnodeops.c      |    2 +-
 src/afs/LINUX/osi_vnodeops.c     |    3 ++-
 src/afs/LINUX24/osi_vnodeops.c   |    3 ++-
 src/afs/NBSD/osi_vnodeops.c      |    2 +-
 src/afs/OBSD/osi_vnodeops.c      |    3 ++-
 src/afs/SOLARIS/osi_vnodeops.c   |    2 +-
 src/afs/UKERNEL/afs_usrops.c     |    3 ++-
 src/afs/VNOPS/afs_vnop_symlink.c |    7 +++++--
 src/afs/afs_prototypes.h         |    2 +-
 12 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/src/afs/AIX/osi_vnodeops.c b/src/afs/AIX/osi_vnodeops.c
index 0e40001..b86347e 100644
--- a/src/afs/AIX/osi_vnodeops.c
+++ b/src/afs/AIX/osi_vnodeops.c
@@ -1420,7 +1420,7 @@ afs_gn_symlink(struct vnode *vp,
     AFS_STATCNT(afs_gn_symlink);
     VATTR_NULL(&va);
     va.va_mode = 0777;
-    error = afs_symlink(vp, link, &va, target, cred);
+    error = afs_symlink(vp, link, &va, target, NULL, cred);
     afs_Trace4(afs_iclSetp, CM_TRACE_GSYMLINK, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_STRING, link, ICL_TYPE_STRING, target, ICL_TYPE_LONG,
 	       error);
diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c
index 1b2156f..f1996ca 100644
--- a/src/afs/DARWIN/osi_vnodeops.c
+++ b/src/afs/DARWIN/osi_vnodeops.c
@@ -1655,19 +1655,33 @@ afs_vop_symlink(ap)
 				 * } */ *ap;
 {
     struct vnode *dvp = ap->a_dvp;
+    struct vcache *vpp = NULL;
     int error = 0;
-    /* NFS ignores a_vpp; so do we. */
 
     GETNAME();
     AFS_GLOCK();
     error =
-	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, vop_cn_cred);
+#ifdef AFS_DARWIN130_ENV
+	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, &vpp,
+		    vop_cn_cred);
+#else
+	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, NULL,
+		    vop_cn_cred);
+#endif
     AFS_GUNLOCK();
-    DROPNAME();
 #ifndef AFS_DARWIN80_ENV
     FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
     vput(dvp);
 #endif
+#ifdef AFS_DARWIN130_ENV
+    *ap->a_vpp = NULL;
+    if (!error && vpp) {
+    	error = afs_darwin_finalizevnode(vpp, dvp, ap->a_cnp, 0, 0);
+	if (! error)
+	    *ap->a_vpp = AFSTOV(vpp);
+    }
+#endif
+    DROPNAME();
     return error;
 }
 
diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c
index 01498fa..fc8e41b 100644
--- a/src/afs/FBSD/osi_vnodeops.c
+++ b/src/afs/FBSD/osi_vnodeops.c
@@ -1368,7 +1368,8 @@ afs_vop_symlink(struct vop_symlink_args *ap)
     newvp = NULL;
 
     error =
-	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred);
+	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, NULL,
+		    cnp->cn_cred);
     if (error == 0) {
 	error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
 	if (error == 0) {
diff --git a/src/afs/HPUX/osi_vnodeops.c b/src/afs/HPUX/osi_vnodeops.c
index a9114ef..dab15db 100644
--- a/src/afs/HPUX/osi_vnodeops.c
+++ b/src/afs/HPUX/osi_vnodeops.c
@@ -502,7 +502,7 @@ mp_afs_symlink(struct vnode *adp, char *aname, struct vattr *attrs,
     int code;
 
     AFS_GLOCK();
-    code = afs_symlink(adp, aname, attrs, atargetName, acred);
+    code = afs_symlink(adp, aname, attrs, atargetName, NULL, acred);
     AFS_GUNLOCK();
     return (code);
 }
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index 78b98ba..3a2a67f 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -1574,7 +1574,8 @@ afs_linux_symlink(struct inode *dip, struct dentry *dp, const char *target)
 
     VATTR_NULL(&vattr);
     AFS_GLOCK();
-    code = afs_symlink(VTOAFS(dip), (char *)name, &vattr, (char *)target, credp);
+    code = afs_symlink(VTOAFS(dip), (char *)name, &vattr, (char *)target, NULL,
+    		       credp);
     AFS_GUNLOCK();
     crfree(credp);
     return afs_convert_code(code);
diff --git a/src/afs/LINUX24/osi_vnodeops.c b/src/afs/LINUX24/osi_vnodeops.c
index 6c0589b..c9af3bb 100644
--- a/src/afs/LINUX24/osi_vnodeops.c
+++ b/src/afs/LINUX24/osi_vnodeops.c
@@ -1447,7 +1447,8 @@ afs_linux_symlink(struct inode *dip, struct dentry *dp, const char *target)
 
     VATTR_NULL(&vattr);
     AFS_GLOCK();
-    code = afs_symlink(VTOAFS(dip), (char *)name, &vattr, (char *)target, credp);
+    code = afs_symlink(VTOAFS(dip), (char *)name, &vattr, (char *)target, NULL,
+    		       credp);
     AFS_GUNLOCK();
     crfree(credp);
     return afs_convert_code(code);
diff --git a/src/afs/NBSD/osi_vnodeops.c b/src/afs/NBSD/osi_vnodeops.c
index 56c42a3..48e29f0 100644
--- a/src/afs/NBSD/osi_vnodeops.c
+++ b/src/afs/NBSD/osi_vnodeops.c
@@ -852,7 +852,7 @@ afs_nbsd_symlink(void *v)
     GETNAME();
     AFS_GLOCK();
     code =
-	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
+	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, NULL,
 		    cnp->cn_cred);
     AFS_GUNLOCK();
     DROPCNP(cnp);
diff --git a/src/afs/OBSD/osi_vnodeops.c b/src/afs/OBSD/osi_vnodeops.c
index 9bf045d..141c881 100644
--- a/src/afs/OBSD/osi_vnodeops.c
+++ b/src/afs/OBSD/osi_vnodeops.c
@@ -847,7 +847,8 @@ afs_obsd_symlink(void *v)
     GETNAME();
     AFS_GLOCK();
     code =
-	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred);
+	afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, NULL,
+		    cnp->cn_cred);
     AFS_GUNLOCK();
     DROPCNP(cnp);
     DROPNAME();
diff --git a/src/afs/SOLARIS/osi_vnodeops.c b/src/afs/SOLARIS/osi_vnodeops.c
index f810c6d..ff1e124 100644
--- a/src/afs/SOLARIS/osi_vnodeops.c
+++ b/src/afs/SOLARIS/osi_vnodeops.c
@@ -1771,7 +1771,7 @@ gafs_symlink(struct vcache *adp, char *aname, struct vattr *attrs,
     int code;
 
     AFS_GLOCK();
-    code = afs_symlink(adp, aname, attrs, atargetName, acred);
+    code = afs_symlink(adp, aname, attrs, atargetName, NULL, acred);
     AFS_GUNLOCK();
     return (code);
 }
diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c
index a4a0fdb..a9825e8 100644
--- a/src/afs/UKERNEL/afs_usrops.c
+++ b/src/afs/UKERNEL/afs_usrops.c
@@ -3043,7 +3043,8 @@ uafs_symlink_r(char *target, char *source)
     attrs.va_mode = 0777;
     attrs.va_uid = afs_cr_uid(get_user_struct()->u_cred);
     attrs.va_gid = afs_cr_gid(get_user_struct()->u_cred);
-    code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, get_user_struct()->u_cred);
+    code = afs_symlink(VTOAFS(dirP), nameP, &attrs, target, NULL,
+    		       get_user_struct()->u_cred);
     VN_RELE(dirP);
     if (code != 0) {
 	errno = code;
diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c
index faf103e..95f6973 100644
--- a/src/afs/VNOPS/afs_vnop_symlink.c
+++ b/src/afs/VNOPS/afs_vnop_symlink.c
@@ -66,7 +66,7 @@ afs_DisconCreateSymlink(struct vcache *avc, char *aname,
 /* don't set CDirty in here because RPC is called synchronously */
 int 
 afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, 
-	    char *atargetName, afs_ucred_t *acred)
+	    char *atargetName, struct vcache **tvcp, afs_ucred_t *acred)
 {
     afs_uint32 now = 0;
     struct vrequest treq;
@@ -284,7 +284,10 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     }
     ReleaseWriteLock(&tvc->lock);
     ReleaseWriteLock(&afs_xvcache);
-    afs_PutVCache(tvc);
+    if (tvcp)
+    	*tvcp = tvc;
+    else
+	afs_PutVCache(tvc);
     code = 0;
   done:
     afs_PutFakeStat(&fakestate);
diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h
index 8b0be90..746b466 100644
--- a/src/afs/afs_prototypes.h
+++ b/src/afs/afs_prototypes.h
@@ -1295,7 +1295,7 @@ extern int afs_UFSHandleLink(struct vcache *avc,
 			     struct vrequest *areq);
 extern int afs_symlink(OSI_VC_DECL(adp), char *aname,
 		       struct vattr *attrs, char *atargetName,
-		       afs_ucred_t *acred);
+		       struct vcache **tvcp, afs_ucred_t *acred);
 extern int afs_readlink(OSI_VC_DECL(avc), struct uio *auio,
 			afs_ucred_t *acred);
 
-- 
1.7.7.4


------- =_aaaaaaaaaa0--