source: MondoRescue/branches/stable/mindi-busybox/e2fsprogs/ext2fs/alloc_stats.c @ 821

Last change on this file since 821 was 821, checked in by Bruno Cornec, 13 years ago

Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)

File size: 1.3 KB
Line 
1/*
2 * alloc_stats.c --- Update allocation statistics for ext2fs
3 *
4 * Copyright (C) 2001 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 *
11 */
12
13#include <stdio.h>
14
15#include "ext2_fs.h"
16#include "ext2fs.h"
17
18void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
19                   int inuse, int isdir)
20{
21    int group = ext2fs_group_of_ino(fs, ino);
22
23    if (inuse > 0)
24        ext2fs_mark_inode_bitmap(fs->inode_map, ino);
25    else
26        ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
27    fs->group_desc[group].bg_free_inodes_count -= inuse;
28    if (isdir)
29        fs->group_desc[group].bg_used_dirs_count += inuse;
30    fs->super->s_free_inodes_count -= inuse;
31    ext2fs_mark_super_dirty(fs);
32    ext2fs_mark_ib_dirty(fs);
33}
34
35void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse)
36{
37    ext2fs_inode_alloc_stats2(fs, ino, inuse, 0);
38}
39
40void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse)
41{
42    int group = ext2fs_group_of_blk(fs, blk);
43
44    if (inuse > 0)
45        ext2fs_mark_block_bitmap(fs->block_map, blk);
46    else
47        ext2fs_unmark_block_bitmap(fs->block_map, blk);
48    fs->group_desc[group].bg_free_blocks_count -= inuse;
49    fs->super->s_free_blocks_count -= inuse;
50    ext2fs_mark_super_dirty(fs);
51    ext2fs_mark_bb_dirty(fs);
52}
Note: See TracBrowser for help on using the repository browser.