allocate.h revision 33f96c66e9a1f2e266a75e5e84c091dffa6ef118
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ALLOCATE_H_
18#define _ALLOCATE_H_
19
20#define EXT4_ALLOCATE_FAILED (u32)(~0)
21
22#include "ext4_utils.h"
23#include "ext4.h"
24
25struct block_allocation;
26
27void block_allocator_init();
28void block_allocator_free();
29u32 allocate_block();
30struct block_allocation *allocate_blocks(u32 len);
31int block_allocation_num_regions(struct block_allocation *alloc);
32int block_allocation_len(struct block_allocation *alloc);
33struct ext4_inode *get_inode(u32 inode);
34void reduce_allocation(struct block_allocation *alloc, u32 len);
35u32 get_block(struct block_allocation *alloc, u32 block);
36u32 get_oob_block(struct block_allocation *alloc, u32 block);
37void get_next_region(struct block_allocation *alloc);
38void get_region(struct block_allocation *alloc, u32 *block, u32 *len);
39u32 get_free_blocks(u32 bg);
40u32 get_free_inodes(u32 bg);
41u32 reserve_inodes(int bg, u32 inodes);
42void add_directory(u32 inode);
43u16 get_directories(int bg);
44u32 allocate_inode();
45void free_alloc(struct block_allocation *alloc);
46int reserve_oob_blocks(struct block_allocation *alloc, int blocks);
47int advance_blocks(struct block_allocation *alloc, int blocks);
48int advance_oob_blocks(struct block_allocation *alloc, int blocks);
49int last_region(struct block_allocation *alloc);
50void rewind_alloc(struct block_allocation *alloc);
51void append_region(struct block_allocation *alloc,
52	u32 block, u32 len, int bg);
53struct block_allocation *create_allocation();
54int append_oob_allocation(struct block_allocation *alloc, u32 len);
55
56#endif
57