aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/befs/befs.h3
-rw-r--r--fs/befs/befs_fs_types.h12
-rw-r--r--fs/befs/btree.c48
-rw-r--r--fs/befs/btree.h8
-rw-r--r--fs/befs/datastream.c8
-rw-r--r--fs/befs/datastream.h5
-rw-r--r--fs/befs/debug.c14
-rw-r--r--fs/befs/inode.c12
-rw-r--r--fs/befs/inode.h5
-rw-r--r--fs/befs/io.c7
-rw-r--r--fs/befs/io.h1
-rw-r--r--fs/befs/linuxvfs.c134
-rw-r--r--fs/befs/super.h4
13 files changed, 145 insertions, 116 deletions
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index c6bad51d8ec7..b914cfb03820 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -129,6 +129,7 @@ static inline befs_inode_addr
129blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno) 129blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
130{ 130{
131 befs_inode_addr iaddr; 131 befs_inode_addr iaddr;
132
132 iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift; 133 iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
133 iaddr.start = 134 iaddr.start =
134 blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift); 135 blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
@@ -140,7 +141,7 @@ blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
140static inline unsigned int 141static inline unsigned int
141befs_iaddrs_per_block(struct super_block *sb) 142befs_iaddrs_per_block(struct super_block *sb)
142{ 143{
143 return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr); 144 return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr);
144} 145}
145 146
146#include "endian.h" 147#include "endian.h"
diff --git a/fs/befs/befs_fs_types.h b/fs/befs/befs_fs_types.h
index eb557d9dc8be..69c9d8cde955 100644
--- a/fs/befs/befs_fs_types.h
+++ b/fs/befs/befs_fs_types.h
@@ -55,12 +55,12 @@ enum super_flags {
55}; 55};
56 56
57#define BEFS_BYTEORDER_NATIVE 0x42494745 57#define BEFS_BYTEORDER_NATIVE 0x42494745
58#define BEFS_BYTEORDER_NATIVE_LE (__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE) 58#define BEFS_BYTEORDER_NATIVE_LE ((__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE))
59#define BEFS_BYTEORDER_NATIVE_BE (__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE) 59#define BEFS_BYTEORDER_NATIVE_BE ((__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE))
60 60
61#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1 61#define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
62#define BEFS_SUPER_MAGIC1_LE (__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1) 62#define BEFS_SUPER_MAGIC1_LE ((__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1))
63#define BEFS_SUPER_MAGIC1_BE (__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1) 63#define BEFS_SUPER_MAGIC1_BE ((__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1))
64 64
65/* 65/*
66 * Flags of inode 66 * Flags of inode
@@ -79,7 +79,7 @@ enum inode_flags {
79 BEFS_INODE_WAS_WRITTEN = 0x00020000, 79 BEFS_INODE_WAS_WRITTEN = 0x00020000,
80 BEFS_NO_TRANSACTION = 0x00040000, 80 BEFS_NO_TRANSACTION = 0x00040000,
81}; 81};
82/* 82/*
83 * On-Disk datastructures of BeFS 83 * On-Disk datastructures of BeFS
84 */ 84 */
85 85
@@ -139,7 +139,7 @@ typedef struct {
139 139
140} PACKED befs_super_block; 140} PACKED befs_super_block;
141 141
142/* 142/*
143 * Note: the indirect and dbl_indir block_runs may 143 * Note: the indirect and dbl_indir block_runs may
144 * be longer than one block! 144 * be longer than one block!
145 */ 145 */
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 7e135ea73fdd..d509887c580c 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -12,8 +12,8 @@
12 * 12 *
13 * Dominic Giampaolo, author of "Practical File System 13 * Dominic Giampaolo, author of "Practical File System
14 * Design with the Be File System", for such a helpful book. 14 * Design with the Be File System", for such a helpful book.
15 * 15 *
16 * Marcus J. Ranum, author of the b+tree package in 16 * Marcus J. Ranum, author of the b+tree package in
17 * comp.sources.misc volume 10. This code is not copied from that 17 * comp.sources.misc volume 10. This code is not copied from that
18 * work, but it is partially based on it. 18 * work, but it is partially based on it.
19 * 19 *
@@ -38,38 +38,38 @@
38 */ 38 */
39 39
40/* Befs B+tree structure: 40/* Befs B+tree structure:
41 * 41 *
42 * The first thing in the tree is the tree superblock. It tells you 42 * The first thing in the tree is the tree superblock. It tells you
43 * all kinds of useful things about the tree, like where the rootnode 43 * all kinds of useful things about the tree, like where the rootnode
44 * is located, and the size of the nodes (always 1024 with current version 44 * is located, and the size of the nodes (always 1024 with current version
45 * of BeOS). 45 * of BeOS).
46 * 46 *
47 * The rest of the tree consists of a series of nodes. Nodes contain a header 47 * The rest of the tree consists of a series of nodes. Nodes contain a header
48 * (struct befs_btree_nodehead), the packed key data, an array of shorts 48 * (struct befs_btree_nodehead), the packed key data, an array of shorts
49 * containing the ending offsets for each of the keys, and an array of 49 * containing the ending offsets for each of the keys, and an array of
50 * befs_off_t values. In interior nodes, the keys are the ending keys for 50 * befs_off_t values. In interior nodes, the keys are the ending keys for
51 * the childnode they point to, and the values are offsets into the 51 * the childnode they point to, and the values are offsets into the
52 * datastream containing the tree. 52 * datastream containing the tree.
53 */ 53 */
54 54
55/* Note: 55/* Note:
56 * 56 *
57 * The book states 2 confusing things about befs b+trees. First, 57 * The book states 2 confusing things about befs b+trees. First,
58 * it states that the overflow field of node headers is used by internal nodes 58 * it states that the overflow field of node headers is used by internal nodes
59 * to point to another node that "effectively continues this one". Here is what 59 * to point to another node that "effectively continues this one". Here is what
60 * I believe that means. Each key in internal nodes points to another node that 60 * I believe that means. Each key in internal nodes points to another node that
61 * contains key values less than itself. Inspection reveals that the last key 61 * contains key values less than itself. Inspection reveals that the last key
62 * in the internal node is not the last key in the index. Keys that are 62 * in the internal node is not the last key in the index. Keys that are
63 * greater than the last key in the internal node go into the overflow node. 63 * greater than the last key in the internal node go into the overflow node.
64 * I imagine there is a performance reason for this. 64 * I imagine there is a performance reason for this.
65 * 65 *
66 * Second, it states that the header of a btree node is sufficient to 66 * Second, it states that the header of a btree node is sufficient to
67 * distinguish internal nodes from leaf nodes. Without saying exactly how. 67 * distinguish internal nodes from leaf nodes. Without saying exactly how.
68 * After figuring out the first, it becomes obvious that internal nodes have 68 * After figuring out the first, it becomes obvious that internal nodes have
69 * overflow nodes and leafnodes do not. 69 * overflow nodes and leafnodes do not.
70 */ 70 */
71 71
72/* 72/*
73 * Currently, this code is only good for directory B+trees. 73 * Currently, this code is only good for directory B+trees.
74 * In order to be used for other BFS indexes, it needs to be extended to handle 74 * In order to be used for other BFS indexes, it needs to be extended to handle
75 * duplicate keys and non-string keytypes (int32, int64, float, double). 75 * duplicate keys and non-string keytypes (int32, int64, float, double).
@@ -237,8 +237,8 @@ befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds,
237 * with @key (usually the disk block number of an inode). 237 * with @key (usually the disk block number of an inode).
238 * 238 *
239 * On failure, returns BEFS_ERR or BEFS_BT_NOT_FOUND. 239 * On failure, returns BEFS_ERR or BEFS_BT_NOT_FOUND.
240 * 240 *
241 * Algorithm: 241 * Algorithm:
242 * Read the superblock and rootnode of the b+tree. 242 * Read the superblock and rootnode of the b+tree.
243 * Drill down through the interior nodes using befs_find_key(). 243 * Drill down through the interior nodes using befs_find_key().
244 * Once at the correct leaf node, use befs_find_key() again to get the 244 * Once at the correct leaf node, use befs_find_key() again to get the
@@ -402,12 +402,12 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node,
402 * 402 *
403 * Here's how it works: Key_no is the index of the key/value pair to 403 * Here's how it works: Key_no is the index of the key/value pair to
404 * return in keybuf/value. 404 * return in keybuf/value.
405 * Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is 405 * Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is
406 * the number of characters in the key (just a convenience). 406 * the number of characters in the key (just a convenience).
407 * 407 *
408 * Algorithm: 408 * Algorithm:
409 * Get the first leafnode of the tree. See if the requested key is in that 409 * Get the first leafnode of the tree. See if the requested key is in that
410 * node. If not, follow the node->right link to the next leafnode. Repeat 410 * node. If not, follow the node->right link to the next leafnode. Repeat
411 * until the (key_no)th key is found or the tree is out of keys. 411 * until the (key_no)th key is found or the tree is out of keys.
412 */ 412 */
413int 413int
@@ -536,7 +536,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
536 * @node_off: Pointer to offset of current node within datastream. Modified 536 * @node_off: Pointer to offset of current node within datastream. Modified
537 * by the function. 537 * by the function.
538 * 538 *
539 * Helper function for btree traverse. Moves the current position to the 539 * Helper function for btree traverse. Moves the current position to the
540 * start of the first leaf node. 540 * start of the first leaf node.
541 * 541 *
542 * Also checks for an empty tree. If there are no keys, returns BEFS_BT_EMPTY. 542 * Also checks for an empty tree. If there are no keys, returns BEFS_BT_EMPTY.
@@ -592,10 +592,10 @@ befs_btree_seekleaf(struct super_block *sb, const befs_data_stream *ds,
592} 592}
593 593
594/** 594/**
595 * befs_leafnode - Determine if the btree node is a leaf node or an 595 * befs_leafnode - Determine if the btree node is a leaf node or an
596 * interior node 596 * interior node
597 * @node: Pointer to node structure to test 597 * @node: Pointer to node structure to test
598 * 598 *
599 * Return 1 if leaf, 0 if interior 599 * Return 1 if leaf, 0 if interior
600 */ 600 */
601static int 601static int
@@ -656,7 +656,7 @@ befs_bt_valarray(struct befs_btree_node *node)
656 * @node: Pointer to the node structure to find the keydata array within 656 * @node: Pointer to the node structure to find the keydata array within
657 * 657 *
658 * Returns a pointer to the start of the keydata array 658 * Returns a pointer to the start of the keydata array
659 * of the node pointed to by the node header 659 * of the node pointed to by the node header
660 */ 660 */
661static char * 661static char *
662befs_bt_keydata(struct befs_btree_node *node) 662befs_bt_keydata(struct befs_btree_node *node)
@@ -702,7 +702,7 @@ befs_bt_get_key(struct super_block *sb, struct befs_btree_node *node,
702 702
703/** 703/**
704 * befs_compare_strings - compare two strings 704 * befs_compare_strings - compare two strings
705 * @key1: pointer to the first key to be compared 705 * @key1: pointer to the first key to be compared
706 * @keylen1: length in bytes of key1 706 * @keylen1: length in bytes of key1
707 * @key2: pointer to the second key to be compared 707 * @key2: pointer to the second key to be compared
708 * @keylen2: length in bytes of key2 708 * @keylen2: length in bytes of key2
diff --git a/fs/befs/btree.h b/fs/befs/btree.h
index f2a8f637e9e0..60c6c728e64e 100644
--- a/fs/befs/btree.h
+++ b/fs/befs/btree.h
@@ -1,13 +1,11 @@
1/* 1/*
2 * btree.h 2 * btree.h
3 * 3 *
4 */ 4 */
5 5
6
7int befs_btree_find(struct super_block *sb, const befs_data_stream *ds, 6int befs_btree_find(struct super_block *sb, const befs_data_stream *ds,
8 const char *key, befs_off_t * value); 7 const char *key, befs_off_t *value);
9 8
10int befs_btree_read(struct super_block *sb, const befs_data_stream *ds, 9int befs_btree_read(struct super_block *sb, const befs_data_stream *ds,
11 loff_t key_no, size_t bufsize, char *keybuf, 10 loff_t key_no, size_t bufsize, char *keybuf,
12 size_t * keysize, befs_off_t * value); 11 size_t *keysize, befs_off_t *value);
13
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index b4c7ba013c0d..720b3bc5c16a 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -84,13 +84,11 @@ befs_read_datastream(struct super_block *sb, const befs_data_stream *ds,
84 * 84 *
85 * Takes a file position and gives back a brun who's starting block 85 * Takes a file position and gives back a brun who's starting block
86 * is block number fblock of the file. 86 * is block number fblock of the file.
87 * 87 *
88 * Returns BEFS_OK or BEFS_ERR. 88 * Returns BEFS_OK or BEFS_ERR.
89 * 89 *
90 * Calls specialized functions for each of the three possible 90 * Calls specialized functions for each of the three possible
91 * datastream regions. 91 * datastream regions.
92 *
93 * 2001-11-15 Will Dyson
94 */ 92 */
95int 93int
96befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, 94befs_fblock2brun(struct super_block *sb, const befs_data_stream *data,
@@ -120,7 +118,7 @@ befs_fblock2brun(struct super_block *sb, const befs_data_stream *data,
120 118
121/** 119/**
122 * befs_read_lsmylink - read long symlink from datastream. 120 * befs_read_lsmylink - read long symlink from datastream.
123 * @sb: Filesystem superblock 121 * @sb: Filesystem superblock
124 * @ds: Datastream to read from 122 * @ds: Datastream to read from
125 * @buff: Buffer in which to place long symlink data 123 * @buff: Buffer in which to place long symlink data
126 * @len: Length of the long symlink in bytes 124 * @len: Length of the long symlink in bytes
diff --git a/fs/befs/datastream.h b/fs/befs/datastream.h
index 91ba8203d83f..7ff9ff09ec6e 100644
--- a/fs/befs/datastream.h
+++ b/fs/befs/datastream.h
@@ -5,10 +5,10 @@
5 5
6struct buffer_head *befs_read_datastream(struct super_block *sb, 6struct buffer_head *befs_read_datastream(struct super_block *sb,
7 const befs_data_stream *ds, 7 const befs_data_stream *ds,
8 befs_off_t pos, uint * off); 8 befs_off_t pos, uint *off);
9 9
10int befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, 10int befs_fblock2brun(struct super_block *sb, const befs_data_stream *data,
11 befs_blocknr_t fblock, befs_block_run * run); 11 befs_blocknr_t fblock, befs_block_run *run);
12 12
13size_t befs_read_lsymlink(struct super_block *sb, const befs_data_stream *data, 13size_t befs_read_lsymlink(struct super_block *sb, const befs_data_stream *data,
14 void *buff, befs_off_t len); 14 void *buff, befs_off_t len);
@@ -17,4 +17,3 @@ befs_blocknr_t befs_count_blocks(struct super_block *sb,
17 const befs_data_stream *ds); 17 const befs_data_stream *ds);
18 18
19extern const befs_inode_addr BAD_IADDR; 19extern const befs_inode_addr BAD_IADDR;
20
diff --git a/fs/befs/debug.c b/fs/befs/debug.c
index 85c13392e9e8..36656c86f50e 100644
--- a/fs/befs/debug.c
+++ b/fs/befs/debug.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/fs/befs/debug.c 2 * linux/fs/befs/debug.c
3 * 3 *
4 * Copyright (C) 2001 Will Dyson (will_dyson at pobox.com) 4 * Copyright (C) 2001 Will Dyson (will_dyson at pobox.com)
5 * 5 *
6 * With help from the ntfs-tng driver by Anton Altparmakov 6 * With help from the ntfs-tng driver by Anton Altparmakov
@@ -57,6 +57,7 @@ befs_debug(const struct super_block *sb, const char *fmt, ...)
57 57
58 struct va_format vaf; 58 struct va_format vaf;
59 va_list args; 59 va_list args;
60
60 va_start(args, fmt); 61 va_start(args, fmt);
61 vaf.fmt = fmt; 62 vaf.fmt = fmt;
62 vaf.va = &args; 63 vaf.va = &args;
@@ -67,7 +68,7 @@ befs_debug(const struct super_block *sb, const char *fmt, ...)
67} 68}
68 69
69void 70void
70befs_dump_inode(const struct super_block *sb, befs_inode * inode) 71befs_dump_inode(const struct super_block *sb, befs_inode *inode)
71{ 72{
72#ifdef CONFIG_BEFS_DEBUG 73#ifdef CONFIG_BEFS_DEBUG
73 74
@@ -151,7 +152,7 @@ befs_dump_inode(const struct super_block *sb, befs_inode * inode)
151 */ 152 */
152 153
153void 154void
154befs_dump_super_block(const struct super_block *sb, befs_super_block * sup) 155befs_dump_super_block(const struct super_block *sb, befs_super_block *sup)
155{ 156{
156#ifdef CONFIG_BEFS_DEBUG 157#ifdef CONFIG_BEFS_DEBUG
157 158
@@ -202,7 +203,7 @@ befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
202#if 0 203#if 0
203/* unused */ 204/* unused */
204void 205void
205befs_dump_small_data(const struct super_block *sb, befs_small_data * sd) 206befs_dump_small_data(const struct super_block *sb, befs_small_data *sd)
206{ 207{
207} 208}
208 209
@@ -221,7 +222,8 @@ befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
221#endif /* 0 */ 222#endif /* 0 */
222 223
223void 224void
224befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super) 225befs_dump_index_entry(const struct super_block *sb,
226 befs_disk_btree_super *super)
225{ 227{
226#ifdef CONFIG_BEFS_DEBUG 228#ifdef CONFIG_BEFS_DEBUG
227 229
@@ -242,7 +244,7 @@ befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * supe
242} 244}
243 245
244void 246void
245befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node) 247befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *node)
246{ 248{
247#ifdef CONFIG_BEFS_DEBUG 249#ifdef CONFIG_BEFS_DEBUG
248 250
diff --git a/fs/befs/inode.c b/fs/befs/inode.c
index fa4b718de597..5367a6470a69 100644
--- a/fs/befs/inode.c
+++ b/fs/befs/inode.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * inode.c 2 * inode.c
3 * 3 *
4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com> 4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com>
5 */ 5 */
6 6
@@ -10,12 +10,12 @@
10#include "inode.h" 10#include "inode.h"
11 11
12/* 12/*
13 Validates the correctness of the befs inode 13 * Validates the correctness of the befs inode
14 Returns BEFS_OK if the inode should be used, otherwise 14 * Returns BEFS_OK if the inode should be used, otherwise
15 returns BEFS_BAD_INODE 15 * returns BEFS_BAD_INODE
16*/ 16 */
17int 17int
18befs_check_inode(struct super_block *sb, befs_inode * raw_inode, 18befs_check_inode(struct super_block *sb, befs_inode *raw_inode,
19 befs_blocknr_t inode) 19 befs_blocknr_t inode)
20{ 20{
21 u32 magic1 = fs32_to_cpu(sb, raw_inode->magic1); 21 u32 magic1 = fs32_to_cpu(sb, raw_inode->magic1);
diff --git a/fs/befs/inode.h b/fs/befs/inode.h
index 9dc7fd9b7570..2219e412f49b 100644
--- a/fs/befs/inode.h
+++ b/fs/befs/inode.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * inode.h 2 * inode.h
3 * 3 *
4 */ 4 */
5 5
6int befs_check_inode(struct super_block *sb, befs_inode * raw_inode, 6int befs_check_inode(struct super_block *sb, befs_inode *raw_inode,
7 befs_blocknr_t inode); 7 befs_blocknr_t inode);
8
diff --git a/fs/befs/io.c b/fs/befs/io.c
index b4a558126ee1..227cb86e07fe 100644
--- a/fs/befs/io.c
+++ b/fs/befs/io.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com 4 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com
5 * 5 *
6 * Based on portions of file.c and inode.c 6 * Based on portions of file.c and inode.c
7 * by Makoto Kato (m_kato@ga2.so-net.ne.jp) 7 * by Makoto Kato (m_kato@ga2.so-net.ne.jp)
8 * 8 *
9 * Many thanks to Dominic Giampaolo, author of Practical File System 9 * Many thanks to Dominic Giampaolo, author of Practical File System
@@ -19,8 +19,7 @@
19/* 19/*
20 * Converts befs notion of disk addr to a disk offset and uses 20 * Converts befs notion of disk addr to a disk offset and uses
21 * linux kernel function sb_bread() to get the buffer containing 21 * linux kernel function sb_bread() to get the buffer containing
22 * the offset. -Will Dyson 22 * the offset.
23 *
24 */ 23 */
25 24
26struct buffer_head * 25struct buffer_head *
@@ -55,7 +54,7 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
55 befs_debug(sb, "<--- %s", __func__); 54 befs_debug(sb, "<--- %s", __func__);
56 return bh; 55 return bh;
57 56
58 error: 57error:
59 befs_debug(sb, "<--- %s ERROR", __func__); 58 befs_debug(sb, "<--- %s ERROR", __func__);
60 return NULL; 59 return NULL;
61} 60}
diff --git a/fs/befs/io.h b/fs/befs/io.h
index 78d7bc6e60de..9b3e1967cb31 100644
--- a/fs/befs/io.h
+++ b/fs/befs/io.h
@@ -4,4 +4,3 @@
4 4
5struct buffer_head *befs_bread_iaddr(struct super_block *sb, 5struct buffer_head *befs_bread_iaddr(struct super_block *sb,
6 befs_inode_addr iaddr); 6 befs_inode_addr iaddr);
7
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 647a276eba56..19407165f4aa 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -18,6 +18,7 @@
18#include <linux/parser.h> 18#include <linux/parser.h>
19#include <linux/namei.h> 19#include <linux/namei.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/exportfs.h>
21 22
22#include "befs.h" 23#include "befs.h"
23#include "btree.h" 24#include "btree.h"
@@ -37,7 +38,8 @@ static int befs_readdir(struct file *, struct dir_context *);
37static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int); 38static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int);
38static int befs_readpage(struct file *file, struct page *page); 39static int befs_readpage(struct file *file, struct page *page);
39static sector_t befs_bmap(struct address_space *mapping, sector_t block); 40static sector_t befs_bmap(struct address_space *mapping, sector_t block);
40static struct dentry *befs_lookup(struct inode *, struct dentry *, unsigned int); 41static struct dentry *befs_lookup(struct inode *, struct dentry *,
42 unsigned int);
41static struct inode *befs_iget(struct super_block *, unsigned long); 43static struct inode *befs_iget(struct super_block *, unsigned long);
42static struct inode *befs_alloc_inode(struct super_block *sb); 44static struct inode *befs_alloc_inode(struct super_block *sb);
43static void befs_destroy_inode(struct inode *inode); 45static void befs_destroy_inode(struct inode *inode);
@@ -51,6 +53,10 @@ static void befs_put_super(struct super_block *);
51static int befs_remount(struct super_block *, int *, char *); 53static int befs_remount(struct super_block *, int *, char *);
52static int befs_statfs(struct dentry *, struct kstatfs *); 54static int befs_statfs(struct dentry *, struct kstatfs *);
53static int parse_options(char *, struct befs_mount_options *); 55static int parse_options(char *, struct befs_mount_options *);
56static struct dentry *befs_fh_to_dentry(struct super_block *sb,
57 struct fid *fid, int fh_len, int fh_type);
58static struct dentry *befs_fh_to_parent(struct super_block *sb,
59 struct fid *fid, int fh_len, int fh_type);
54 60
55static const struct super_operations befs_sops = { 61static const struct super_operations befs_sops = {
56 .alloc_inode = befs_alloc_inode, /* allocate a new inode */ 62 .alloc_inode = befs_alloc_inode, /* allocate a new inode */
@@ -83,9 +89,14 @@ static const struct address_space_operations befs_symlink_aops = {
83 .readpage = befs_symlink_readpage, 89 .readpage = befs_symlink_readpage,
84}; 90};
85 91
86/* 92static const struct export_operations befs_export_operations = {
93 .fh_to_dentry = befs_fh_to_dentry,
94 .fh_to_parent = befs_fh_to_parent,
95};
96
97/*
87 * Called by generic_file_read() to read a page of data 98 * Called by generic_file_read() to read a page of data
88 * 99 *
89 * In turn, simply calls a generic block read function and 100 * In turn, simply calls a generic block read function and
90 * passes it the address of befs_get_block, for mapping file 101 * passes it the address of befs_get_block, for mapping file
91 * positions to disk blocks. 102 * positions to disk blocks.
@@ -102,15 +113,13 @@ befs_bmap(struct address_space *mapping, sector_t block)
102 return generic_block_bmap(mapping, block, befs_get_block); 113 return generic_block_bmap(mapping, block, befs_get_block);
103} 114}
104 115
105/* 116/*
106 * Generic function to map a file position (block) to a 117 * Generic function to map a file position (block) to a
107 * disk offset (passed back in bh_result). 118 * disk offset (passed back in bh_result).
108 * 119 *
109 * Used by many higher level functions. 120 * Used by many higher level functions.
110 * 121 *
111 * Calls befs_fblock2brun() in datastream.c to do the real work. 122 * Calls befs_fblock2brun() in datastream.c to do the real work.
112 *
113 * -WD 10-26-01
114 */ 123 */
115 124
116static int 125static int
@@ -269,15 +278,15 @@ befs_alloc_inode(struct super_block *sb)
269 struct befs_inode_info *bi; 278 struct befs_inode_info *bi;
270 279
271 bi = kmem_cache_alloc(befs_inode_cachep, GFP_KERNEL); 280 bi = kmem_cache_alloc(befs_inode_cachep, GFP_KERNEL);
272 if (!bi) 281 if (!bi)
273 return NULL; 282 return NULL;
274 return &bi->vfs_inode; 283 return &bi->vfs_inode;
275} 284}
276 285
277static void befs_i_callback(struct rcu_head *head) 286static void befs_i_callback(struct rcu_head *head)
278{ 287{
279 struct inode *inode = container_of(head, struct inode, i_rcu); 288 struct inode *inode = container_of(head, struct inode, i_rcu);
280 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
281} 290}
282 291
283static void befs_destroy_inode(struct inode *inode) 292static void befs_destroy_inode(struct inode *inode)
@@ -287,7 +296,7 @@ static void befs_destroy_inode(struct inode *inode)
287 296
288static void init_once(void *foo) 297static void init_once(void *foo)
289{ 298{
290 struct befs_inode_info *bi = (struct befs_inode_info *) foo; 299 struct befs_inode_info *bi = (struct befs_inode_info *) foo;
291 300
292 inode_init_once(&bi->vfs_inode); 301 inode_init_once(&bi->vfs_inode);
293} 302}
@@ -338,7 +347,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
338 /* 347 /*
339 * set uid and gid. But since current BeOS is single user OS, so 348 * set uid and gid. But since current BeOS is single user OS, so
340 * you can change by "uid" or "gid" options. 349 * you can change by "uid" or "gid" options.
341 */ 350 */
342 351
343 inode->i_uid = befs_sb->mount_opts.use_uid ? 352 inode->i_uid = befs_sb->mount_opts.use_uid ?
344 befs_sb->mount_opts.uid : 353 befs_sb->mount_opts.uid :
@@ -353,14 +362,14 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
353 * BEFS's time is 64 bits, but current VFS is 32 bits... 362 * BEFS's time is 64 bits, but current VFS is 32 bits...
354 * BEFS don't have access time. Nor inode change time. VFS 363 * BEFS don't have access time. Nor inode change time. VFS
355 * doesn't have creation time. 364 * doesn't have creation time.
356 * Also, the lower 16 bits of the last_modified_time and 365 * Also, the lower 16 bits of the last_modified_time and
357 * create_time are just a counter to help ensure uniqueness 366 * create_time are just a counter to help ensure uniqueness
358 * for indexing purposes. (PFD, page 54) 367 * for indexing purposes. (PFD, page 54)
359 */ 368 */
360 369
361 inode->i_mtime.tv_sec = 370 inode->i_mtime.tv_sec =
362 fs64_to_cpu(sb, raw_inode->last_modified_time) >> 16; 371 fs64_to_cpu(sb, raw_inode->last_modified_time) >> 16;
363 inode->i_mtime.tv_nsec = 0; /* lower 16 bits are not a time */ 372 inode->i_mtime.tv_nsec = 0; /* lower 16 bits are not a time */
364 inode->i_ctime = inode->i_mtime; 373 inode->i_ctime = inode->i_mtime;
365 inode->i_atime = inode->i_mtime; 374 inode->i_atime = inode->i_mtime;
366 375
@@ -414,10 +423,10 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
414 unlock_new_inode(inode); 423 unlock_new_inode(inode);
415 return inode; 424 return inode;
416 425
417 unacquire_bh: 426unacquire_bh:
418 brelse(bh); 427 brelse(bh);
419 428
420 unacquire_none: 429unacquire_none:
421 iget_failed(inode); 430 iget_failed(inode);
422 befs_debug(sb, "<--- %s - Bad inode", __func__); 431 befs_debug(sb, "<--- %s - Bad inode", __func__);
423 return ERR_PTR(-EIO); 432 return ERR_PTR(-EIO);
@@ -442,7 +451,7 @@ befs_init_inodecache(void)
442} 451}
443 452
444/* Called at fs teardown. 453/* Called at fs teardown.
445 * 454 *
446 * Taken from NFS implementation by Al Viro. 455 * Taken from NFS implementation by Al Viro.
447 */ 456 */
448static void 457static void
@@ -491,13 +500,10 @@ fail:
491} 500}
492 501
493/* 502/*
494 * UTF-8 to NLS charset convert routine 503 * UTF-8 to NLS charset convert routine
495 *
496 * 504 *
497 * Changed 8/10/01 by Will Dyson. Now use uni2char() / char2uni() rather than 505 * Uses uni2char() / char2uni() rather than the nls tables directly
498 * the nls tables directly
499 */ 506 */
500
501static int 507static int
502befs_utf2nls(struct super_block *sb, const char *in, 508befs_utf2nls(struct super_block *sb, const char *in,
503 int in_len, char **out, int *out_len) 509 int in_len, char **out, int *out_len)
@@ -521,9 +527,8 @@ befs_utf2nls(struct super_block *sb, const char *in,
521 } 527 }
522 528
523 *out = result = kmalloc(maxlen, GFP_NOFS); 529 *out = result = kmalloc(maxlen, GFP_NOFS);
524 if (!*out) { 530 if (!*out)
525 return -ENOMEM; 531 return -ENOMEM;
526 }
527 532
528 for (i = o = 0; i < in_len; i += utflen, o += unilen) { 533 for (i = o = 0; i < in_len; i += utflen, o += unilen) {
529 534
@@ -546,7 +551,7 @@ befs_utf2nls(struct super_block *sb, const char *in,
546 551
547 return o; 552 return o;
548 553
549 conv_err: 554conv_err:
550 befs_error(sb, "Name using character set %s contains a character that " 555 befs_error(sb, "Name using character set %s contains a character that "
551 "cannot be converted to unicode.", nls->charset); 556 "cannot be converted to unicode.", nls->charset);
552 befs_debug(sb, "<--- %s", __func__); 557 befs_debug(sb, "<--- %s", __func__);
@@ -561,18 +566,18 @@ befs_utf2nls(struct super_block *sb, const char *in,
561 * @in_len: Length of input string in bytes 566 * @in_len: Length of input string in bytes
562 * @out: The output string in UTF-8 format 567 * @out: The output string in UTF-8 format
563 * @out_len: Length of the output buffer 568 * @out_len: Length of the output buffer
564 * 569 *
565 * Converts input string @in, which is in the format of the loaded NLS map, 570 * Converts input string @in, which is in the format of the loaded NLS map,
566 * into a utf8 string. 571 * into a utf8 string.
567 * 572 *
568 * The destination string @out is allocated by this function and the caller is 573 * The destination string @out is allocated by this function and the caller is
569 * responsible for freeing it with kfree() 574 * responsible for freeing it with kfree()
570 * 575 *
571 * On return, *@out_len is the length of @out in bytes. 576 * On return, *@out_len is the length of @out in bytes.
572 * 577 *
573 * On success, the return value is the number of utf8 characters written to 578 * On success, the return value is the number of utf8 characters written to
574 * the output buffer @out. 579 * the output buffer @out.
575 * 580 *
576 * On Failure, a negative number coresponding to the error code is returned. 581 * On Failure, a negative number coresponding to the error code is returned.
577 */ 582 */
578 583
@@ -585,9 +590,11 @@ befs_nls2utf(struct super_block *sb, const char *in,
585 wchar_t uni; 590 wchar_t uni;
586 int unilen, utflen; 591 int unilen, utflen;
587 char *result; 592 char *result;
588 /* There're nls characters that will translate to 3-chars-wide UTF-8 593 /*
589 * characters, a additional byte is needed to save the final \0 594 * There are nls characters that will translate to 3-chars-wide UTF-8
590 * in special cases */ 595 * characters, an additional byte is needed to save the final \0
596 * in special cases
597 */
591 int maxlen = (3 * in_len) + 1; 598 int maxlen = (3 * in_len) + 1;
592 599
593 befs_debug(sb, "---> %s\n", __func__); 600 befs_debug(sb, "---> %s\n", __func__);
@@ -624,14 +631,41 @@ befs_nls2utf(struct super_block *sb, const char *in,
624 631
625 return i; 632 return i;
626 633
627 conv_err: 634conv_err:
628 befs_error(sb, "Name using charecter set %s contains a charecter that " 635 befs_error(sb, "Name using character set %s contains a character that "
629 "cannot be converted to unicode.", nls->charset); 636 "cannot be converted to unicode.", nls->charset);
630 befs_debug(sb, "<--- %s", __func__); 637 befs_debug(sb, "<--- %s", __func__);
631 kfree(result); 638 kfree(result);
632 return -EILSEQ; 639 return -EILSEQ;
633} 640}
634 641
642static struct inode *befs_nfs_get_inode(struct super_block *sb, uint64_t ino,
643 uint32_t generation)
644{
645 /* No need to handle i_generation */
646 return befs_iget(sb, ino);
647}
648
649/*
650 * Map a NFS file handle to a corresponding dentry
651 */
652static struct dentry *befs_fh_to_dentry(struct super_block *sb,
653 struct fid *fid, int fh_len, int fh_type)
654{
655 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
656 befs_nfs_get_inode);
657}
658
659/*
660 * Find the parent for a file specified by NFS handle
661 */
662static struct dentry *befs_fh_to_parent(struct super_block *sb,
663 struct fid *fid, int fh_len, int fh_type)
664{
665 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
666 befs_nfs_get_inode);
667}
668
635enum { 669enum {
636 Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err, 670 Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err,
637}; 671};
@@ -666,6 +700,7 @@ parse_options(char *options, struct befs_mount_options *opts)
666 700
667 while ((p = strsep(&options, ",")) != NULL) { 701 while ((p = strsep(&options, ",")) != NULL) {
668 int token; 702 int token;
703
669 if (!*p) 704 if (!*p)
670 continue; 705 continue;
671 706
@@ -721,7 +756,7 @@ parse_options(char *options, struct befs_mount_options *opts)
721} 756}
722 757
723/* This function has the responsibiltiy of getting the 758/* This function has the responsibiltiy of getting the
724 * filesystem ready for unmounting. 759 * filesystem ready for unmounting.
725 * Basically, we free everything that we allocated in 760 * Basically, we free everything that we allocated in
726 * befs_read_inode 761 * befs_read_inode
727 */ 762 */
@@ -782,8 +817,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
782 * Linux 2.4.10 and later refuse to read blocks smaller than 817 * Linux 2.4.10 and later refuse to read blocks smaller than
783 * the logical block size for the device. But we also need to read at 818 * the logical block size for the device. But we also need to read at
784 * least 1k to get the second 512 bytes of the volume. 819 * least 1k to get the second 512 bytes of the volume.
785 * -WD 10-26-01 820 */
786 */
787 blocksize = sb_min_blocksize(sb, 1024); 821 blocksize = sb_min_blocksize(sb, 1024);
788 if (!blocksize) { 822 if (!blocksize) {
789 if (!silent) 823 if (!silent)
@@ -791,7 +825,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
791 goto unacquire_priv_sbp; 825 goto unacquire_priv_sbp;
792 } 826 }
793 827
794 if (!(bh = sb_bread(sb, sb_block))) { 828 bh = sb_bread(sb, sb_block);
829 if (!bh) {
795 if (!silent) 830 if (!silent)
796 befs_error(sb, "unable to read superblock"); 831 befs_error(sb, "unable to read superblock");
797 goto unacquire_priv_sbp; 832 goto unacquire_priv_sbp;
@@ -816,7 +851,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
816 851
817 brelse(bh); 852 brelse(bh);
818 853
819 if( befs_sb->num_blocks > ~((sector_t)0) ) { 854 if (befs_sb->num_blocks > ~((sector_t)0)) {
820 if (!silent) 855 if (!silent)
821 befs_error(sb, "blocks count: %llu is larger than the host can use", 856 befs_error(sb, "blocks count: %llu is larger than the host can use",
822 befs_sb->num_blocks); 857 befs_sb->num_blocks);
@@ -831,6 +866,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
831 /* Set real blocksize of fs */ 866 /* Set real blocksize of fs */
832 sb_set_blocksize(sb, (ulong) befs_sb->block_size); 867 sb_set_blocksize(sb, (ulong) befs_sb->block_size);
833 sb->s_op = &befs_sops; 868 sb->s_op = &befs_sops;
869 sb->s_export_op = &befs_export_operations;
834 root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); 870 root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
835 if (IS_ERR(root)) { 871 if (IS_ERR(root)) {
836 ret = PTR_ERR(root); 872 ret = PTR_ERR(root);
@@ -861,16 +897,16 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
861 } 897 }
862 898
863 return 0; 899 return 0;
864/*****************/ 900
865 unacquire_bh: 901unacquire_bh:
866 brelse(bh); 902 brelse(bh);
867 903
868 unacquire_priv_sbp: 904unacquire_priv_sbp:
869 kfree(befs_sb->mount_opts.iocharset); 905 kfree(befs_sb->mount_opts.iocharset);
870 kfree(sb->s_fs_info); 906 kfree(sb->s_fs_info);
871 sb->s_fs_info = NULL; 907 sb->s_fs_info = NULL;
872 908
873 unacquire_none: 909unacquire_none:
874 return ret; 910 return ret;
875} 911}
876 912
@@ -919,7 +955,7 @@ static struct file_system_type befs_fs_type = {
919 .name = "befs", 955 .name = "befs",
920 .mount = befs_mount, 956 .mount = befs_mount,
921 .kill_sb = kill_block_super, 957 .kill_sb = kill_block_super,
922 .fs_flags = FS_REQUIRES_DEV, 958 .fs_flags = FS_REQUIRES_DEV,
923}; 959};
924MODULE_ALIAS_FS("befs"); 960MODULE_ALIAS_FS("befs");
925 961
@@ -956,9 +992,9 @@ exit_befs_fs(void)
956} 992}
957 993
958/* 994/*
959Macros that typecheck the init and exit functions, 995 * Macros that typecheck the init and exit functions,
960ensures that they are called at init and cleanup, 996 * ensures that they are called at init and cleanup,
961and eliminates warnings about unused functions. 997 * and eliminates warnings about unused functions.
962*/ 998 */
963module_init(init_befs_fs) 999module_init(init_befs_fs)
964module_exit(exit_befs_fs) 1000module_exit(exit_befs_fs)
diff --git a/fs/befs/super.h b/fs/befs/super.h
index dc4556376a22..ec1df30a7e9a 100644
--- a/fs/befs/super.h
+++ b/fs/befs/super.h
@@ -2,7 +2,5 @@
2 * super.h 2 * super.h
3 */ 3 */
4 4
5int befs_load_sb(struct super_block *sb, befs_super_block * disk_sb); 5int befs_load_sb(struct super_block *sb, befs_super_block *disk_sb);
6
7int befs_check_sb(struct super_block *sb); 6int befs_check_sb(struct super_block *sb);
8