summaryrefslogtreecommitdiff
path: root/rpmdb/falloc.h
blob: b8d21fda08ea44c55ebe98f1fbf5db6d4a6d44b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef H_FALLOC
#define H_FALLOC

/** \ingroup db1
 * \file rpmdb/falloc.h
 * File space allocation routines.
 *
 * Best fit allocation is used, free blocks are compacted. Minimal
 * fragmentation is more important then speed. This uses 32 bit
 * offsets on all platforms and should be byte order independent.
 */

/*@access FD_t@*/

#ifdef __cplusplus
extern "C" {
#endif

/*@unused@*/ static inline long int fadGetFileSize(FD_t fd) /*@*/ {
    return fd->fileSize;
}

/*@unused@*/ static inline void fadSetFileSize(FD_t fd, long int fileSize)
	/*@modifies fd @*/
{
    fd->fileSize = fileSize;
}

/*@unused@*/ static inline unsigned int fadGetFirstFree(FD_t fd) /*@*/ {
    return fd->firstFree;
}

/*@unused@*/ static inline void fadSetFirstFree(FD_t fd, unsigned int firstFree)
	/*@modifies fd @*/
{
    fd->firstFree = firstFree;
}

/** \ingroup db1
 */
/*@null@*/ FD_t	fadOpen(const char * path, int flags, mode_t perms)
	/*@modifies fileSystem @*/;

/** \ingroup db1
 * @param fd		file handle
 * @return		0 on failure
 */
unsigned int fadAlloc(FD_t fd, unsigned int size)
	/*@modifies fd, fileSystem @*/;

/** \ingroup db1
 * @param fd		file handle
 */
void fadFree(FD_t fd, unsigned int offset)
	/*@modifies fd, fileSystem @*/;

/** \ingroup db1
 * @param fd		file handle
 */
int fadFirstOffset(FD_t fd)
	/*@modifies fd, fileSystem @*/;

/** \ingroup db1
 * @param fd		file handle
 * @return		next offset, 0 to terminate
 */
int fadNextOffset(FD_t fd, unsigned int lastoff)
	/*@modifies fd, fileSystem @*/;

#ifdef __cplusplus
}
#endif

#endif	/* H_FALLOC */