~ubuntu-branches/ubuntu/hardy/ntfs-3g/hardy

« back to all changes in this revision

Viewing changes to include/ntfs-3g/bitmap.h

  • Committer: Bazaar Package Importer
  • Author(s): Florent Mertens
  • Date: 2006-09-27 12:00:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060927120049-1hk9p6a42k58cv55
Tags: upstream-20060920
ImportĀ upstreamĀ versionĀ 20060920

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * bitmap.h - Exports for bitmap handling. Part of the Linux-NTFS project.
 
3
 *
 
4
 * Copyright (c) 2000-2004 Anton Altaparmakov
 
5
 * Copyright (c) 2004-2005 Richard Russon
 
6
 *
 
7
 * This program/include file is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License as published
 
9
 * by the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program/include file is distributed in the hope that it will be
 
13
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 
14
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program (in the main directory of the Linux-NTFS
 
19
 * distribution in the file COPYING); if not, write to the Free Software
 
20
 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
 */
 
22
 
 
23
#ifndef _NTFS_BITMAP_H
 
24
#define _NTFS_BITMAP_H
 
25
 
 
26
#include "types.h"
 
27
#include "attrib.h"
 
28
 
 
29
/*
 
30
 * NOTES:
 
31
 *
 
32
 * - Operations are 8-bit only to ensure the functions work both on little
 
33
 *   and big endian machines! So don't make them 32-bit ops!
 
34
 * - bitmap starts at bit = 0 and ends at bit = bitmap size - 1.
 
35
 * - _Caller_ has to make sure that the bit to operate on is less than the
 
36
 *   size of the bitmap.
 
37
 */
 
38
 
 
39
extern void ntfs_bit_set(u8 *bitmap, const u64 bit, const u8 new_value);
 
40
extern char ntfs_bit_get(const u8 *bitmap, const u64 bit);
 
41
extern char ntfs_bit_get_and_set(u8 *bitmap, const u64 bit, const u8 new_value);
 
42
extern int  ntfs_bitmap_set_run(ntfs_attr *na, s64 start_bit, s64 count);
 
43
extern int  ntfs_bitmap_clear_run(ntfs_attr *na, s64 start_bit, s64 count);
 
44
 
 
45
/**
 
46
 * ntfs_bitmap_set_bit - set a bit in a bitmap
 
47
 * @na:         attribute containing the bitmap
 
48
 * @bit:        bit to set
 
49
 *
 
50
 * Set the @bit in the bitmap described by the attribute @na.
 
51
 *
 
52
 * On success return 0 and on error return -1 with errno set to the error code.
 
53
 */
 
54
static __inline__ int ntfs_bitmap_set_bit(ntfs_attr *na, s64 bit)
 
55
{
 
56
        return ntfs_bitmap_set_run(na, bit, 1);
 
57
}
 
58
 
 
59
/**
 
60
 * ntfs_bitmap_clear_bit - clear a bit in a bitmap
 
61
 * @na:         attribute containing the bitmap
 
62
 * @bit:        bit to clear
 
63
 *
 
64
 * Clear @bit in the bitmap described by the attribute @na.
 
65
 *
 
66
 * On success return 0 and on error return -1 with errno set to the error code.
 
67
 */
 
68
static __inline__ int ntfs_bitmap_clear_bit(ntfs_attr *na, s64 bit)
 
69
{
 
70
        return ntfs_bitmap_clear_run(na, bit, 1);
 
71
}
 
72
 
 
73
#endif /* defined _NTFS_BITMAP_H */
 
74