blob: d0869c91917b20a2efc7e62be79ad5d5d9c44046 [file] [log] [blame]
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +00001/* vi: set sw=4 ts=4: */
2/*
3 * gen_bitmap.c --- Generic bitmap routines that used to be inlined.
4 *
5 * Copyright (C) 2001 Theodore Ts'o.
6 *
7 * %Begin-Header%
8 * This file may be redistributed under the terms of the GNU Public
9 * License.
10 * %End-Header%
11 */
12
13
14#include <stdio.h>
15#include <string.h>
16#if HAVE_UNISTD_H
17#include <unistd.h>
18#endif
19#include <fcntl.h>
20#include <time.h>
21#if HAVE_SYS_STAT_H
22#include <sys/stat.h>
23#endif
24#if HAVE_SYS_TYPES_H
25#include <sys/types.h>
26#endif
27
28#include "ext2_fs.h"
29#include "ext2fs.h"
30
31int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
32 __u32 bitno)
33{
34 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
35 ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
36 return 0;
37 }
38 return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
39}
40
41int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
42 blk_t bitno)
43{
44 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
45 ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
46 return 0;
47 }
48 return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
49}