Android-cuttlefish cvd tool
ext4_utils.h
Go to the documentation of this file.
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 _EXT4_UTILS_H_
18#define _EXT4_UTILS_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <sys/types.h>
25#include <unistd.h>
26
27#include <errno.h>
28#include <setjmp.h>
29#include <stdarg.h>
30#include <stdint.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <sys/types.h>
35
36#include "ext4_sb.h"
37
38extern int force;
39
40#define EXT4_JNL_BACKUP_BLOCKS 1
41
42#ifndef __cplusplus
43#ifndef min /* already defined by windows.h */
44#define min(a, b) ((a) < (b) ? (a) : (b))
45#endif
46#endif
47
48#define DIV_ROUND_UP(x, y) (((x) + (y)-1) / (y))
49#define EXT4_ALIGN(x, y) ((y)*DIV_ROUND_UP((x), (y)))
50
51/* XXX */
52#define cpu_to_le32(x) (x)
53#define cpu_to_le16(x) (x)
54#define le32_to_cpu(x) (x)
55#define le16_to_cpu(x) (x)
56
57#ifdef __LP64__
58typedef unsigned long u64;
59typedef signed long s64;
60
61#define PRIext4u64 "lu"
62#else
63typedef unsigned long long u64;
64typedef signed long long s64;
65
66#define PRIext4u64 PRIu64
67#endif
68typedef unsigned int u32;
69typedef unsigned short int u16;
70typedef unsigned char u8;
71
72struct block_group_info;
73struct xattr_list_element;
74
83};
84
91 struct block_group_info* bgs;
92 struct xattr_list_element* xattrs;
102};
103
104extern struct fs_info info;
105extern struct fs_aux_info aux_info;
106
107extern jmp_buf setjmp_env;
108
109int bitmap_get_bit(u8* bitmap, u32 bit); // vold
110u64 get_block_device_size(int fd); // recovery
111int is_block_device_fd(int fd); // wipe.c
112u64 get_file_size(int fd); // fs_mgr
113int ext4_bg_has_super_block(int bg);
114int read_ext(int fd, int verbose); // vold
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif
int ext4_bg_has_super_block(int bg)
Definition: ext4_utils.cpp:73
unsigned int u32
Definition: ext4_utils.h:68
u64 get_block_device_size(int fd)
Definition: ext4_utils.cpp:181
signed long long s64
Definition: ext4_utils.h:64
struct fs_aux_info aux_info
Definition: ext4_utils.cpp:43
int force
Definition: ext4_utils.cpp:41
jmp_buf setjmp_env
Definition: ext4_utils.cpp:45
struct fs_info info
Definition: ext4_utils.cpp:42
unsigned short int u16
Definition: ext4_utils.h:69
int bitmap_get_bit(u8 *bitmap, u32 bit)
Definition: ext4_utils.cpp:57
int is_block_device_fd(int fd)
u64 get_file_size(int fd)
Definition: ext4_utils.cpp:211
unsigned long long u64
Definition: ext4_utils.h:63
int read_ext(int fd, int verbose)
Definition: ext4_utils.cpp:276
unsigned char u8
Definition: ext4_utils.h:70
Definition: ext4_utils.h:75
u64 bg_inode_bitmap
Definition: ext4_utils.h:77
u64 bg_inode_table
Definition: ext4_utils.h:78
u32 bg_free_blocks_count
Definition: ext4_utils.h:79
u16 bg_flags
Definition: ext4_utils.h:82
u32 bg_free_inodes_count
Definition: ext4_utils.h:80
u32 bg_used_dirs_count
Definition: ext4_utils.h:81
u64 bg_block_bitmap
Definition: ext4_utils.h:76
Definition: ext4.h:415
Definition: ext4_utils.h:85
u32 first_data_block
Definition: ext4_utils.h:93
u64 blocks_per_dind
Definition: ext4_utils.h:100
u32 bg_desc_blocks
Definition: ext4_utils.h:97
u32 inode_table_blocks
Definition: ext4_utils.h:95
struct ext4_super_block * sb
Definition: ext4_utils.h:86
u64 len_blocks
Definition: ext4_utils.h:94
struct block_group_info * bgs
Definition: ext4_utils.h:91
u32 default_i_flags
Definition: ext4_utils.h:98
u64 blocks_per_tind
Definition: ext4_utils.h:101
struct xattr_list_element * xattrs
Definition: ext4_utils.h:92
struct ext4_super_block * sb_zero
Definition: ext4_utils.h:88
struct ext4_super_block * sb_block
Definition: ext4_utils.h:87
u32 groups
Definition: ext4_utils.h:96
struct ext4_super_block ** backup_sb
Definition: ext4_utils.h:89
u64 blocks_per_ind
Definition: ext4_utils.h:99
struct ext2_group_desc * bg_desc
Definition: ext4_utils.h:90
Definition: ext4_sb.h:30
void verbose(const char *fmt,...)
Definition: util.cpp:69