aboutsummaryrefslogtreecommitdiffstats
path: root/fs/befs/inode.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/befs/inode.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/befs/inode.c')
-rw-r--r--fs/befs/inode.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/fs/befs/inode.c b/fs/befs/inode.c
new file mode 100644
index 000000000000..d41c9247ae8a
--- /dev/null
+++ b/fs/befs/inode.c
@@ -0,0 +1,53 @@
1/*
2 * inode.c
3 *
4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com>
5 */
6
7#include <linux/fs.h>
8
9#include "befs.h"
10#include "inode.h"
11#include "endian.h"
12
13/*
14 Validates the correctness of the befs inode
15 Returns BEFS_OK if the inode should be used, otherwise
16 returns BEFS_BAD_INODE
17*/
18int
19befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
20 befs_blocknr_t inode)
21{
22 u32 magic1 = fs32_to_cpu(sb, raw_inode->magic1);
23 befs_inode_addr ino_num = fsrun_to_cpu(sb, raw_inode->inode_num);
24 u32 flags = fs32_to_cpu(sb, raw_inode->flags);
25
26 /* check magic header. */
27 if (magic1 != BEFS_INODE_MAGIC1) {
28 befs_error(sb,
29 "Inode has a bad magic header - inode = %lu", inode);
30 return BEFS_BAD_INODE;
31 }
32
33 /*
34 * Sanity check2: inodes store their own block address. Check it.
35 */
36 if (inode != iaddr2blockno(sb, &ino_num)) {
37 befs_error(sb, "inode blocknr field disagrees with vfs "
38 "VFS: %lu, Inode %lu",
39 inode, iaddr2blockno(sb, &ino_num));
40 return BEFS_BAD_INODE;
41 }
42
43 /*
44 * check flag
45 */
46
47 if (!(flags & BEFS_INODE_IN_USE)) {
48 befs_error(sb, "inode is not used - inode = %lu", inode);
49 return BEFS_BAD_INODE;
50 }
51
52 return BEFS_OK;
53}