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