Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * file.c
0004  *
0005  * Copyright (c) 1999 Al Smith
0006  *
0007  * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
0008  */
0009 
0010 #include <linux/buffer_head.h>
0011 #include "efs.h"
0012 
0013 int efs_get_block(struct inode *inode, sector_t iblock,
0014           struct buffer_head *bh_result, int create)
0015 {
0016     int error = -EROFS;
0017     long phys;
0018 
0019     if (create)
0020         return error;
0021     if (iblock >= inode->i_blocks) {
0022 #ifdef DEBUG
0023         /*
0024          * i have no idea why this happens as often as it does
0025          */
0026         pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
0027             __func__, block, inode->i_blocks, inode->i_size);
0028 #endif
0029         return 0;
0030     }
0031     phys = efs_map_block(inode, iblock);
0032     if (phys)
0033         map_bh(bh_result, inode->i_sb, phys);
0034     return 0;
0035 }
0036 
0037 int efs_bmap(struct inode *inode, efs_block_t block) {
0038 
0039     if (block < 0) {
0040         pr_warn("%s(): block < 0\n", __func__);
0041         return 0;
0042     }
0043 
0044     /* are we about to read past the end of a file ? */
0045     if (!(block < inode->i_blocks)) {
0046 #ifdef DEBUG
0047         /*
0048          * i have no idea why this happens as often as it does
0049          */
0050         pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
0051             __func__, block, inode->i_blocks, inode->i_size);
0052 #endif
0053         return 0;
0054     }
0055 
0056     return efs_map_block(inode, block);
0057 }