blob: bbde5d582978972e02bbb97841837f9788b9da20 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
2 * linux/fs/ext4/bitmap.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */
9
10#include <linux/buffer_head.h>
11#include <linux/jbd2.h>
12#include "ext4.h"
13
14static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
15
16unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
17{
18 unsigned int i, sum = 0;
19
20 for (i = 0; i < numchars; i++)
21 sum += nibblemap[bitmap[i] & 0xf] +
22 nibblemap[(bitmap[i] >> 4) & 0xf];
23 return sum;
24}
25