
---

---


---


diff -puN fs/nfs/client.c~nfs-switch-flavor fs/nfs/client.c
--- linux-2.6.18-rc5/fs/nfs/client.c~nfs-switch-flavor	2006-10-18 23:10:13.000000000 -0400
+++ linux-2.6.18-rc5-andros/fs/nfs/client.c	2006-10-18 23:22:57.000000000 -0400
@@ -1106,6 +1106,33 @@ error:
 	return ERR_PTR(error);
 }
 
+
+ /*
+ * Switch security flavors.
+ */
+int nfs4_clnt_switch_flavor(struct rpc_clnt *clnt, rpc_authflavor_t flavor, struct rpc_cred **cred)
+{
+	struct rpc_auth *auth;
+
+	auth = rpcauth_create(flavor, clnt);
+	if (IS_ERR(auth))
+		goto out_err;
+
+	if (cred && *cred) {
+		struct rpc_cred *local;
+		put_rpccred(*cred);
+		local = rpcauth_lookupcred(clnt->cl_auth, 0);
+		*cred = local;
+	}
+
+	dprintk("NFS: switch to flavor %d succeeded\n", flavor);
+	return 0;
+out_err:
+	dprintk("%s() switch to flavor %d failed error=%ld\n",
+			__FUNCTION__, flavor, (long)auth);
+	return PTR_ERR(auth);
+}
+
 #endif /* CONFIG_NFS_V4 */
 
 /*
diff -puN fs/nfs/internal.h~nfs-switch-flavor fs/nfs/internal.h
--- linux-2.6.18-rc5/fs/nfs/internal.h~nfs-switch-flavor	2006-10-18 23:10:13.000000000 -0400
+++ linux-2.6.18-rc5-andros/fs/nfs/internal.h	2006-10-18 23:10:13.000000000 -0400
@@ -47,6 +47,10 @@ extern void nfs_free_server(struct nfs_s
 extern struct nfs_server *nfs_clone_server(struct nfs_server *,
 					   struct nfs_fh *,
 					   struct nfs_fattr *);
+extern int nfs4_clnt_switch_flavor(struct rpc_clnt *,
+				   rpc_authflavor_t flavor,
+				   struct rpc_cred **);
+
 #ifdef CONFIG_PROC_FS
 extern int __init nfs_fs_proc_init(void);
 extern void nfs_fs_proc_exit(void);
_
