]> Git Repo - J-linux.git/commitdiff
Merge branch 'work.adfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <[email protected]>
Fri, 19 Jul 2019 18:33:22 +0000 (11:33 -0700)
committerLinus Torvalds <[email protected]>
Fri, 19 Jul 2019 18:33:22 +0000 (11:33 -0700)
Pull adfs updates from Al Viro:
 "More ADFS patches from Russell King"

* 'work.adfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs/adfs: add time stamp and file type helpers
  fs/adfs: super: limit idlen according to directory type
  fs/adfs: super: fix use-after-free bug
  fs/adfs: super: safely update options on remount
  fs/adfs: super: correct superblock flags
  fs/adfs: clean up indirect disc addresses and fragment IDs
  fs/adfs: clean up error message printing
  fs/adfs: use %pV for error messages
  fs/adfs: use format_version from disc_record
  fs/adfs: add helper to get filesystem size
  fs/adfs: add helper to get discrecord from map
  fs/adfs: correct disc record structure

1  2 
fs/adfs/dir.c
fs/adfs/dir_f.c
fs/adfs/dir_fplus.c
fs/adfs/inode.c
fs/adfs/map.c
fs/adfs/super.c

diff --combined fs/adfs/dir.c
index 35a4d9f4c3ae255b4ab2e17acf3a16b6b1cab879,77503d12f7eec93e6e8753808f9bd682957e21a9..a54c53244992f67f60735d4313ca57564b40855c
@@@ -1,9 -1,12 +1,9 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/dir.c
   *
   *  Copyright (C) 1999-2000 Russell King
   *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
 - *
   *  Common directory handling for ADFS
   */
  #include "adfs.h"
