import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / fs / efs / file.c
1 /*
2  * file.c
3  *
4  * Copyright (c) 1999 Al Smith
5  *
6  * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
7  */
8
9 #include <linux/efs_fs.h>
10
11 int efs_get_block(struct inode *inode, long iblock,
12                   struct buffer_head *bh_result, int create)
13 {
14         int error = -EROFS;
15         long phys;
16
17         if (create)
18                 return error;
19         if (iblock >= inode->i_blocks) {
20 #ifdef DEBUG
21                 /*
22                  * i have no idea why this happens as often as it does
23                  */
24                 printk(KERN_WARNING "EFS: bmap(): block %d >= %ld (filesize %ld)\n",
25                         block,
26                         inode->i_blocks,
27                         inode->i_size);
28 #endif
29                 return 0;
30         }
31         phys = efs_map_block(inode, iblock);
32         if (phys) {
33                 bh_result->b_dev = inode->i_dev;
34                 bh_result->b_blocknr = phys;
35                 bh_result->b_state |= (1UL << BH_Mapped);
36         }
37         return 0;
38 }
39
40 int efs_bmap(struct inode *inode, efs_block_t block) {
41
42         if (block < 0) {
43                 printk(KERN_WARNING "EFS: bmap(): block < 0\n");
44                 return 0;
45         }
46
47         /* are we about to read past the end of a file ? */
48         if (!(block < inode->i_blocks)) {
49 #ifdef DEBUG
50                 /*
51                  * i have no idea why this happens as often as it does
52                  */
53                 printk(KERN_WARNING "EFS: bmap(): block %d >= %ld (filesize %ld)\n",
54                         block,
55                         inode->i_blocks,
56                         inode->i_size);
57 #endif
58                 return 0;
59         }
60
61         return efs_map_block(inode, block);
62 }