allocate.h revision 4df62f342dbbe2f5cca831ce789dc0426d32ec03
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"
244df62f342dbbe2f5cca831ce789dc0426d32ec03Nick Kralevich#include "xattr.h"
25ec0a2e83dc66d67addeb90e83144187691852a3eColin Cross
26ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossstruct block_allocation;
27ec0a2e83dc66d67addeb90e83144187691852a3eColin Cross
28ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid block_allocator_init();
29ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid block_allocator_free();
30ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 allocate_block();
31ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossstruct block_allocation *allocate_blocks(u32 len);
32ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint block_allocation_num_regions(struct block_allocation *alloc);
33ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint block_allocation_len(struct block_allocation *alloc);
34ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossstruct ext4_inode *get_inode(u32 inode);
354df62f342dbbe2f5cca831ce789dc0426d32ec03Nick Kralevichstruct ext4_xattr_header *get_xattr_block_for_inode(struct ext4_inode *inode);
36ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid reduce_allocation(struct block_allocation *alloc, u32 len);
37ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 get_block(struct block_allocation *alloc, u32 block);
38ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 get_oob_block(struct block_allocation *alloc, u32 block);
39ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid get_next_region(struct block_allocation *alloc);
40ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid get_region(struct block_allocation *alloc, u32 *block, u32 *len);
41ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 get_free_blocks(u32 bg);
42ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 get_free_inodes(u32 bg);
43ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 reserve_inodes(int bg, u32 inodes);
44ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid add_directory(u32 inode);
45ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu16 get_directories(int bg);
4656497f28bd20001dd5f931208e8d948cf2f81b2fColin Crossu16 get_bg_flags(int bg);
47107a9f161babc20daf915311146b0e864d3b4157Ken Sumrallvoid init_unused_inode_tables(void);
48ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossu32 allocate_inode();
49ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid free_alloc(struct block_allocation *alloc);
50ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint reserve_oob_blocks(struct block_allocation *alloc, int blocks);
51ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint advance_blocks(struct block_allocation *alloc, int blocks);
52ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint advance_oob_blocks(struct block_allocation *alloc, int blocks);
53ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint last_region(struct block_allocation *alloc);
54ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid rewind_alloc(struct block_allocation *alloc);
55ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossvoid append_region(struct block_allocation *alloc,
568aef66d2125af8de7672a12895276802fcc1948fColin Cross	u32 block, u32 len, int bg);
57ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossstruct block_allocation *create_allocation();
58ec0a2e83dc66d67addeb90e83144187691852a3eColin Crossint append_oob_allocation(struct block_allocation *alloc, u32 len);
5933f96c66e9a1f2e266a75e5e84c091dffa6ef118Colin Cross
6033f96c66e9a1f2e266a75e5e84c091dffa6ef118Colin Cross#endif
61