qnx4fs: remove remains of the (defunct) write support
[deliverable/linux.git] / fs / qnx4 / bitmap.c
CommitLineData
1da177e4
LT
1/*
2 * QNX4 file system, Linux implementation.
3 *
4 * Version : 0.2.1
5 *
6 * Using parts of the xiafs filesystem.
7 *
8 * History :
9 *
10 * 28-05-1998 by Richard Frowijn : first release.
11 * 20-06-1998 by Frank Denis : basic optimisations.
12 * 25-06-1998 by Frank Denis : qnx4_is_free, qnx4_set_bitmap, qnx4_bmap .
13 * 28-06-1998 by Frank Denis : qnx4_free_inode (to be fixed) .
14 */
15
1da177e4
LT
16#include <linux/buffer_head.h>
17#include <linux/bitops.h>
964f5369 18#include "qnx4.h"
1da177e4 19
1da177e4
LT
20static void count_bits(register const char *bmPart, register int size,
21 int *const tf)
22{
23 char b;
24 int tot = *tf;
25
26 if (size > QNX4_BLOCK_SIZE) {
27 size = QNX4_BLOCK_SIZE;
28 }
29 do {
30 b = *bmPart++;
31 if ((b & 1) == 0)
32 tot++;
33 if ((b & 2) == 0)
34 tot++;
35 if ((b & 4) == 0)
36 tot++;
37 if ((b & 8) == 0)
38 tot++;
39 if ((b & 16) == 0)
40 tot++;
41 if ((b & 32) == 0)
42 tot++;
43 if ((b & 64) == 0)
44 tot++;
45 if ((b & 128) == 0)
46 tot++;
47 size--;
48 } while (size != 0);
49 *tf = tot;
50}
51
52unsigned long qnx4_count_free_blocks(struct super_block *sb)
53{
54 int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
55 int total = 0;
56 int total_free = 0;
57 int offset = 0;
58 int size = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size);
59 struct buffer_head *bh;
60
61 while (total < size) {
62 if ((bh = sb_bread(sb, start + offset)) == NULL) {
891ddb95 63 printk(KERN_ERR "qnx4: I/O error in counting free blocks\n");
1da177e4
LT
64 break;
65 }
66 count_bits(bh->b_data, size - total, &total_free);
67 brelse(bh);
68 total += QNX4_BLOCK_SIZE;
69 offset++;
70 }
71
72 return total_free;
73}
This page took 0.456087 seconds and 5 git commands to generate.