fs/adfs: factor out object fixups
authorRussell King <rmk+kernel@armlinux.org.uk>
Sun, 24 Mar 2019 12:57:32 +0000 (12:57 +0000)
committerRussell King <rmk+kernel@armlinux.org.uk>
Fri, 31 May 2019 09:30:54 +0000 (10:30 +0100)
Factor out the directory object fixups, which parse the filetype and
optionally apply the filetype suffix to the filename.

Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
fs/adfs/adfs.h
fs/adfs/dir.c
fs/adfs/dir_f.c
fs/adfs/dir_fplus.c

index c76db75f02aab45659a151b7d9b6d908da016963..1097bee65fa9bbc83ab97f92b45c0faa4a3942f2 100644 (file)
@@ -172,6 +172,7 @@ extern const struct dentry_operations adfs_dentry_operations;
 extern const struct adfs_dir_ops adfs_f_dir_ops;
 extern const struct adfs_dir_ops adfs_fplus_dir_ops;
 
+void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj);
 extern int adfs_dir_update(struct super_block *sb, struct object_info *obj,
                           int wait);
 
index be4b4f950500bdff32e5746bc8421707eec6fa3e..03490f16300d46a8ed430492b7bb4c98700ea6f1 100644 (file)
  */
 static DEFINE_RWLOCK(adfs_dir_lock);
 
+void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj)
+{
+       obj->filetype = -1;
+
+       /*
+        * object is a file and is filetyped and timestamped?
+        * RISC OS 12-bit filetype is stored in load_address[19:8]
+        */
+       if ((0 == (obj->attr & ADFS_NDA_DIRECTORY)) &&
+           (0xfff00000 == (0xfff00000 & obj->loadaddr))) {
+               obj->filetype = (__u16) ((0x000fff00 & obj->loadaddr) >> 8);
+
+               /* optionally append the ,xyz hex filetype suffix */
+               if (ADFS_SB(dir->sb)->s_ftsuffix)
+                       obj->name_len +=
+                               append_filetype_suffix(
+                                       &obj->name[obj->name_len],
+                                       obj->filetype);
+       }
+}
+
 static int
 adfs_readdir(struct file *file, struct dir_context *ctx)
 {
index 0fbfd0b04ae09abca52a420f8d6754ce83f1781e..1bab896918ed1d71e26d6cc2cb80a0cf9de25e79 100644 (file)
@@ -216,23 +216,8 @@ adfs_dir2obj(struct adfs_dir *dir, struct object_info *obj,
        obj->execaddr = adfs_readval(de->direxec, 4);
        obj->size     = adfs_readval(de->dirlen,  4);
        obj->attr     = de->newdiratts;
-       obj->filetype = -1;
 
-       /*
-        * object is a file and is filetyped and timestamped?
-        * RISC OS 12-bit filetype is stored in load_address[19:8]
-        */
-       if ((0 == (obj->attr & ADFS_NDA_DIRECTORY)) &&
-               (0xfff00000 == (0xfff00000 & obj->loadaddr))) {
-               obj->filetype = (__u16) ((0x000fff00 & obj->loadaddr) >> 8);
-
-               /* optionally append the ,xyz hex filetype suffix */
-               if (ADFS_SB(dir->sb)->s_ftsuffix)
-                       obj->name_len +=
-                               append_filetype_suffix(
-                                       &obj->name[obj->name_len],
-                                       obj->filetype);
-       }
+       adfs_object_fixup(dir, obj);
 }
 
 /*
index c92cfb638c18324a5c2e7af17cafb7b3db6982a7..308009d00a5b58b8d60b67e4247873eb60e252d4 100644 (file)
@@ -197,23 +197,7 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
                if (obj->name[i] == '/')
                        obj->name[i] = '.';
 
-       obj->filetype = -1;
-
-       /*
-        * object is a file and is filetyped and timestamped?
-        * RISC OS 12-bit filetype is stored in load_address[19:8]
-        */
-       if ((0 == (obj->attr & ADFS_NDA_DIRECTORY)) &&
-               (0xfff00000 == (0xfff00000 & obj->loadaddr))) {
-               obj->filetype = (__u16) ((0x000fff00 & obj->loadaddr) >> 8);
-
-               /* optionally append the ,xyz hex filetype suffix */
-               if (ADFS_SB(dir->sb)->s_ftsuffix)
-                       obj->name_len +=
-                               append_filetype_suffix(
-                                       &obj->name[obj->name_len],
-                                       obj->filetype);
-       }
+       adfs_object_fixup(dir, obj);
 
        dir->pos += 1;
        ret = 0;