summaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs/alloc_stats.c
diff options
context:
space:
mode:
authorMike Frysinger2005-05-09 22:10:42 +0000
committerMike Frysinger2005-05-09 22:10:42 +0000
commit1fd98e039d146dcff02a5350f509cabca65fd29c (patch)
tree1564707d41a6271bb44cf3fa5b88b9cc70fedd35 /e2fsprogs/ext2fs/alloc_stats.c
parentb32011943a0764872ca1ea17f13b53176ace8e69 (diff)
downloadbusybox-1fd98e039d146dcff02a5350f509cabca65fd29c.zip
busybox-1fd98e039d146dcff02a5350f509cabca65fd29c.tar.gz
import ext2fs lib to prep for new e2fsprogs
Diffstat (limited to 'e2fsprogs/ext2fs/alloc_stats.c')
-rw-r--r--e2fsprogs/ext2fs/alloc_stats.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/e2fsprogs/ext2fs/alloc_stats.c b/e2fsprogs/ext2fs/alloc_stats.c
new file mode 100644
index 0000000..4088f7b
--- /dev/null
+++ b/e2fsprogs/ext2fs/alloc_stats.c
@@ -0,0 +1,52 @@
+/*
+ * alloc_stats.c --- Update allocation statistics for ext2fs
+ *
+ * Copyright (C) 2001 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ *
+ */
+
+#include <stdio.h>
+
+#include "ext2_fs.h"
+#include "ext2fs.h"
+
+void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
+ int inuse, int isdir)
+{
+ int group = ext2fs_group_of_ino(fs, ino);
+
+ if (inuse > 0)
+ ext2fs_mark_inode_bitmap(fs->inode_map, ino);
+ else
+ ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
+ fs->group_desc[group].bg_free_inodes_count -= inuse;
+ if (isdir)
+ fs->group_desc[group].bg_used_dirs_count += inuse;
+ fs->super->s_free_inodes_count -= inuse;
+ ext2fs_mark_super_dirty(fs);
+ ext2fs_mark_ib_dirty(fs);
+}
+
+void ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse)
+{
+ ext2fs_inode_alloc_stats2(fs, ino, inuse, 0);
+}
+
+void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse)
+{
+ int group = ext2fs_group_of_blk(fs, blk);
+
+ if (inuse > 0)
+ ext2fs_mark_block_bitmap(fs->block_map, blk);
+ else
+ ext2fs_unmark_block_bitmap(fs->block_map, blk);
+ fs->group_desc[group].bg_free_blocks_count -= inuse;
+ fs->super->s_free_blocks_count -= inuse;
+ ext2fs_mark_super_dirty(fs);
+ ext2fs_mark_bb_dirty(fs);
+}