blob: 25ce7b54442d5445682a8db94f3c60b26701a998 (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* erofs_utils/include/erofs/internal.h
*
* Copyright (C) 2019 HUAWEI, Inc.
* http://www.huawei.com/
* Created by Gao Xiang <gaoxiang25@huawei.com>
*/
#ifndef __EROFS_INTERNAL_H
#define __EROFS_INTERNAL_H
#include "list.h"
#include "err.h"
typedef unsigned short umode_t;
#define __packed __attribute__((__packed__))
#include "erofs_fs.h"
#include <fcntl.h>
#ifndef PATH_MAX
#define PATH_MAX 4096 /* # chars in a path name including nul */
#endif
#define PAGE_SHIFT (12)
#define PAGE_SIZE (1U << PAGE_SHIFT)
#define LOG_BLOCK_SIZE (12)
#define EROFS_BLKSIZ (1U << LOG_BLOCK_SIZE)
#define EROFS_ISLOTBITS 5
#define EROFS_SLOTSIZE (1U << EROFS_ISLOTBITS)
typedef u64 erofs_off_t;
typedef u64 erofs_nid_t;
/* data type for filesystem-wide blocks number */
typedef u32 erofs_blk_t;
#define NULL_ADDR ((unsigned int)-1)
#define NULL_ADDR_UL ((unsigned long)-1)
#define erofs_blknr(addr) ((addr) / EROFS_BLKSIZ)
#define erofs_blkoff(addr) ((addr) % EROFS_BLKSIZ)
#define blknr_to_addr(nr) ((erofs_off_t)(nr) * EROFS_BLKSIZ)
#define BLK_ROUND_UP(addr) DIV_ROUND_UP(addr, EROFS_BLKSIZ)
struct erofs_buffer_head;
struct erofs_sb_info {
erofs_blk_t meta_blkaddr;
erofs_blk_t xattr_blkaddr;
u32 feature_incompat;
u64 build_time;
u32 build_time_nsec;
};
/* global sbi */
extern struct erofs_sb_info sbi;
struct erofs_inode {
struct list_head i_hash, i_subdirs, i_xattrs;
unsigned int i_count;
struct erofs_inode *i_parent;
umode_t i_mode;
erofs_off_t i_size;
u64 i_ino[2];
u32 i_uid;
u32 i_gid;
u64 i_ctime;
u32 i_ctime_nsec;
u32 i_nlink;
union {
u32 i_blkaddr;
u32 i_blocks;
u32 i_rdev;
} u;
char i_srcpath[PATH_MAX + 1];
unsigned char datalayout;
unsigned char inode_isize;
/* inline tail-end packing size */
unsigned short idata_size;
unsigned int xattr_isize;
unsigned int extent_isize;
erofs_nid_t nid;
struct erofs_buffer_head *bh;
struct erofs_buffer_head *bh_inline, *bh_data;
void *idata;
void *compressmeta;
};
static inline bool is_inode_layout_compression(struct erofs_inode *inode)
{
return erofs_inode_is_data_compressed(inode->datalayout);
}
#define IS_ROOT(x) ((x) == (x)->i_parent)
struct erofs_dentry {
struct list_head d_child; /* child of parent list */
unsigned int type;
char name[EROFS_NAME_LEN];
union {
struct erofs_inode *inode;
erofs_nid_t nid;
};
};
static inline bool is_dot_dotdot(const char *name)
{
if (name[0] != '.')
return false;
return name[1] == '\0' || (name[1] == '.' && name[2] == '\0');
}
#include <stdio.h>
#include <string.h>
static inline const char *erofs_strerror(int err)
{
static char msg[256];
sprintf(msg, "[Error %d] %s", -err, strerror(-err));
return msg;
}
#endif
|