@@@ -35,20 -38,14 +35,14 @@@ void adfs_object_fixup(struct adfs_dir 
        if (obj->name_len <= 2 && dots == obj->name_len)
                obj->name[0] = '^';
  
-       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 the object is a file, and the user requested the ,xyz hex
+        * filetype suffix to the name, check the filetype and append.
         */
-       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) {
-                       __u16 filetype = obj->filetype;
+       if (!(obj->attr & ADFS_NDA_DIRECTORY) && ADFS_SB(dir->sb)->s_ftsuffix) {
+               u16 filetype = adfs_filetype(obj->loadaddr);
  
+               if (filetype != ADFS_FILETYPE_NONE) {
                        obj->name[obj->name_len++] = ',';
                        obj->name[obj->name_len++] = hex_asc_lo(filetype >> 8);
                        obj->name[obj->name_len++] = hex_asc_lo(filetype >> 4);
@@@ -92,7 -89,7 +86,7 @@@ adfs_readdir(struct file *file, struct 
                goto unlock_out;
        while (ops->getnext(&dir, &obj) == 0) {
                if (!dir_emit(ctx, obj.name, obj.name_len,
-                           obj.file_id, DT_UNKNOWN))
+                             obj.indaddr, DT_UNKNOWN))
                        break;
                ctx->pos++;
        }
@@@ -113,8 -110,8 +107,8 @@@ adfs_dir_update(struct super_block *sb
        const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
        struct adfs_dir dir;
  
-       printk(KERN_INFO "adfs_dir_update: object %06X in dir %06X\n",
-                obj->file_id, obj->parent_id);
+       printk(KERN_INFO "adfs_dir_update: object %06x in dir %06x\n",
+                obj->indaddr, obj->parent_id);
  
        if (!ops->update) {
                ret = -EINVAL;
@@@ -178,7 -175,8 +172,8 @@@ static int adfs_dir_lookup_byname(struc
                goto out;
  
        if (ADFS_I(inode)->parent_id != dir.parent_id) {
-               adfs_error(sb, "parent directory changed under me! (%lx but got %x)\n",
+               adfs_error(sb,
+                          "parent directory changed under me! (%06x but got %06x)\n",
                           ADFS_I(inode)->parent_id, dir.parent_id);
                ret = -EIO;
                goto free_out;
diff --combined fs/adfs/dir_f.c
index 7557378e58b330b2b285314263e6403f79921b9e,67afb3808e43ab08fa89f88fa854ea5af0cb54e0..c1a950c7400a6b21f4b84a40df9077f34b27067b
@@@ -1,12 -1,14 +1,11 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/dir_f.c
   *
   * Copyright (C) 1997-1999 Russell King
   *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
 - *
   *  E and F format directory handling
   */
- #include <linux/buffer_head.h>
  #include "adfs.h"
  #include "dir_f.h"
  
@@@ -124,12 -126,9 +123,9 @@@ adfs_dir_checkbyte(const struct adfs_di
        return (dircheck ^ (dircheck >> 8) ^ (dircheck >> 16) ^ (dircheck >> 24)) & 0xff;
  }
  
- /*
-  * Read and check that a directory is valid
-  */
- static int
- adfs_dir_read(struct super_block *sb, unsigned long object_id,
-             unsigned int size, struct adfs_dir *dir)
+ /* Read and check that a directory is valid */
+ static int adfs_dir_read(struct super_block *sb, u32 indaddr,
+                        unsigned int size, struct adfs_dir *dir)
  {
        const unsigned int blocksize_bits = sb->s_blocksize_bits;
        int blk = 0;
        for (blk = 0; blk < size; blk++) {
                int phys;
  
-               phys = __adfs_block_map(sb, object_id, blk);
+               phys = __adfs_block_map(sb, indaddr, blk);
                if (!phys) {
-                       adfs_error(sb, "dir object %lX has a hole at offset %d",
-                                  object_id, blk);
+                       adfs_error(sb, "dir %06x has a hole at offset %d",
+                                  indaddr, blk);
                        goto release_buffers;
                }
  
        return 0;
  
  bad_dir:
-       adfs_error(sb, "corrupted directory fragment %lX",
-                  object_id);
+       adfs_error(sb, "dir %06x is corrupted", indaddr);
  release_buffers:
        for (blk -= 1; blk >= 0; blk -= 1)
                brelse(dir->bh[blk]);
@@@ -208,7 -206,7 +203,7 @@@ adfs_dir2obj(struct adfs_dir *dir, stru
        }
  
        obj->name_len = name_len;
-       obj->file_id  = adfs_readval(de->dirinddiscadd, 3);
+       obj->indaddr  = adfs_readval(de->dirinddiscadd, 3);
        obj->loadaddr = adfs_readval(de->dirload, 4);
        obj->execaddr = adfs_readval(de->direxec, 4);
        obj->size     = adfs_readval(de->dirlen,  4);
  static inline void
  adfs_obj2dir(struct adfs_direntry *de, struct object_info *obj)
  {
-       adfs_writeval(de->dirinddiscadd, 3, obj->file_id);
+       adfs_writeval(de->dirinddiscadd, 3, obj->indaddr);
        adfs_writeval(de->dirload, 4, obj->loadaddr);
        adfs_writeval(de->direxec, 4, obj->execaddr);
        adfs_writeval(de->dirlen,  4, obj->size);
@@@ -309,8 -307,7 +304,7 @@@ __adfs_dir_put(struct adfs_dir *dir, in
   * the caller is responsible for holding the necessary
   * locks.
   */
- static int
- adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
+ static int adfs_dir_find_entry(struct adfs_dir *dir, u32 indaddr)
  {
        int pos, ret;
  
                if (!__adfs_dir_get(dir, pos, &obj))
                        break;
  
-               if (obj.file_id == object_id) {
+               if (obj.indaddr == indaddr) {
                        ret = pos;
                        break;
                }
        return ret;
  }
  
- static int
adfs_f_read(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir)
+ static int adfs_f_read(struct super_block *sb, u32 indaddr, unsigned int size,
                     struct adfs_dir *dir)
  {
        int ret;
  
-       if (sz != ADFS_NEWDIR_SIZE)
+       if (size != ADFS_NEWDIR_SIZE)
                return -EIO;
  
-       ret = adfs_dir_read(sb, id, sz, dir);
+       ret = adfs_dir_read(sb, indaddr, size, dir);
        if (ret)
                adfs_error(sb, "unable to read directory");
        else
@@@ -376,7 -373,7 +370,7 @@@ adfs_f_update(struct adfs_dir *dir, str
        struct super_block *sb = dir->sb;
        int ret, i;
  
-       ret = adfs_dir_find_entry(dir, obj->file_id);
+       ret = adfs_dir_find_entry(dir, obj->indaddr);
        if (ret < 0) {
                adfs_error(dir->sb, "unable to locate entry to update");
                goto out;
diff --combined fs/adfs/dir_fplus.c
index 6c5fbb0259c9295315f2bf97513b50573d390c5d,973282fc47587634574691ede4e371a6d9e49923..d56924c11b17f0f61f5d7ef1825db7c63a024529
@@@ -1,10 -1,12 +1,9 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/dir_fplus.c
   *
   *  Copyright (C) 1997-1999 Russell King
 - *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
   */
- #include <linux/buffer_head.h>
  #include <linux/slab.h>
  #include "adfs.h"
  #include "dir_fplus.h"
@@@ -37,17 -39,15 +36,15 @@@ adfs_fplus_read(struct super_block *sb
        h = (struct adfs_bigdirheader *)dir->bh_fplus[0]->b_data;
        size = le32_to_cpu(h->bigdirsize);
        if (size != sz) {
-               printk(KERN_WARNING "adfs: adfs_fplus_read:"
-                                       " directory header size %X\n"
-                                       " does not match directory size %X\n",
-                                       size, sz);
+               adfs_msg(sb, KERN_WARNING,
+                        "directory header size %X does not match directory size %X",
+                        size, sz);
        }
  
        if (h->bigdirversion[0] != 0 || h->bigdirversion[1] != 0 ||
            h->bigdirversion[2] != 0 || size & 2047 ||
            h->bigdirstartname != cpu_to_le32(BIGDIRSTARTNAME)) {
-               printk(KERN_WARNING "adfs: dir object %X has"
-                                       " malformed dir header\n", id);
+               adfs_error(sb, "dir %06x has malformed header", id);
                goto out;
        }
  
                        kcalloc(size, sizeof(struct buffer_head *),
                                GFP_KERNEL);
                if (!bh_fplus) {
+                       adfs_msg(sb, KERN_ERR,
+                                "not enough memory for dir object %X (%d blocks)",
+                                id, size);
                        ret = -ENOMEM;
-                       adfs_error(sb, "not enough memory for"
-                                       " dir object %X (%d blocks)", id, size);
                        goto out;
                }
                dir->bh_fplus = bh_fplus;
@@@ -91,8 -92,7 +89,7 @@@
        if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) ||
            t->bigdirendmasseq != h->startmasseq ||
            t->reserved[0] != 0 || t->reserved[1] != 0) {
-               printk(KERN_WARNING "adfs: dir object %X has "
-                                       "malformed dir end\n", id);
+               adfs_error(sb, "dir %06x has malformed tail", id);
                goto out;
        }
  
@@@ -180,7 -180,7 +177,7 @@@ adfs_fplus_getnext(struct adfs_dir *dir
        obj->loadaddr = le32_to_cpu(bde.bigdirload);
        obj->execaddr = le32_to_cpu(bde.bigdirexec);
        obj->size     = le32_to_cpu(bde.bigdirlen);
-       obj->file_id  = le32_to_cpu(bde.bigdirindaddr);
+       obj->indaddr  = le32_to_cpu(bde.bigdirindaddr);
        obj->attr     = le32_to_cpu(bde.bigdirattr);
        obj->name_len = le32_to_cpu(bde.bigdirobnamelen);
  
diff --combined fs/adfs/inode.c
index 904d624541ad0e73564347fe5e1812068e1e255d,d61c7453a4c32e08b0584997be39d0a1844a4b51..124de75413a5ded884c49b93b26880136d1f84ef
@@@ -1,8 -1,11 +1,8 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/inode.c
   *
   *  Copyright (C) 1997-1999 Russell King
 - *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
   */
  #include <linux/buffer_head.h>
  #include <linux/writeback.h>
@@@ -94,7 -97,7 +94,7 @@@ adfs_atts2mode(struct super_block *sb, 
                return S_IFDIR | S_IXUGO | mode;
        }
  
-       switch (ADFS_I(inode)->filetype) {
+       switch (adfs_filetype(ADFS_I(inode)->loadaddr)) {
        case 0xfc0:     /* LinkFS */
                return S_IFLNK|S_IRWXUGO;
  
@@@ -174,7 -177,7 +174,7 @@@ adfs_adfs2unix_time(struct timespec64 *
                                                        2208988800000000000LL;
        s64 nsec;
  
-       if (ADFS_I(inode)->stamped == 0)
+       if (!adfs_inode_is_stamped(inode))
                goto cur_time;
  
        high = ADFS_I(inode)->loadaddr & 0xFF; /* top 8 bits of timestamp */
@@@ -213,7 -216,7 +213,7 @@@ adfs_unix2adfs_time(struct inode *inode
  {
        unsigned int high, low;
  
-       if (ADFS_I(inode)->stamped) {
+       if (adfs_inode_is_stamped(inode)) {
                /* convert 32-bit seconds to 40-bit centi-seconds */
                low  = (secs & 255) * 100;
                high = (secs / 256) * 100 + (low >> 8) + 0x336e996a;
@@@ -247,7 -250,7 +247,7 @@@ adfs_iget(struct super_block *sb, struc
  
        inode->i_uid     = ADFS_SB(sb)->s_uid;
        inode->i_gid     = ADFS_SB(sb)->s_gid;
-       inode->i_ino     = obj->file_id;
+       inode->i_ino     = obj->indaddr;
        inode->i_size    = obj->size;
        set_nlink(inode, 2);
        inode->i_blocks  = (inode->i_size + sb->s_blocksize - 1) >>
        ADFS_I(inode)->loadaddr  = obj->loadaddr;
        ADFS_I(inode)->execaddr  = obj->execaddr;
        ADFS_I(inode)->attr      = obj->attr;
-       ADFS_I(inode)->filetype  = obj->filetype;
-       ADFS_I(inode)->stamped   = ((obj->loadaddr & 0xfff00000) == 0xfff00000);
  
        inode->i_mode    = adfs_atts2mode(sb, inode);
        adfs_adfs2unix_time(&inode->i_mtime, inode);
@@@ -355,7 -356,7 +353,7 @@@ int adfs_write_inode(struct inode *inod
        struct object_info obj;
        int ret;
  
-       obj.file_id     = inode->i_ino;
+       obj.indaddr     = inode->i_ino;
        obj.name_len    = 0;
        obj.parent_id   = ADFS_I(inode)->parent_id;
        obj.loadaddr    = ADFS_I(inode)->loadaddr;
diff --combined fs/adfs/map.c
index 4d34338c61764c49e032b145ad72406d41e04598,e8f70f7c384eb878225e40ecd47cd22fa97b58ef..f44d12cef5be1012701daefaf0603806b7813d95
@@@ -1,10 -1,12 +1,9 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/map.c
   *
   *  Copyright (C) 1997-2002 Russell King
 - *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
   */
- #include <linux/buffer_head.h>
  #include <asm/unaligned.h>
  #include "adfs.h"
  
@@@ -64,9 -66,8 +63,8 @@@ static DEFINE_RWLOCK(adfs_map_lock)
   * output of:
   *  gcc -D__KERNEL__ -O2 -I../../include -o - -S map.c
   */
- static int
- lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
-           const unsigned int frag_id, unsigned int *offset)
+ static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
+                      const u32 frag_id, unsigned int *offset)
  {
        const unsigned int mapsize = dm->dm_endbit;
        const u32 idmask = (1 << idlen) - 1;
@@@ -185,9 -186,8 +183,8 @@@ error
        return 0;
  }
  
- static int
- scan_map(struct adfs_sb_info *asb, unsigned int zone,
-        const unsigned int frag_id, unsigned int mapoff)
+ static int scan_map(struct adfs_sb_info *asb, unsigned int zone,
+                   const u32 frag_id, unsigned int mapoff)
  {
        const unsigned int idlen = asb->s_idlen;
        struct adfs_discmap *dm, *dm_end;
@@@ -241,9 -241,7 +238,7 @@@ adfs_map_free(struct super_block *sb
        return signed_asl(total, asb->s_map2blk);
  }
  
- int
- adfs_map_lookup(struct super_block *sb, unsigned int frag_id,
-               unsigned int offset)
+ int adfs_map_lookup(struct super_block *sb, u32 frag_id, unsigned int offset)
  {
        struct adfs_sb_info *asb = ADFS_SB(sb);
        unsigned int zone, mapoff;
diff --combined fs/adfs/super.c
index ffb669f9bba78a76cfedce50b2029d95e88299f0,89b159c02b516623b9c066dcd9b387e06f26d2db..65b04ebb51c30525b8623b15e8bab3b8b71388a8
@@@ -1,12 -1,14 +1,11 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  linux/fs/adfs/super.c
   *
   *  Copyright (C) 1997-1999 Russell King
 - *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License version 2 as
 - * published by the Free Software Foundation.
   */
  #include <linux/module.h>
  #include <linux/init.h>
- #include <linux/buffer_head.h>
  #include <linux/parser.h>
  #include <linux/mount.h>
  #include <linux/seq_file.h>
  #include "dir_f.h"
  #include "dir_fplus.h"
  
+ #define ADFS_SB_FLAGS SB_NOATIME
  #define ADFS_DEFAULT_OWNER_MASK S_IRWXU
  #define ADFS_DEFAULT_OTHER_MASK (S_IRWXG | S_IRWXO)
  
  void __adfs_error(struct super_block *sb, const char *function, const char *fmt, ...)
  {
-       char error_buf[128];
+       struct va_format vaf;
        va_list args;
  
        va_start(args, fmt);
-       vsnprintf(error_buf, sizeof(error_buf), fmt, args);
-       va_end(args);
+       vaf.fmt = fmt;
+       vaf.va = &args;
  
-       printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n",
+       printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %pV\n",
                sb->s_id, function ? ": " : "",
-               function ? function : "", error_buf);
+               function ? function : "", &vaf);
+       va_end(args);
+ }
+ void adfs_msg(struct super_block *sb, const char *pfx, const char *fmt, ...)
+ {
+       struct va_format vaf;
+       va_list args;
+       va_start(args, fmt);
+       vaf.fmt = fmt;
+       vaf.va = &args;
+       printk("%sADFS-fs (%s): %pV\n", pfx, sb->s_id, &vaf);
+       va_end(args);
  }
  
  static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
  {
+       unsigned int max_idlen;
        int i;
  
        /* sector size must be 256, 512 or 1024 bytes */
        if (le32_to_cpu(dr->disc_size_high) >> dr->log2secsize)
                return 1;
  
-       /* idlen must be no greater than 19 v2 [1.0] */
-       if (dr->idlen > 19)
+       /*
+        * Maximum idlen is limited to 16 bits for new directories by
+        * the three-byte storage of an indirect disc address.  For
+        * big directories, idlen must be no greater than 19 v2 [1.0]
+        */
+       max_idlen = dr->format_version ? 19 : 16;
+       if (dr->idlen > max_idlen)
                return 1;
  
        /* reserved bytes should be zero */
@@@ -152,10 -176,10 +173,10 @@@ static const match_table_t tokens = 
        {Opt_err, NULL}
  };
  
- static int parse_options(struct super_block *sb, char *options)
+ static int parse_options(struct super_block *sb, struct adfs_sb_info *asb,
+                        char *options)
  {
        char *p;
-       struct adfs_sb_info *asb = ADFS_SB(sb);
        int option;
  
        if (!options)
                        asb->s_ftsuffix = option;
                        break;
                default:
-                       printk("ADFS-fs: unrecognised mount option \"%s\" "
-                                       "or missing value\n", p);
+                       adfs_msg(sb, KERN_ERR,
+                                "unrecognised mount option \"%s\" or missing value",
+                                p);
                        return -EINVAL;
                }
        }
  
  static int adfs_remount(struct super_block *sb, int *flags, char *data)
  {
+       struct adfs_sb_info temp_asb;
+       int ret;
        sync_filesystem(sb);
-       *flags |= SB_NODIRATIME;
-       return parse_options(sb, data);
+       *flags |= ADFS_SB_FLAGS;
+       temp_asb = *ADFS_SB(sb);
+       ret = parse_options(sb, &temp_asb, data);
+       if (ret == 0)
+               *ADFS_SB(sb) = temp_asb;
+       return ret;
  }
  
  static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  {
        struct super_block *sb = dentry->d_sb;
        struct adfs_sb_info *sbi = ADFS_SB(sb);
+       struct adfs_discrecord *dr = adfs_map_discrecord(sbi->s_map);
        u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
  
        buf->f_type    = ADFS_SUPER_MAGIC;
        buf->f_namelen = sbi->s_namelen;
        buf->f_bsize   = sb->s_blocksize;
-       buf->f_blocks  = sbi->s_size;
+       buf->f_blocks  = adfs_disc_size(dr) >> sb->s_blocksize_bits;
        buf->f_files   = sbi->s_ids_per_zone * sbi->s_map_size;
        buf->f_bavail  =
        buf->f_bfree   = adfs_map_free(sb);
@@@ -327,8 -362,7 +359,7 @@@ static struct adfs_discmap *adfs_read_m
        i = zone - 1;
        dm[0].dm_startblk = 0;
        dm[0].dm_startbit = ADFS_DR_SIZE_BITS;
-       dm[i].dm_endbit   = (le32_to_cpu(dr->disc_size_high) << (32 - dr->log2bpmb)) +
-                           (le32_to_cpu(dr->disc_size) >> dr->log2bpmb) +
+       dm[i].dm_endbit   = (adfs_disc_size(dr) >> dr->log2bpmb) +
                            (ADFS_DR_SIZE_BITS - i * zone_size);
  
        if (adfs_checkmap(sb, dm))
@@@ -344,27 -378,18 +375,18 @@@ error_free
        return ERR_PTR(-EIO);
  }
  
- static inline unsigned long adfs_discsize(struct adfs_discrecord *dr, int block_bits)
- {
-       unsigned long discsize;
-       discsize  = le32_to_cpu(dr->disc_size_high) << (32 - block_bits);
-       discsize |= le32_to_cpu(dr->disc_size) >> block_bits;
-       return discsize;
- }
  static int adfs_fill_super(struct super_block *sb, void *data, int silent)
  {
        struct adfs_discrecord *dr;
        struct buffer_head *bh;
        struct object_info root_obj;
        unsigned char *b_data;
+       unsigned int blocksize;
        struct adfs_sb_info *asb;
        struct inode *root;
        int ret = -EINVAL;
  
-       sb->s_flags |= SB_NODIRATIME;
+       sb->s_flags |= ADFS_SB_FLAGS;
  
        asb = kzalloc(sizeof(*asb), GFP_KERNEL);
        if (!asb)
        asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK;
        asb->s_ftsuffix = 0;
  
-       if (parse_options(sb, data))
+       if (parse_options(sb, asb, data))
                goto error;
  
        sb_set_blocksize(sb, BLOCK_SIZE);
        if (!(bh = sb_bread(sb, ADFS_DISCRECORD / BLOCK_SIZE))) {
-               adfs_error(sb, "unable to read superblock");
+               adfs_msg(sb, KERN_ERR, "error: unable to read superblock");
                ret = -EIO;
                goto error;
        }
        b_data = bh->b_data + (ADFS_DISCRECORD % BLOCK_SIZE);
  
        if (adfs_checkbblk(b_data)) {
-               if (!silent)
-                       printk("VFS: Can't find an adfs filesystem on dev "
-                               "%s.\n", sb->s_id);
                ret = -EINVAL;
-               goto error_free_bh;
+               goto error_badfs;
        }
  
        dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
         * Do some sanity checks on the ADFS disc record
         */
        if (adfs_checkdiscrecord(dr)) {
-               if (!silent)
-                       printk("VPS: Can't find an adfs filesystem on dev "
-                               "%s.\n", sb->s_id);
                ret = -EINVAL;
-               goto error_free_bh;
+               goto error_badfs;
        }
  
+       blocksize = 1 << dr->log2secsize;
        brelse(bh);
-       if (sb_set_blocksize(sb, 1 << dr->log2secsize)) {
+       if (sb_set_blocksize(sb, blocksize)) {
                bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize);
                if (!bh) {
-                       adfs_error(sb, "couldn't read superblock on "
-                               "2nd try.");
+                       adfs_msg(sb, KERN_ERR,
+                                "error: couldn't read superblock on 2nd try.");
                        ret = -EIO;
                        goto error;
                }
                b_data = bh->b_data + (ADFS_DISCRECORD % sb->s_blocksize);
                if (adfs_checkbblk(b_data)) {
-                       adfs_error(sb, "disc record mismatch, very weird!");
+                       adfs_msg(sb, KERN_ERR,
+                                "error: disc record mismatch, very weird!");
                        ret = -EINVAL;
                        goto error_free_bh;
                }
                dr = (struct adfs_discrecord *)(b_data + ADFS_DR_OFFSET);
        } else {
                if (!silent)
-                       printk(KERN_ERR "VFS: Unsupported blocksize on dev "
-                               "%s.\n", sb->s_id);
+                       adfs_msg(sb, KERN_ERR,
+                                "error: unsupported blocksize");
                ret = -EINVAL;
                goto error;
        }
        asb->s_idlen            = dr->idlen;
        asb->s_map_size         = dr->nzones | (dr->nzones_high << 8);
        asb->s_map2blk          = dr->log2bpmb - dr->log2secsize;
-       asb->s_size             = adfs_discsize(dr, sb->s_blocksize_bits);
-       asb->s_version          = dr->format_version;
        asb->s_log2sharesize    = dr->log2sharesize;
  
        asb->s_map = adfs_read_map(sb, dr);
         */
        sb->s_op = &adfs_sops;
  
-       dr = (struct adfs_discrecord *)(asb->s_map[0].dm_bh->b_data + 4);
+       dr = adfs_map_discrecord(asb->s_map);
  
-       root_obj.parent_id = root_obj.file_id = le32_to_cpu(dr->root);
+       root_obj.parent_id = root_obj.indaddr = le32_to_cpu(dr->root);
        root_obj.name_len  = 0;
        /* Set root object date as 01 Jan 1987 00:00:00 */
        root_obj.loadaddr  = 0xfff0003f;
        root_obj.size      = ADFS_NEWDIR_SIZE;
        root_obj.attr      = ADFS_NDA_DIRECTORY   | ADFS_NDA_OWNER_READ |
                             ADFS_NDA_OWNER_WRITE | ADFS_NDA_PUBLIC_READ;
-       root_obj.filetype  = -1;
  
        /*
         * If this is a F+ disk with variable length directories,
         * get the root_size from the disc record.
         */
-       if (asb->s_version) {
+       if (dr->format_version) {
                root_obj.size = le32_to_cpu(dr->root_size);
                asb->s_dir     = &adfs_fplus_dir_ops;
                asb->s_namelen = ADFS_FPLUS_NAME_LEN;
        }
        return 0;
  
+ error_badfs:
+       if (!silent)
+               adfs_msg(sb, KERN_ERR,
+                        "error: can't find an ADFS filesystem on dev %s.",
+                        sb->s_id);
  error_free_bh:
        brelse(bh);
  error:
This page took 0.101659 seconds and 4 git commands to generate.