~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/befs/super.c

Version: ~ [ linux-5.18-rc6 ] ~ [ linux-5.17.6 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.38 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.114 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.192 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.241 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.277 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.312 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * super.c
  3  *
  4  * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
  5  *
  6  * Licensed under the GNU GPL. See the file COPYING for details.
  7  *
  8  */
  9 
 10 #include <linux/fs.h>
 11 #include <asm/page.h> /* for PAGE_SIZE */
 12 
 13 #include "befs.h"
 14 #include "super.h"
 15 
 16 /**
 17  * load_befs_sb -- Read from disk and properly byteswap all the fields
 18  * of the befs superblock
 19  *
 20  *
 21  *
 22  *
 23  */
 24 int
 25 befs_load_sb(struct super_block *sb, befs_super_block * disk_sb)
 26 {
 27         struct befs_sb_info *befs_sb = BEFS_SB(sb);
 28 
 29         /* Check the byte order of the filesystem */
 30         if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE)
 31             befs_sb->byte_order = BEFS_BYTESEX_LE;
 32         else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE)
 33             befs_sb->byte_order = BEFS_BYTESEX_BE;
 34 
 35         befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1);
 36         befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2);
 37         befs_sb->magic3 = fs32_to_cpu(sb, disk_sb->magic3);
 38         befs_sb->block_size = fs32_to_cpu(sb, disk_sb->block_size);
 39         befs_sb->block_shift = fs32_to_cpu(sb, disk_sb->block_shift);
 40         befs_sb->num_blocks = fs64_to_cpu(sb, disk_sb->num_blocks);
 41         befs_sb->used_blocks = fs64_to_cpu(sb, disk_sb->used_blocks);
 42         befs_sb->inode_size = fs32_to_cpu(sb, disk_sb->inode_size);
 43 
 44         befs_sb->blocks_per_ag = fs32_to_cpu(sb, disk_sb->blocks_per_ag);
 45         befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift);
 46         befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags);
 47 
 48         befs_sb->log_blocks = fsrun_to_cpu(sb, disk_sb->log_blocks);
 49         befs_sb->log_start = fs64_to_cpu(sb, disk_sb->log_start);
 50         befs_sb->log_end = fs64_to_cpu(sb, disk_sb->log_end);
 51 
 52         befs_sb->root_dir = fsrun_to_cpu(sb, disk_sb->root_dir);
 53         befs_sb->indices = fsrun_to_cpu(sb, disk_sb->indices);
 54         befs_sb->nls = NULL;
 55 
 56         return BEFS_OK;
 57 }
 58 
 59 int
 60 befs_check_sb(struct super_block *sb)
 61 {
 62         struct befs_sb_info *befs_sb = BEFS_SB(sb);
 63 
 64         /* Check magic headers of super block */
 65         if ((befs_sb->magic1 != BEFS_SUPER_MAGIC1)
 66             || (befs_sb->magic2 != BEFS_SUPER_MAGIC2)
 67             || (befs_sb->magic3 != BEFS_SUPER_MAGIC3)) {
 68                 befs_error(sb, "invalid magic header");
 69                 return BEFS_ERR;
 70         }
 71 
 72         /*
 73          * Check blocksize of BEFS.
 74          *
 75          * Blocksize of BEFS is 1024, 2048, 4096 or 8192.
 76          */
 77 
 78         if ((befs_sb->block_size != 1024)
 79             && (befs_sb->block_size != 2048)
 80             && (befs_sb->block_size != 4096)
 81             && (befs_sb->block_size != 8192)) {
 82                 befs_error(sb, "invalid blocksize: %u", befs_sb->block_size);
 83                 return BEFS_ERR;
 84         }
 85 
 86         if (befs_sb->block_size > PAGE_SIZE) {
 87                 befs_error(sb, "blocksize(%u) cannot be larger"
 88                            "than system pagesize(%lu)", befs_sb->block_size,
 89                            PAGE_SIZE);
 90                 return BEFS_ERR;
 91         }
 92 
 93         /*
 94            * block_shift and block_size encode the same information
 95            * in different ways as a consistency check.
 96          */
 97 
 98         if ((1 << befs_sb->block_shift) != befs_sb->block_size) {
 99                 befs_error(sb, "block_shift disagrees with block_size. "
100                            "Corruption likely.");
101                 return BEFS_ERR;
102         }
103 
104         if (befs_sb->log_start != befs_sb->log_end) {
105                 befs_error(sb, "Filesystem not clean! There are blocks in the "
106                            "journal. You must boot into BeOS and mount this volume "
107                            "to make it clean.");
108                 return BEFS_ERR;
109         }
110 
111         return BEFS_OK;
112 }
113 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp