Linux: Rework handling of names in the lookup functions
authorMarc Dionne <marc.c.dionne@gmail.com>
Sat, 20 Oct 2012 16:59:01 +0000 (17:59 +0100)
committerDerrick Brashear <shadow@your-file-system.com>
Sat, 20 Oct 2012 18:39:47 +0000 (11:39 -0700)
Rework the name lookup functions in the kernel to deal more cleanly
with the change of API for kernel 3.7

Change-Id: I1de9e02cfedbbeee31e2793c443722d4eed57705
Reviewed-on: http://gerrit.openafs.org/8278
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_misc.c

index 68604b7..1c822f9 100644 (file)
@@ -524,14 +524,40 @@ afs_dentry_open(struct dentry *dp, struct vfsmount *mnt, int flags, const struct
 }
 #endif
 
-static inline void
 #if defined(HAVE_LINUX_PUTNAME)
-afs_putname(char *name) {
-    putname(name);
+typedef char *afs_name_t;
+
+static inline char *
+afs_name_to_string(afs_name_t s) {
+    return (char *)s;
+}
+
+static inline void
+afs_putname(afs_name_t name) {
+    putname((char *)name);
+}
+
+static inline void
+afs_set_name(afs_name_t name, char *string) {
+    name = string;
+}
 #else
-afs_putname(struct filename *name) {
+typedef struct filename *afs_name_t;
+
+static inline char *
+afs_name_to_string(afs_name_t s) {
+    return (char *)s->name;
+}
+
+static inline void
+afs_putname(afs_name_t name) {
     kmem_cache_free(names_cachep, (void *)name);
-#endif
 }
 
+static inline void
+afs_set_name(afs_name_t aname, char *string) {
+    aname->name = string;
+}
+#endif
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
index 0fe7484..879f7a1 100644 (file)
@@ -78,22 +78,25 @@ osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt,
 }
 
 int
-osi_lookupname(char *aname, uio_seg_t seg, int followlink, 
+osi_lookupname(char *aname, uio_seg_t seg, int followlink,
               struct dentry **dpp)
 {
     int code;
-    char *tname;
+    afs_name_t tname = NULL;
+    char *name;
+
     code = ENOENT;
     if (seg == AFS_UIOUSER) {
-        tname = getname(aname);
-        if (IS_ERR(tname)) 
-            return PTR_ERR(tname);
+       tname = getname(aname);
+       if (IS_ERR(tname))
+           return PTR_ERR(tname);
+       name = afs_name_to_string(tname);
     } else {
-        tname = aname;
+       name = aname;
     }
-    code = osi_lookupname_internal(tname, followlink, NULL, dpp);   
+    code = osi_lookupname_internal(name, followlink, NULL, dpp);
     if (seg == AFS_UIOUSER) {
-        afs_putname(tname);
+       afs_putname(tname);
     }
     return code;
 }
@@ -103,14 +106,15 @@ int osi_abspath(char *aname, char *buf, int buflen,
 {
     struct dentry *dp = NULL;
     struct vfsmount *mnt = NULL;
-    char *tname, *path;
+    afs_name_t tname;
+    char *path;
     int code;
 
     code = ENOENT;
     tname = getname(aname);
-    if (IS_ERR(tname)) 
+    if (IS_ERR(tname))
        return -PTR_ERR(tname);
-    code = osi_lookupname_internal(tname, followlink, &mnt, &dp);   
+    code = osi_lookupname_internal(afs_name_to_string(tname), followlink, &mnt, &dp);
     if (!code) {
 #if defined(D_PATH_TAKES_STRUCT_PATH)
        afs_linux_path_t p = { mnt, dp };