reiserfsprogs: annotate for endian safeness
By annotating structure members and other on-disk structures as little endian, we can catch bugs more easily. The code was already endian safe except for three minor spots: 1) The badblock list code was initializing its key in an endian-unsafe way. 2) Indirect block pointer sequence printing was treating cpu-order values as little endian. 3) reiserfsck was trying to do endian switching on the lost+found key, but it was before it was even initialized to anything, so we can just remove that completely. These issues were fixed as part of this commit. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
1 parent
767f7b85df
commit
81aeadf510
26 files changed
+241
-220
No files matched your search
@@ -523,7 +523,7 @@ void do_one_corruption_in_one_block(reiserfs_filsys_t *fs,
|
|||||||
"not so many unfm ptrs in it\n");
|
"not so many unfm ptrs in it\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d32_put((__u32 *) ih_item_body(bh, ih), pos_in_item,
|
d32_put((__le32 *) ih_item_body(bh, ih), pos_in_item,
|
||||||
get_sb_block_count(fs->fs_ondisk_sb) + 100);
|
get_sb_block_count(fs->fs_ondisk_sb) + 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ static void print_disk_tree(reiserfs_filsys_t *fs, unsigned long block_nr)
|
|||||||
count = leaf_item_number_estimate(bh);
|
count = leaf_item_number_estimate(bh);
|
||||||
for (i = 0; i < count; i++, ih++) {
|
for (i = 0; i < count; i++, ih++) {
|
||||||
if (is_indirect_ih(ih)) {
|
if (is_indirect_ih(ih)) {
|
||||||
__u32 *ind_item = (__u32 *) ih_item_body(bh, ih);
|
__le32 *ind_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
||||||
if (d32_get(ind_item, j)) {
|
if (d32_get(ind_item, j)) {
|
||||||
@@ -571,11 +571,11 @@ static void callback_badblock_print(reiserfs_filsys_t *fs,
|
|||||||
{
|
{
|
||||||
struct item_head *tmp_ih;
|
struct item_head *tmp_ih;
|
||||||
FILE *fd = (FILE *) data;
|
FILE *fd = (FILE *) data;
|
||||||
__u32 *ind_item;
|
__le32 *ind_item;
|
||||||
__u32 i;
|
__u32 i;
|
||||||
|
|
||||||
tmp_ih = tp_item_head(badblock_path);
|
tmp_ih = tp_item_head(badblock_path);
|
||||||
ind_item = (__u32 *) tp_item_body(badblock_path);
|
ind_item = (__le32 *) tp_item_body(badblock_path);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++)
|
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++)
|
||||||
fprintf(fd, "%u\n", d32_get(ind_item, i));
|
fprintf(fd, "%u\n", d32_get(ind_item, i));
|
||||||
|
|||||||
@@ -134,21 +134,21 @@ struct packed_dir_entry {
|
|||||||
|
|
||||||
#define fread_le16(pv)\
|
#define fread_le16(pv)\
|
||||||
{\
|
{\
|
||||||
__u16 tmp; \
|
__le16 tmp; \
|
||||||
fread16(&tmp); \
|
fread16(&tmp); \
|
||||||
*pv = le16_to_cpu(tmp); \
|
*pv = le16_to_cpu(tmp); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define fread_le32(pv)\
|
#define fread_le32(pv)\
|
||||||
{\
|
{\
|
||||||
__u32 tmp; \
|
__le32 tmp; \
|
||||||
fread32(&tmp); \
|
fread32(&tmp); \
|
||||||
*pv = le32_to_cpu(tmp); \
|
*pv = le32_to_cpu(tmp); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define fread_le64(pv)\
|
#define fread_le64(pv)\
|
||||||
{\
|
{\
|
||||||
__u64 tmp; \
|
__le64 tmp; \
|
||||||
fread64(&tmp); \
|
fread64(&tmp); \
|
||||||
*pv = le64_to_cpu(tmp); \
|
*pv = le64_to_cpu(tmp); \
|
||||||
}
|
}
|
||||||
@@ -160,19 +160,19 @@ struct packed_dir_entry {
|
|||||||
|
|
||||||
#define fwrite_le16(pv)\
|
#define fwrite_le16(pv)\
|
||||||
{\
|
{\
|
||||||
__u16 tmp = cpu_to_le16(*(pv));\
|
__le16 tmp = cpu_to_le16(*(pv));\
|
||||||
fwrite16(&tmp);\
|
fwrite16(&tmp);\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define fwrite_le32(pv)\
|
#define fwrite_le32(pv)\
|
||||||
{\
|
{\
|
||||||
__u32 tmp = cpu_to_le32(*(pv));\
|
__le32 tmp = cpu_to_le32(*(pv));\
|
||||||
fwrite32(&tmp);\
|
fwrite32(&tmp);\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define fwrite_le64(pv)\
|
#define fwrite_le64(pv)\
|
||||||
{\
|
{\
|
||||||
__u64 tmp = cpu_to_le64(*(pv));\
|
__le64 tmp = cpu_to_le64(*(pv));\
|
||||||
fwrite64(&tmp);\
|
fwrite64(&tmp);\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,14 +100,14 @@ static void pack_direct(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
|
|
||||||
if (get_pi_mask(pi) & SAFE_LINK)
|
if (get_pi_mask(pi) & SAFE_LINK)
|
||||||
set_key_dirid(&ih->ih_key,
|
set_key_dirid(&ih->ih_key,
|
||||||
d32_get((__u32 *) ih_item_body(bh, ih), 0));
|
d32_get((__le32 *) ih_item_body(bh, ih), 0));
|
||||||
|
|
||||||
/* send key components which are to be sent */
|
/* send key components which are to be sent */
|
||||||
pack_ih(pi, ih);
|
pack_ih(pi, ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if there is at least one extent longer than 2 - it is worth packing */
|
/* if there is at least one extent longer than 2 - it is worth packing */
|
||||||
static int should_pack_indirect(__u32 * ind_item, int unfm_num)
|
static int should_pack_indirect(__le32 * ind_item, int unfm_num)
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
@@ -132,13 +132,13 @@ static void pack_indirect(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
struct item_head *ih)
|
struct item_head *ih)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
__u32 *ind_item;
|
__le32 *ind_item;
|
||||||
__u16 len;
|
__u16 len;
|
||||||
|
|
||||||
if (get_ih_entry_count(ih))
|
if (get_ih_entry_count(ih))
|
||||||
set_pi_mask(pi, get_pi_mask(pi) | IH_FREE_SPACE);
|
set_pi_mask(pi, get_pi_mask(pi) | IH_FREE_SPACE);
|
||||||
|
|
||||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
ind_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
if (!should_pack_indirect(ind_item, I_UNFM_NUM(ih)))
|
if (!should_pack_indirect(ind_item, I_UNFM_NUM(ih)))
|
||||||
set_pi_mask(pi, get_pi_mask(pi) | WHOLE_INDIRECT);
|
set_pi_mask(pi, get_pi_mask(pi) | WHOLE_INDIRECT);
|
||||||
|
|
||||||
@@ -275,8 +275,8 @@ static void pack_stat_data(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
*/
|
*/
|
||||||
struct stat_data *sd;
|
struct stat_data *sd;
|
||||||
/* these will maintain disk-order values */
|
/* these will maintain disk-order values */
|
||||||
__u16 nlink16;
|
__le16 nlink16;
|
||||||
__u32 nlink32, size32;
|
__le32 nlink32, size32;
|
||||||
__u64 size64;
|
__u64 size64;
|
||||||
|
|
||||||
sd = (struct stat_data *)ih_item_body(bh, ih);
|
sd = (struct stat_data *)ih_item_body(bh, ih);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void do_recover(reiserfs_filsys_t fs)
|
|||||||
|
|
||||||
ih = item_head(bh, 0);
|
ih = item_head(bh, 0);
|
||||||
for (i = 0; i < node_item_number(bh); i++, ih++) {
|
for (i = 0; i < node_item_number(bh); i++, ih++) {
|
||||||
__u32 *indirect;
|
__le32 *indirect;
|
||||||
struct buffer_head *tmp_bh;
|
struct buffer_head *tmp_bh;
|
||||||
|
|
||||||
if (!is_indirect_ih(ih)
|
if (!is_indirect_ih(ih)
|
||||||
@@ -385,7 +385,7 @@ static void recover_items(FILE * fp, reiserfs_filsys_t *fs, FILE * target_file)
|
|||||||
} else if (is_indirect_ih(ih)) {
|
} else if (is_indirect_ih(ih)) {
|
||||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||||
unfm_ptr =
|
unfm_ptr =
|
||||||
d32_get((__u32 *) ih_item_body(bh, ih), j);
|
d32_get((__le32 *) ih_item_body(bh, ih), j);
|
||||||
if (!unfm_ptr) {
|
if (!unfm_ptr) {
|
||||||
fseek(target_file, fs->fs_blocksize,
|
fseek(target_file, fs->fs_blocksize,
|
||||||
SEEK_CUR);
|
SEEK_CUR);
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ static void unpack_stat_data(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
|
static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
|
||||||
struct item_head *ih)
|
struct item_head *ih)
|
||||||
{
|
{
|
||||||
__u32 *ind_item, *end;
|
__le32 *ind_item, *end;
|
||||||
int i;
|
int i;
|
||||||
__u16 v16;
|
__u16 v16;
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
set_ih_entry_count(ih, 0);
|
set_ih_entry_count(ih, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
ind_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
if (get_pi_mask(pi) & SAFE_LINK) {
|
if (get_pi_mask(pi) & SAFE_LINK) {
|
||||||
d32_put(ind_item, 0, get_key_dirid(&ih->ih_key));
|
d32_put(ind_item, 0, get_key_dirid(&ih->ih_key));
|
||||||
@@ -263,7 +263,7 @@ static void unpack_indirect(struct packed_item *pi, struct buffer_head *bh,
|
|||||||
static void unpack_direct(struct packed_item *pi, struct buffer_head *bh,
|
static void unpack_direct(struct packed_item *pi, struct buffer_head *bh,
|
||||||
struct item_head *ih)
|
struct item_head *ih)
|
||||||
{
|
{
|
||||||
__u32 *d_item = (__u32 *) ih_item_body(bh, ih);
|
__le32 *d_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
if (!(get_pi_mask(pi) & IH_FREE_SPACE))
|
if (!(get_pi_mask(pi) & IH_FREE_SPACE))
|
||||||
/* ih_free_space was not packed - set default */
|
/* ih_free_space was not packed - set default */
|
||||||
@@ -285,8 +285,8 @@ static void unpack_leaf(int dev, hashf_t hash_func, __u16 blocksize)
|
|||||||
struct packed_item pi;
|
struct packed_item pi;
|
||||||
struct item_head *ih;
|
struct item_head *ih;
|
||||||
int i;
|
int i;
|
||||||
__u16 v16;
|
__le16 v16;
|
||||||
__u32 v32;
|
__le32 v32;
|
||||||
|
|
||||||
/* block number */
|
/* block number */
|
||||||
fread_le32(&v32);
|
fread_le32(&v32);
|
||||||
@@ -489,7 +489,7 @@ void unpack_partition(int fd, int jfd)
|
|||||||
{
|
{
|
||||||
__u32 magic32;
|
__u32 magic32;
|
||||||
long position;
|
long position;
|
||||||
__u16 magic16;
|
__le16 magic16;
|
||||||
__u16 blocksize;
|
__u16 blocksize;
|
||||||
int dev = fd;
|
int dev = fd;
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -388,7 +388,8 @@ static int bad_direct_item(reiserfs_filsys_t *fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void handle_one_pointer(reiserfs_filsys_t *fs,
|
inline void handle_one_pointer(reiserfs_filsys_t *fs,
|
||||||
struct buffer_head *bh, __u32 * item, int offset)
|
struct buffer_head *bh, __le32 * item,
|
||||||
|
int offset)
|
||||||
{
|
{
|
||||||
if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
|
if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
|
||||||
fsck_log(" - zeroed");
|
fsck_log(" - zeroed");
|
||||||
@@ -403,7 +404,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
|||||||
struct item_head *ih)
|
struct item_head *ih)
|
||||||
{
|
{
|
||||||
__u32 i;
|
__u32 i;
|
||||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
__le32 *ind = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
if (get_ih_item_len(ih) % 4) {
|
if (get_ih_item_len(ih) % 4) {
|
||||||
fsck_log("%s: block %lu: item (%H) has bad length\n",
|
fsck_log("%s: block %lu: item (%H) has bad length\n",
|
||||||
@@ -477,7 +478,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
|||||||
static int bad_indirect_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
static int bad_indirect_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||||
struct item_head *ih)
|
struct item_head *ih)
|
||||||
{
|
{
|
||||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
__le32 *ind = (__le32 *) ih_item_body(bh, ih);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (get_ih_item_len(ih) % 4) {
|
if (get_ih_item_len(ih) % 4) {
|
||||||
|
|||||||
@@ -1331,10 +1331,6 @@ int main(int argc, char *argv[])
|
|||||||
screen_savebuffer = getmem(screen_width + 1);
|
screen_savebuffer = getmem(screen_width + 1);
|
||||||
memset(screen_savebuffer, 0, screen_savebuffer_len + 1);
|
memset(screen_savebuffer, 0, screen_savebuffer_len + 1);
|
||||||
|
|
||||||
lost_found_dir_key.k2_dir_id =
|
|
||||||
cpu_to_le32(lost_found_dir_key.k2_dir_id);
|
|
||||||
lost_found_dir_key.k2_objectid =
|
|
||||||
cpu_to_le32(lost_found_dir_key.k2_objectid);
|
|
||||||
/* this is only needed (and works) when running under 2.4 on regular files */
|
/* this is only needed (and works) when running under 2.4 on regular files */
|
||||||
if (setrlimit(RLIMIT_FSIZE, &rlim) == -1) {
|
if (setrlimit(RLIMIT_FSIZE, &rlim) == -1) {
|
||||||
reiserfs_warning(stderr,
|
reiserfs_warning(stderr,
|
||||||
|
|||||||
+3
-3
@@ -676,7 +676,7 @@ static void pass0_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
|||||||
int file_format = KEY_FORMAT_UNDEFINED;
|
int file_format = KEY_FORMAT_UNDEFINED;
|
||||||
struct item_head *ih;
|
struct item_head *ih;
|
||||||
|
|
||||||
__u32 *ind_item;
|
__le32 *ind_item;
|
||||||
__u64 fs_size;
|
__u64 fs_size;
|
||||||
__u64 offset;
|
__u64 offset;
|
||||||
int symlnk = 0;
|
int symlnk = 0;
|
||||||
@@ -1607,7 +1607,7 @@ start_again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
ind_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
||||||
unfm_ptr = d32_get(ind_item, j);
|
unfm_ptr = d32_get(ind_item, j);
|
||||||
if (!unfm_ptr)
|
if (!unfm_ptr)
|
||||||
@@ -1766,7 +1766,7 @@ static int is_bad_indirect(struct item_head *ih, char *item, int dev,
|
|||||||
blocks = get_sb_block_count(fs->fs_ondisk_sb);
|
blocks = get_sb_block_count(fs->fs_ondisk_sb);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||||
__u32 *ind = (__u32 *) item;
|
__le32 *ind = (__le32 *) item;
|
||||||
|
|
||||||
if (d32_get(ind, i) >= blocks) {
|
if (d32_get(ind, i) >= blocks) {
|
||||||
bad++;
|
bad++;
|
||||||
|
|||||||
+4
-4
@@ -94,11 +94,11 @@ static char *still_bad_unfm_ptr_to_string(int val)
|
|||||||
static void indirect_in_tree(struct buffer_head *bh, struct item_head *ih)
|
static void indirect_in_tree(struct buffer_head *bh, struct item_head *ih)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
__u32 *unp;
|
__le32 *unp;
|
||||||
__u32 unfm_ptr;
|
__u32 unfm_ptr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
unp = (__u32 *) ih_item_body(bh, ih);
|
unp = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||||
unfm_ptr = d32_get(unp, i);
|
unfm_ptr = d32_get(unp, i);
|
||||||
@@ -344,7 +344,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
|||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
struct item_head *ih;
|
struct item_head *ih;
|
||||||
__u32 *ind_item;
|
__le32 *ind_item;
|
||||||
__u32 unfm_ptr;
|
__u32 unfm_ptr;
|
||||||
int dirty = 0;
|
int dirty = 0;
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* correct indirect items */
|
/* correct indirect items */
|
||||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
ind_item = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||||
unfm_ptr = d32_get(ind_item, j);
|
unfm_ptr = d32_get(ind_item, j);
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
|||||||
static int check_safe_links(void)
|
static int check_safe_links(void)
|
||||||
{
|
{
|
||||||
struct reiserfs_path safe_link_path, path;
|
struct reiserfs_path safe_link_path, path;
|
||||||
struct reiserfs_key safe_link_key = { -1, 0, {{0, 0}} };
|
struct reiserfs_key safe_link_key = { cpu_to_le32(-1), 0, {{0, 0}} };
|
||||||
struct reiserfs_key key = { 0, 0, {{0, 0}} };
|
struct reiserfs_key key = { 0, 0, {{0, 0}} };
|
||||||
struct reiserfs_key *rkey;
|
struct reiserfs_key *rkey;
|
||||||
struct item_head *tmp_ih;
|
struct item_head *tmp_ih;
|
||||||
@@ -784,7 +784,7 @@ static int check_safe_links(void)
|
|||||||
get_ih_item_len(tmp_ih));
|
get_ih_item_len(tmp_ih));
|
||||||
|
|
||||||
set_key_dirid(&key,
|
set_key_dirid(&key,
|
||||||
d32_get((__u32 *) tp_item_body(&safe_link_path), 0));
|
d32_get((__le32 *) tp_item_body(&safe_link_path), 0));
|
||||||
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
||||||
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
||||||
set_key_dirid(&safe_link_key, 0);
|
set_key_dirid(&safe_link_key, 0);
|
||||||
@@ -803,7 +803,7 @@ static int check_safe_links(void)
|
|||||||
("Invalid safe link %k: cannot find the pointed object (%K) - "
|
("Invalid safe link %k: cannot find the pointed object (%K) - "
|
||||||
"safe link was deleted\n", &tmp_ih->ih_key,
|
"safe link was deleted\n", &tmp_ih->ih_key,
|
||||||
&key);
|
&key);
|
||||||
d32_put((__u32 *) tp_item_body(&safe_link_path), 0,
|
d32_put((__le32 *) tp_item_body(&safe_link_path), 0,
|
||||||
0);
|
0);
|
||||||
pathrelse(&path);
|
pathrelse(&path);
|
||||||
reiserfsck_delete_item(&safe_link_path, 0);
|
reiserfsck_delete_item(&safe_link_path, 0);
|
||||||
@@ -825,7 +825,7 @@ static int check_safe_links(void)
|
|||||||
("Invalid 'truncate' safe link %k, cannot happen for "
|
("Invalid 'truncate' safe link %k, cannot happen for "
|
||||||
"a directory (%K) - safe link was deleted\n",
|
"a directory (%K) - safe link was deleted\n",
|
||||||
&tmp_ih->ih_key, &key);
|
&tmp_ih->ih_key, &key);
|
||||||
d32_put((__u32 *)
|
d32_put((__le32 *)
|
||||||
tp_item_body(&safe_link_path), 0,
|
tp_item_body(&safe_link_path), 0,
|
||||||
0);
|
0);
|
||||||
pathrelse(&path);
|
pathrelse(&path);
|
||||||
|
|||||||
+1
-1
@@ -540,7 +540,7 @@ void rebuild_sb(reiserfs_filsys_t *fs, char *filename, struct fsck_data *data)
|
|||||||
"generated (%U)\n", sb->s_uuid);
|
"generated (%U)\n", sb->s_uuid);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (sb->s_flags != 0 && sb->s_flags != 1) {
|
if (sb->s_flags != 0 && sb->s_flags != cpu_to_le32(1)) {
|
||||||
fsck_log
|
fsck_log
|
||||||
("rebuild-sb: super block flags found (%u), zeroed\n",
|
("rebuild-sb: super block flags found (%u), zeroed\n",
|
||||||
sb->s_flags);
|
sb->s_flags);
|
||||||
|
|||||||
+20
-20
@@ -57,7 +57,7 @@ static unsigned long indirect_to_direct(struct reiserfs_path *path, __u64 len,
|
|||||||
TYPE_DIRECT);
|
TYPE_DIRECT);
|
||||||
|
|
||||||
// we do not know what length this item should be
|
// we do not know what length this item should be
|
||||||
unfm_ptr = d32_get((__u32 *) tp_item_body(path), I_UNFM_NUM(ih) - 1);
|
unfm_ptr = d32_get((__le32 *) tp_item_body(path), I_UNFM_NUM(ih) - 1);
|
||||||
if (unfm_ptr && (unfm_bh = bread(bh->b_dev, unfm_ptr, bh->b_size))) {
|
if (unfm_ptr && (unfm_bh = bread(bh->b_dev, unfm_ptr, bh->b_size))) {
|
||||||
/* we can read the block */
|
/* we can read the block */
|
||||||
buf = unfm_bh->b_data;
|
buf = unfm_bh->b_data;
|
||||||
@@ -375,8 +375,8 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
|||||||
else
|
else
|
||||||
for (i = 0; i < I_UNFM_NUM(ih);
|
for (i = 0; i < I_UNFM_NUM(ih);
|
||||||
i++) {
|
i++) {
|
||||||
__u32 *ind =
|
__le32 *ind =
|
||||||
(__u32 *)
|
(__le32 *)
|
||||||
tp_item_body(&path);
|
tp_item_body(&path);
|
||||||
|
|
||||||
if (d32_get(ind, i) !=
|
if (d32_get(ind, i) !=
|
||||||
@@ -413,8 +413,8 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
|||||||
FIXABLE);
|
FIXABLE);
|
||||||
pathrelse(&path);
|
pathrelse(&path);
|
||||||
} else {
|
} else {
|
||||||
__u32 *ind =
|
__le32 *ind =
|
||||||
(__u32 *) tp_item_body(&path);
|
(__le32 *) tp_item_body(&path);
|
||||||
/* DEBUG message.
|
/* DEBUG message.
|
||||||
fsck_log ("are_file_items_correct: The indirect item is converted back to direct %K\n", &ih->ih_key);
|
fsck_log ("are_file_items_correct: The indirect item is converted back to direct %K\n", &ih->ih_key);
|
||||||
*/
|
*/
|
||||||
@@ -647,8 +647,8 @@ static int create_first_item_of_file(struct item_head *ih, char *item,
|
|||||||
struct reiserfs_path *path,
|
struct reiserfs_path *path,
|
||||||
int was_in_tree)
|
int was_in_tree)
|
||||||
{
|
{
|
||||||
__u32 unfm_ptr;
|
__le32 unfm_ptr;
|
||||||
__u32 *ni = 0;
|
__le32 *ni = 0;
|
||||||
struct buffer_head *unbh;
|
struct buffer_head *unbh;
|
||||||
struct item_head indih;
|
struct item_head indih;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -743,7 +743,7 @@ static unsigned long block_to_start(struct reiserfs_path *path)
|
|||||||
return bh->b_blocknr;
|
return bh->b_blocknr;
|
||||||
|
|
||||||
ih--;
|
ih--;
|
||||||
blk = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
blk = d32_get((__le32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||||
return (blk ? blk : bh->b_blocknr);
|
return (blk ? blk : bh->b_blocknr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +752,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
|||||||
struct item_head *ih;
|
struct item_head *ih;
|
||||||
struct reiserfs_key key;
|
struct reiserfs_key key;
|
||||||
struct buffer_head *unbh;
|
struct buffer_head *unbh;
|
||||||
__u32 ni;
|
__le32 ni;
|
||||||
int copied = 0;
|
int copied = 0;
|
||||||
int file_format;
|
int file_format;
|
||||||
|
|
||||||
@@ -856,7 +856,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
|||||||
int zero_number;
|
int zero_number;
|
||||||
|
|
||||||
bh = PATH_PLAST_BUFFER(path);
|
bh = PATH_PLAST_BUFFER(path);
|
||||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
unfm_ptr = d32_get((__le32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||||
|
|
||||||
/* append to free space of the last unformatted node of indirect item ih */
|
/* append to free space of the last unformatted node of indirect item ih */
|
||||||
free_space =
|
free_space =
|
||||||
@@ -896,7 +896,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
|||||||
/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) { */
|
/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) { */
|
||||||
unbh = reiserfsck_get_new_buffer(bh->b_blocknr);
|
unbh = reiserfsck_get_new_buffer(bh->b_blocknr);
|
||||||
memset(unbh->b_data, 0, unbh->b_size);
|
memset(unbh->b_data, 0, unbh->b_size);
|
||||||
d32_put((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1,
|
d32_put((__le32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1,
|
||||||
unbh->b_blocknr);
|
unbh->b_blocknr);
|
||||||
/*mark_block_unformatted (unbh->b_blocknr); */
|
/*mark_block_unformatted (unbh->b_blocknr); */
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
@@ -924,7 +924,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
|||||||
int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
||||||
struct reiserfs_path *path, int was_in_tree)
|
struct reiserfs_path *path, int was_in_tree)
|
||||||
{
|
{
|
||||||
__u32 *ni;
|
__le32 *ni;
|
||||||
struct buffer_head *unbh;
|
struct buffer_head *unbh;
|
||||||
int retval;
|
int retval;
|
||||||
struct item_head *ih = tp_item_head(path);
|
struct item_head *ih = tp_item_head(path);
|
||||||
@@ -1023,7 +1023,7 @@ long long int must_there_be_a_hole(struct item_head *comingih,
|
|||||||
int reiserfs_append_zero_unfm_ptr(struct reiserfs_path *path,
|
int reiserfs_append_zero_unfm_ptr(struct reiserfs_path *path,
|
||||||
long long int p_count)
|
long long int p_count)
|
||||||
{
|
{
|
||||||
__u32 *ni;
|
__le32 *ni;
|
||||||
long long int count;
|
long long int count;
|
||||||
|
|
||||||
if (is_direct_ih(tp_item_head(path)))
|
if (is_direct_ih(tp_item_head(path)))
|
||||||
@@ -1057,7 +1057,7 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
|||||||
bh = PATH_PLAST_BUFFER(path);
|
bh = PATH_PLAST_BUFFER(path);
|
||||||
ih = tp_item_head(path);
|
ih = tp_item_head(path);
|
||||||
|
|
||||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), path->pos_in_item);
|
unfm_ptr = d32_get((__le32 *) ih_item_body(bh, ih), path->pos_in_item);
|
||||||
unbh = 0;
|
unbh = 0;
|
||||||
|
|
||||||
if (unfm_ptr != 0 && unfm_ptr < get_sb_block_count(fs->fs_ondisk_sb)) {
|
if (unfm_ptr != 0 && unfm_ptr < get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||||
@@ -1070,7 +1070,7 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
|||||||
if (unfm_ptr == 0 || unfm_ptr >= get_sb_block_count(fs->fs_ondisk_sb)) {
|
if (unfm_ptr == 0 || unfm_ptr >= get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||||
if ((unbh = reiserfsck_get_new_buffer(bh->b_blocknr)) != NULL) {
|
if ((unbh = reiserfsck_get_new_buffer(bh->b_blocknr)) != NULL) {
|
||||||
memset(unbh->b_data, 0, unbh->b_size);
|
memset(unbh->b_data, 0, unbh->b_size);
|
||||||
d32_put((__u32 *) ih_item_body(bh, ih), path->pos_in_item,
|
d32_put((__le32 *) ih_item_body(bh, ih), path->pos_in_item,
|
||||||
unbh->b_blocknr);
|
unbh->b_blocknr);
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
} else {
|
} else {
|
||||||
@@ -1151,17 +1151,17 @@ void overwrite_unfm_by_unfm(unsigned long unfm_in_tree,
|
|||||||
|
|
||||||
/* put unformatted node pointers from incoming item over the in-tree ones */
|
/* put unformatted node pointers from incoming item over the in-tree ones */
|
||||||
static int overwrite_by_indirect_item(struct item_head *comingih,
|
static int overwrite_by_indirect_item(struct item_head *comingih,
|
||||||
__u32 * coming_item,
|
__le32 * coming_item,
|
||||||
struct reiserfs_path *path,
|
struct reiserfs_path *path,
|
||||||
int *pos_in_coming_item)
|
int *pos_in_coming_item)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||||
struct item_head *ih = tp_item_head(path);
|
struct item_head *ih = tp_item_head(path);
|
||||||
int written;
|
int written;
|
||||||
__u32 *item_in_tree;
|
__le32 *item_in_tree;
|
||||||
int src_unfm_ptrs, dest_unfm_ptrs, to_copy, i, dirty = 0;
|
int src_unfm_ptrs, dest_unfm_ptrs, to_copy, i, dirty = 0;
|
||||||
|
|
||||||
item_in_tree = (__u32 *) ih_item_body(bh, ih) + path->pos_in_item;
|
item_in_tree = (__le32 *) ih_item_body(bh, ih) + path->pos_in_item;
|
||||||
coming_item += *pos_in_coming_item;
|
coming_item += *pos_in_coming_item;
|
||||||
|
|
||||||
dest_unfm_ptrs = I_UNFM_NUM(ih) - path->pos_in_item;
|
dest_unfm_ptrs = I_UNFM_NUM(ih) - path->pos_in_item;
|
||||||
@@ -1224,7 +1224,7 @@ static int reiserfsck_overwrite_file(struct item_head *comingih, char *item,
|
|||||||
" be overwritten by indirect item %k",
|
" be overwritten by indirect item %k",
|
||||||
&ih->ih_key, &comingih->ih_key);
|
&ih->ih_key, &comingih->ih_key);
|
||||||
/* use pointer from coming indirect item */
|
/* use pointer from coming indirect item */
|
||||||
unfm_ptr = d32_get((__u32 *) item, *pos_in_coming_item);
|
unfm_ptr = d32_get((__le32 *) item, *pos_in_coming_item);
|
||||||
if (!was_in_tree) {
|
if (!was_in_tree) {
|
||||||
if (still_bad_unfm_ptr_2(unfm_ptr))
|
if (still_bad_unfm_ptr_2(unfm_ptr))
|
||||||
die("reiserfsck_overwrite_file: The pointer to the unformatted block (%u)" " points to the bad area.", unfm_ptr);
|
die("reiserfsck_overwrite_file: The pointer to the unformatted block (%u)" " points to the bad area.", unfm_ptr);
|
||||||
@@ -1242,7 +1242,7 @@ static int reiserfsck_overwrite_file(struct item_head *comingih, char *item,
|
|||||||
" %k cannot not be in the tree yet", &ih->ih_key,
|
" %k cannot not be in the tree yet", &ih->ih_key,
|
||||||
&comingih->ih_key);
|
&comingih->ih_key);
|
||||||
written =
|
written =
|
||||||
overwrite_by_indirect_item(comingih, (__u32 *) item, path,
|
overwrite_by_indirect_item(comingih, (__le32 *) item, path,
|
||||||
pos_in_coming_item);
|
pos_in_coming_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -213,10 +213,10 @@ void id_map_flush(struct id_map *map, reiserfs_filsys_t *fs)
|
|||||||
{
|
{
|
||||||
int size, max, i;
|
int size, max, i;
|
||||||
__u32 id, prev_id;
|
__u32 id, prev_id;
|
||||||
__u32 *sb_objectid_map;
|
__le32 *sb_objectid_map;
|
||||||
|
|
||||||
size = reiserfs_super_block_size(fs->fs_ondisk_sb);
|
size = reiserfs_super_block_size(fs->fs_ondisk_sb);
|
||||||
sb_objectid_map = (__u32 *) ((char *)(fs->fs_ondisk_sb) + size);
|
sb_objectid_map = (__le32 *) ((char *)(fs->fs_ondisk_sb) + size);
|
||||||
|
|
||||||
max = ((fs->fs_blocksize - size) >> 3 << 1);
|
max = ((fs->fs_blocksize - size) >> 3 << 1);
|
||||||
set_sb_oid_maxsize(fs->fs_ondisk_sb, max);
|
set_sb_oid_maxsize(fs->fs_ondisk_sb, max);
|
||||||
@@ -286,10 +286,10 @@ void id_map_flush(struct id_map *map, reiserfs_filsys_t *fs)
|
|||||||
void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t *fs)
|
void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t *fs)
|
||||||
{
|
{
|
||||||
int sb_size;
|
int sb_size;
|
||||||
__u32 * sb_objectid_map;
|
__le32 * sb_objectid_map;
|
||||||
|
|
||||||
sb_size = reiserfs_super_block_size (fs->fs_ondisk_sb);
|
sb_size = reiserfs_super_block_size (fs->fs_ondisk_sb);
|
||||||
sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + sb_size);
|
sb_objectid_map = (__le32 *)((char *)(fs->fs_ondisk_sb) + sb_size);
|
||||||
|
|
||||||
if (map->m_page_count != 1)
|
if (map->m_page_count != 1)
|
||||||
die ("fetch_objectid_map: can not fetch long map");
|
die ("fetch_objectid_map: can not fetch long map");
|
||||||
|
|||||||
+2
-2
@@ -40,7 +40,7 @@ void reiserfsck_insert_item(struct reiserfs_path *path, struct item_head *ih,
|
|||||||
|
|
||||||
static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
||||||
{
|
{
|
||||||
__u32 *punfm = (__u32 *) ih_item_body(bh, ih);
|
__le32 *punfm = (__le32 *) ih_item_body(bh, ih);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||||
@@ -90,7 +90,7 @@ void reiserfsck_cut_from_item(struct reiserfs_path *path, int cut_size)
|
|||||||
if (is_indirect_ih(ih = tp_item_head(path))) {
|
if (is_indirect_ih(ih = tp_item_head(path))) {
|
||||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||||
__u32 unfm_ptr =
|
__u32 unfm_ptr =
|
||||||
d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
d32_get((__le32 *)ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||||
if (unfm_ptr != 0) {
|
if (unfm_ptr != 0) {
|
||||||
struct buffer_head *to_be_forgotten;
|
struct buffer_head *to_be_forgotten;
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -250,13 +250,14 @@ int blockdev_list_compare(const void *block1, const void *block2);
|
|||||||
|
|
||||||
#define set_bit_field_XX(XX,vp,val,from,count) \
|
#define set_bit_field_XX(XX,vp,val,from,count) \
|
||||||
{\
|
{\
|
||||||
__u##XX * p, tmp;\
|
__le##XX * p;\
|
||||||
|
__u##XX tmp;\
|
||||||
\
|
\
|
||||||
/* make sure that given value can be put in 'count' bits */\
|
/* make sure that given value can be put in 'count' bits */\
|
||||||
if (val > (1 << count))\
|
if (val > (1 << count))\
|
||||||
die ("set_bit_field: val %d is too big for %d bits", val, count);\
|
die ("set_bit_field: val %d is too big for %d bits", val, count);\
|
||||||
\
|
\
|
||||||
p = (__u##XX *)vp;\
|
p = (__le##XX *)vp;\
|
||||||
tmp = le##XX##_to_cpu (*p);\
|
tmp = le##XX##_to_cpu (*p);\
|
||||||
\
|
\
|
||||||
/* clear 'count' bits starting from 'from'-th one */\
|
/* clear 'count' bits starting from 'from'-th one */\
|
||||||
@@ -270,9 +271,10 @@ int blockdev_list_compare(const void *block1, const void *block2);
|
|||||||
|
|
||||||
#define get_bit_field_XX(XX,vp,from,count) \
|
#define get_bit_field_XX(XX,vp,from,count) \
|
||||||
\
|
\
|
||||||
__u##XX * p, tmp;\
|
__le##XX * p;\
|
||||||
|
__u##XX tmp;\
|
||||||
\
|
\
|
||||||
p = (__u##XX *)vp;\
|
p = (__le##XX *)vp;\
|
||||||
tmp = le##XX##_to_cpu (*p);\
|
tmp = le##XX##_to_cpu (*p);\
|
||||||
\
|
\
|
||||||
/* clear all bits but 'count' bits starting from 'from'-th one */\
|
/* clear all bits but 'count' bits starting from 'from'-th one */\
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef _PROGBAR_H_
|
#ifndef _PROGBAR_H_
|
||||||
#define _PROGBAR_H_
|
#define _PROGBAR_H_
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
E2F_FLAG_PROG_SUPPRESS = 1,
|
E2F_FLAG_PROG_SUPPRESS = 1,
|
||||||
E2F_FLAG_PROG_BAR = 2,
|
E2F_FLAG_PROG_BAR = 2,
|
||||||
|
|||||||
+107
-100
@@ -32,6 +32,13 @@
|
|||||||
#ifndef REISERFSPROGS_FS_H
|
#ifndef REISERFSPROGS_FS_H
|
||||||
#define REISERFSPROGS_FS_H
|
#define REISERFSPROGS_FS_H
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include "swab.h"
|
||||||
|
|
||||||
|
typedef __u16 __bitwise __le16;
|
||||||
|
typedef __u32 __bitwise __le32;
|
||||||
|
typedef __u64 __bitwise __le64;
|
||||||
|
|
||||||
typedef unsigned int blocknr_t;
|
typedef unsigned int blocknr_t;
|
||||||
|
|
||||||
#ifndef get_unaligned
|
#ifndef get_unaligned
|
||||||
@@ -77,31 +84,31 @@ typedef unsigned int blocknr_t;
|
|||||||
|
|
||||||
/* super block of prejournalled version */
|
/* super block of prejournalled version */
|
||||||
struct reiserfs_super_block_v0 {
|
struct reiserfs_super_block_v0 {
|
||||||
__u32 s_block_count;
|
__le32 s_block_count;
|
||||||
__u32 s_free_blocks;
|
__le32 s_free_blocks;
|
||||||
__u32 s_root_block;
|
__le32 s_root_block;
|
||||||
__u16 s_blocksize;
|
__le16 s_blocksize;
|
||||||
__u16 s_oid_maxsize;
|
__le16 s_oid_maxsize;
|
||||||
__u16 s_oid_cursize;
|
__le16 s_oid_cursize;
|
||||||
__u16 s_state;
|
__le16 s_state;
|
||||||
char s_magic[16];
|
char s_magic[16];
|
||||||
__u16 s_tree_height;
|
__le16 s_tree_height;
|
||||||
__u16 s_bmap_nr;
|
__le16 s_bmap_nr;
|
||||||
__u16 s_reserved;
|
__le16 s_reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct journal_params {
|
struct journal_params {
|
||||||
__u32 jp_journal_1st_block; /* where does journal start from on its
|
__le32 jp_journal_1st_block; /* where does journal start from on its
|
||||||
device */
|
device */
|
||||||
__u32 jp_journal_dev; /* journal device st_rdev */
|
__le32 jp_journal_dev; /* journal device st_rdev */
|
||||||
__u32 jp_journal_size; /* size of the journal on FS creation. used to
|
__le32 jp_journal_size; /* size of the journal on FS creation. used to
|
||||||
make sure they don't overflow it */
|
make sure they don't overflow it */
|
||||||
__u32 jp_journal_trans_max; /* max number of blocks in a transaction. */
|
__le32 jp_journal_trans_max; /* max number of blocks in a transaction. */
|
||||||
__u32 jp_journal_magic; /* random value made on fs creation (this was
|
__le32 jp_journal_magic; /* random value made on fs creation (this was
|
||||||
sb_journal_block_count) */
|
sb_journal_block_count) */
|
||||||
__u32 jp_journal_max_batch; /* max number of blocks to batch into a trans */
|
__le32 jp_journal_max_batch; /* max number of blocks to batch into a trans */
|
||||||
__u32 jp_journal_max_commit_age; /* in seconds, how old can an async commit be */
|
__le32 jp_journal_max_commit_age; /* in seconds, how old can an async commit be */
|
||||||
__u32 jp_journal_max_trans_age; /* in seconds, how old can a transaction be */
|
__le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction be */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define get_jp_journal_1st_block(jp) get_le32 (jp, jp_journal_1st_block)
|
#define get_jp_journal_1st_block(jp) get_le32 (jp, jp_journal_1st_block)
|
||||||
@@ -132,35 +139,35 @@ struct journal_params {
|
|||||||
|
|
||||||
/* this is the super from 3.5.X */
|
/* this is the super from 3.5.X */
|
||||||
struct reiserfs_super_block_v1 {
|
struct reiserfs_super_block_v1 {
|
||||||
__u32 sb_block_count; /* 0 number of block on data device */
|
__le32 sb_block_count; /* 0 number of block on data device */
|
||||||
__u32 sb_free_blocks; /* 4 free blocks count */
|
__le32 sb_free_blocks; /* 4 free blocks count */
|
||||||
__u32 sb_root_block; /* 8 root of the tree */
|
__le32 sb_root_block; /* 8 root of the tree */
|
||||||
|
|
||||||
struct journal_params sb_journal; /* 12 */
|
struct journal_params sb_journal; /* 12 */
|
||||||
|
|
||||||
__u16 sb_blocksize; /* 44 */
|
__le16 sb_blocksize; /* 44 */
|
||||||
__u16 sb_oid_maxsize; /* 46 max size of object id array, see
|
__le16 sb_oid_maxsize; /* 46 max size of object id array, see
|
||||||
get_objectid() commentary */
|
get_objectid() commentary */
|
||||||
__u16 sb_oid_cursize; /* 48 current size of object id array */
|
__le16 sb_oid_cursize; /* 48 current size of object id array */
|
||||||
__u16 sb_umount_state; /* 50 this is set to 1 when filesystem was
|
__le16 sb_umount_state; /* 50 this is set to 1 when filesystem was
|
||||||
umounted, to 2 - when not */
|
umounted, to 2 - when not */
|
||||||
|
|
||||||
char s_magic[10]; /* 52 reiserfs magic string indicates that
|
char s_magic[10]; /* 52 reiserfs magic string indicates that
|
||||||
file system is reiserfs: "ReIsErFs" or
|
file system is reiserfs: "ReIsErFs" or
|
||||||
"ReIsEr2Fs" or "ReIsEr3Fs" */
|
"ReIsEr2Fs" or "ReIsEr3Fs" */
|
||||||
__u16 sb_fs_state; /* 62 it is set to used by fsck to mark which phase of
|
__le16 sb_fs_state; /* 62 it is set to used by fsck to mark which phase of
|
||||||
rebuilding is done (used for fsck debugging) */
|
rebuilding is done (used for fsck debugging) */
|
||||||
__u32 sb_hash_function_code; /* 64 code of fuction which was/is/will be
|
__le32 sb_hash_function_code; /* 64 code of fuction which was/is/will be
|
||||||
used to sort names in a directory. See
|
used to sort names in a directory. See
|
||||||
codes in above */
|
codes in above */
|
||||||
__u16 sb_tree_height; /* 68 height of filesytem tree. Tree
|
__le16 sb_tree_height; /* 68 height of filesytem tree. Tree
|
||||||
consisting of only one root block has 2
|
consisting of only one root block has 2
|
||||||
here */
|
here */
|
||||||
__u16 sb_bmap_nr; /* 70 amount of bitmap blocks needed to
|
__le16 sb_bmap_nr; /* 70 amount of bitmap blocks needed to
|
||||||
address each block of file system */
|
address each block of file system */
|
||||||
__u16 sb_version; /* 72 this field is only reliable on
|
__le16 sb_version; /* 72 this field is only reliable on
|
||||||
filesystem with non-standard journal */
|
filesystem with non-standard journal */
|
||||||
__u16 sb_reserved_for_journal; /* 74 size in blocks of journal area on
|
__le16 sb_reserved_for_journal; /* 74 size in blocks of journal area on
|
||||||
main device, we need to keep after
|
main device, we need to keep after
|
||||||
non-standard journal relocation */
|
non-standard journal relocation */
|
||||||
};
|
};
|
||||||
@@ -184,17 +191,17 @@ struct reiserfs_super_block_v1 {
|
|||||||
/* Structure of super block on disk */
|
/* Structure of super block on disk */
|
||||||
struct reiserfs_super_block {
|
struct reiserfs_super_block {
|
||||||
/* 0 */ struct reiserfs_super_block_v1 s_v1;
|
/* 0 */ struct reiserfs_super_block_v1 s_v1;
|
||||||
/* 76 */ __u32 sb_inode_generation;
|
/* 76 */ __le32 sb_inode_generation;
|
||||||
/* 80 */ __u32 s_flags;
|
/* 80 */ __le32 s_flags;
|
||||||
/* Right now used only by inode-attributes, if enabled */
|
/* Right now used only by inode-attributes, if enabled */
|
||||||
/* 84 */ unsigned char s_uuid[16];
|
/* 84 */ unsigned char s_uuid[16];
|
||||||
/* filesystem unique identifier */
|
/* filesystem unique identifier */
|
||||||
/*100 */ char s_label[16];
|
/*100 */ char s_label[16];
|
||||||
/* filesystem volume label */
|
/* filesystem volume label */
|
||||||
/*116 */ __u16 s_mnt_count;
|
/*116 */ __le16 s_mnt_count;
|
||||||
/*118 */ __u16 s_max_mnt_count;
|
/*118 */ __le16 s_max_mnt_count;
|
||||||
/*120 */ __u32 s_lastcheck;
|
/*120 */ __le32 s_lastcheck;
|
||||||
/*124 */ __u32 s_check_interval;
|
/*124 */ __le32 s_check_interval;
|
||||||
/*128 */ char s_unused[76];
|
/*128 */ char s_unused[76];
|
||||||
/* zero filled by mkreiserfs and reiserfs_convert_objectid_map_v1()
|
/* zero filled by mkreiserfs and reiserfs_convert_objectid_map_v1()
|
||||||
* so any additions must be updated there as well. */
|
* so any additions must be updated there as well. */
|
||||||
@@ -406,16 +413,16 @@ typedef enum {
|
|||||||
|
|
||||||
/* first block written in a commit. BUG, not 64bit safe */
|
/* first block written in a commit. BUG, not 64bit safe */
|
||||||
struct reiserfs_journal_desc {
|
struct reiserfs_journal_desc {
|
||||||
__u32 j2_trans_id; /* id of commit */
|
__le32 j2_trans_id; /* id of commit */
|
||||||
__u32 j2_len; /* length of commit. len +1 is the commit block */
|
__le32 j2_len; /* length of commit. len +1 is the commit block */
|
||||||
__u32 j2_mount_id; /* mount id of this trans */
|
__le32 j2_mount_id; /* mount id of this trans */
|
||||||
__u32 j2_realblock[1]; /* real locations for each block */
|
__le32 j2_realblock[1]; /* real locations for each block */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define get_jd_magic(bh) (bh->b_data + bh->b_size - 12)
|
#define get_jd_magic(bh) (bh->b_data + bh->b_size - 12)
|
||||||
|
|
||||||
#define journal_trans_half(blocksize) \
|
#define journal_trans_half(blocksize) \
|
||||||
((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32))
|
((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__le32) - 12) / sizeof (__le32))
|
||||||
|
|
||||||
#define jdesc_header(bh) ((struct reiserfs_journal_desc *)bh->b_data)
|
#define jdesc_header(bh) ((struct reiserfs_journal_desc *)bh->b_data)
|
||||||
|
|
||||||
@@ -430,9 +437,9 @@ struct reiserfs_journal_desc {
|
|||||||
|
|
||||||
/* last block written in a commit BUG, not 64bit safe */
|
/* last block written in a commit BUG, not 64bit safe */
|
||||||
struct reiserfs_journal_commit {
|
struct reiserfs_journal_commit {
|
||||||
__u32 j3_trans_id; /* must match j_trans_id from the desc block */
|
__le32 j3_trans_id; /* must match j_trans_id from the desc block */
|
||||||
__u32 j3_len; /* ditto */
|
__le32 j3_len; /* ditto */
|
||||||
__u32 j3_realblock[1]; /* real locations for each block */
|
__le32 j3_realblock[1]; /* real locations for each block */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define jcommit_header(bh) ((struct reiserfs_journal_commit *)bh->b_data)
|
#define jcommit_header(bh) ((struct reiserfs_journal_commit *)bh->b_data)
|
||||||
@@ -448,13 +455,13 @@ struct reiserfs_journal_commit {
|
|||||||
** flushed means all the log blocks and all the real blocks are on disk, and
|
** flushed means all the log blocks and all the real blocks are on disk, and
|
||||||
** this transaction does not need to be replayed. */
|
** this transaction does not need to be replayed. */
|
||||||
struct reiserfs_journal_header {
|
struct reiserfs_journal_header {
|
||||||
__u32 jh_last_flush_trans_id; /* id of last fully flushed transaction */
|
__le32 jh_last_flush_trans_id; /* id of last fully flushed transaction */
|
||||||
__u32 jh_first_unflushed_offset; /* offset in the log of where to start replay after a crash */
|
__le32 jh_first_unflushed_offset; /* offset in the log of where to start replay after a crash */
|
||||||
__u32 jh_mount_id;
|
__le32 jh_mount_id;
|
||||||
|
|
||||||
struct journal_params jh_journal;
|
struct journal_params jh_journal;
|
||||||
|
|
||||||
__u32 jh_last_check_mount_id; /* the mount id of the fs during the last reiserfsck --check. */
|
__le32 jh_last_check_mount_id; /* the mount id of the fs during the last reiserfsck --check. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* set/get fields of journal header with these defines */
|
/* set/get fields of journal header with these defines */
|
||||||
@@ -502,8 +509,8 @@ int reiserfs_replay_journal(reiserfs_filsys_t *fs);
|
|||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
struct offset_v1 {
|
struct offset_v1 {
|
||||||
__u32 k_offset;
|
__le32 k_offset;
|
||||||
__u32 k_uniqueness;
|
__le32 k_uniqueness;
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -512,13 +519,13 @@ struct offset_v1 {
|
|||||||
* bits 60-63 [4]: type
|
* bits 60-63 [4]: type
|
||||||
*/
|
*/
|
||||||
struct offset_v2 {
|
struct offset_v2 {
|
||||||
__u64 v;
|
__le64 v;
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
/* Key of the object determines object's location in the tree, composed of 4 components */
|
/* Key of the object determines object's location in the tree, composed of 4 components */
|
||||||
struct reiserfs_key {
|
struct reiserfs_key {
|
||||||
__u32 k2_dir_id; /* packing locality: by default parent directory object id */
|
__le32 k2_dir_id; /* packing locality: by default parent directory object id */
|
||||||
__u32 k2_objectid; /* object identifier */
|
__le32 k2_objectid; /* object identifier */
|
||||||
union {
|
union {
|
||||||
struct offset_v1 k2_offset_v1;
|
struct offset_v1 k2_offset_v1;
|
||||||
struct offset_v2 k2_offset_v2;
|
struct offset_v2 k2_offset_v2;
|
||||||
@@ -600,28 +607,28 @@ struct item_head {
|
|||||||
based on its key. */
|
based on its key. */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
__u16 ih2_free_space; /* The free space in the last unformatted node
|
__le16 ih2_free_space; /* The free space in the last unformatted node
|
||||||
of an indirect item if this is an indirect
|
of an indirect item if this is an indirect
|
||||||
item. This equals 0xFFFF iff this is a direct
|
item. This equals 0xFFFF iff this is a direct
|
||||||
item or stat data item. Note that the key, not
|
item or stat data item. Note that the key, not
|
||||||
this field, is used to determine the item
|
this field, is used to determine the item
|
||||||
type, and thus which field this union
|
type, and thus which field this union
|
||||||
contains. */
|
contains. */
|
||||||
__u16 ih2_entry_count; /* Iff this is a directory item, this field
|
__le16 ih2_entry_count; /* Iff this is a directory item, this field
|
||||||
equals the number of directory entries in
|
equals the number of directory entries in
|
||||||
the directory item. */
|
the directory item. */
|
||||||
} __attribute__ ((__packed__)) u;
|
} __attribute__ ((__packed__)) u;
|
||||||
__u16 ih2_item_len; /* total size of the item body */
|
__le16 ih2_item_len; /* total size of the item body */
|
||||||
__u16 ih2_item_location; /* an offset to the item body within the
|
__le16 ih2_item_location; /* an offset to the item body within the
|
||||||
block */
|
block */
|
||||||
|
|
||||||
__u16 ih_format; /* key format is stored in bits 0-11 of this item
|
__le16 ih_format; /* key format is stored in bits 0-11 of this item
|
||||||
flags are stored in bits 12-15 */
|
flags are stored in bits 12-15 */
|
||||||
#if 0
|
#if 0
|
||||||
struct {
|
struct {
|
||||||
__u16 key_format:12; /* KEY_FORMAT_1 or KEY_FORMAT_2. This is not
|
__le16 key_format:12; /* KEY_FORMAT_1 or KEY_FORMAT_2. This is not
|
||||||
necessary, but we have space, let use it */
|
necessary, but we have space, let use it */
|
||||||
__u16 flags:4; /* fsck set here its flag (reachable/unreachable) */
|
__le16 flags:4; /* fsck set here its flag (reachable/unreachable) */
|
||||||
} __attribute__ ((__packed__)) ih2_format;
|
} __attribute__ ((__packed__)) ih2_format;
|
||||||
#endif
|
#endif
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
@@ -703,11 +710,11 @@ void set_ih_key_format(struct item_head *ih, __u16 val);
|
|||||||
/* Header of a disk block. More precisely, header of a formatted leaf
|
/* Header of a disk block. More precisely, header of a formatted leaf
|
||||||
or internal node, and not the header of an unformatted node. */
|
or internal node, and not the header of an unformatted node. */
|
||||||
struct block_head {
|
struct block_head {
|
||||||
__u16 blk2_level; /* Level of a block in the tree. */
|
__le16 blk2_level; /* Level of a block in the tree. */
|
||||||
__u16 blk2_nr_item; /* Number of keys/items in a block. */
|
__le16 blk2_nr_item; /* Number of keys/items in a block. */
|
||||||
__u16 blk2_free_space; /* Block free space in bytes. */
|
__le16 blk2_free_space; /* Block free space in bytes. */
|
||||||
__u16 blk_reserved;
|
__le16 blk_reserved;
|
||||||
__u32 reserved[4];
|
__le32 reserved[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLKH_SIZE (sizeof(struct block_head))
|
#define BLKH_SIZE (sizeof(struct block_head))
|
||||||
@@ -761,20 +768,20 @@ struct block_head {
|
|||||||
overloaded. */
|
overloaded. */
|
||||||
|
|
||||||
struct stat_data_v1 {
|
struct stat_data_v1 {
|
||||||
__u16 sd_mode; /* file type, permissions */
|
__le16 sd_mode; /* file type, permissions */
|
||||||
__u16 sd_nlink; /* number of hard links */
|
__le16 sd_nlink; /* number of hard links */
|
||||||
__u16 sd_uid; /* owner */
|
__le16 sd_uid; /* owner */
|
||||||
__u16 sd_gid; /* group */
|
__le16 sd_gid; /* group */
|
||||||
__u32 sd_size; /* file size */
|
__le32 sd_size; /* file size */
|
||||||
__u32 sd_atime; /* time of last access */
|
__le32 sd_atime; /* time of last access */
|
||||||
__u32 sd_mtime; /* time file was last modified */
|
__le32 sd_mtime; /* time file was last modified */
|
||||||
__u32 sd_ctime; /* time inode (stat data) was last changed (except
|
__le32 sd_ctime; /* time inode (stat data) was last changed (except
|
||||||
changes to sd_atime and sd_mtime) */
|
changes to sd_atime and sd_mtime) */
|
||||||
union {
|
union {
|
||||||
__u32 sd_rdev;
|
__le32 sd_rdev;
|
||||||
__u32 sd_blocks; /* number of blocks file uses */
|
__le32 sd_blocks; /* number of blocks file uses */
|
||||||
} __attribute__ ((__packed__)) u;
|
} __attribute__ ((__packed__)) u;
|
||||||
__u32 sd_first_direct_byte; /* first byte of file which is stored
|
__le32 sd_first_direct_byte; /* first byte of file which is stored
|
||||||
in a direct item: except that if it
|
in a direct item: except that if it
|
||||||
equals 1 it is a symlink and if it
|
equals 1 it is a symlink and if it
|
||||||
equals MAX_KEY_OFFSET there is no
|
equals MAX_KEY_OFFSET there is no
|
||||||
@@ -796,23 +803,23 @@ struct stat_data_v1 {
|
|||||||
/* Stat Data on disk (reiserfs version of UFS disk inode minus the
|
/* Stat Data on disk (reiserfs version of UFS disk inode minus the
|
||||||
address blocks) */
|
address blocks) */
|
||||||
struct stat_data {
|
struct stat_data {
|
||||||
__u16 sd_mode; /* file type, permissions */
|
__le16 sd_mode; /* file type, permissions */
|
||||||
__u16 sd_attrs;
|
__le16 sd_attrs;
|
||||||
__u32 sd_nlink; /* 32 bit nlink! */
|
__le32 sd_nlink; /* 32 bit nlink! */
|
||||||
__u64 sd_size; /* 64 bit size! */
|
__le64 sd_size; /* 64 bit size! */
|
||||||
__u32 sd_uid; /* 32 bit uid! */
|
__le32 sd_uid; /* 32 bit uid! */
|
||||||
__u32 sd_gid; /* 32 bit gid! */
|
__le32 sd_gid; /* 32 bit gid! */
|
||||||
__u32 sd_atime; /* time of last access */
|
__le32 sd_atime; /* time of last access */
|
||||||
__u32 sd_mtime; /* time file was last modified */
|
__le32 sd_mtime; /* time file was last modified */
|
||||||
__u32 sd_ctime; /* time inode (stat data) was last changed (except
|
__le32 sd_ctime; /* time inode (stat data) was last changed (except
|
||||||
changes to sd_atime and sd_mtime) */
|
changes to sd_atime and sd_mtime) */
|
||||||
__u32 sd_blocks;
|
__le32 sd_blocks;
|
||||||
union {
|
union {
|
||||||
__u32 sd_rdev;
|
__le32 sd_rdev;
|
||||||
__u32 sd_generation;
|
__le32 sd_generation;
|
||||||
//__u32 sd_first_direct_byte;
|
//__le32 sd_first_direct_byte;
|
||||||
/* first byte of file which is stored in a direct item: except that if
|
/* first byte of file which is stored in a direct item: except that if
|
||||||
it equals 1 it is a symlink and if it equals ~(__u32)0 there is no
|
it equals 1 it is a symlink and if it equals ~(__le32)0 there is no
|
||||||
direct item. The existence of this field really grates on me. Let's
|
direct item. The existence of this field really grates on me. Let's
|
||||||
replace it with a macro based on sd_size and our tail suppression
|
replace it with a macro based on sd_size and our tail suppression
|
||||||
policy? */
|
policy? */
|
||||||
@@ -857,13 +864,13 @@ struct stat_data {
|
|||||||
/* NOT IMPLEMENTED:
|
/* NOT IMPLEMENTED:
|
||||||
Directory will someday contain stat data of object */
|
Directory will someday contain stat data of object */
|
||||||
struct reiserfs_de_head {
|
struct reiserfs_de_head {
|
||||||
__u32 deh2_offset; /* third component of the directory entry key */
|
__le32 deh2_offset; /* third component of the directory entry key */
|
||||||
__u32 deh2_dir_id; /* objectid of the parent directory of the object,
|
__le32 deh2_dir_id; /* objectid of the parent directory of the object,
|
||||||
that is referenced by directory entry */
|
that is referenced by directory entry */
|
||||||
__u32 deh2_objectid; /* objectid of the object, that is referenced by
|
__le32 deh2_objectid; /* objectid of the object, that is referenced by
|
||||||
directory entry */
|
directory entry */
|
||||||
__u16 deh2_location; /* offset of name in the whole item */
|
__le16 deh2_location; /* offset of name in the whole item */
|
||||||
__u16 deh2_state; /* whether 1) entry contains stat data (for future),
|
__le16 deh2_state; /* whether 1) entry contains stat data (for future),
|
||||||
and 2) whether entry is hidden (unlinked) */
|
and 2) whether entry is hidden (unlinked) */
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
@@ -970,9 +977,9 @@ struct reiserfs_de_head {
|
|||||||
/* Disk child pointer: The pointer from an internal node of the tree
|
/* Disk child pointer: The pointer from an internal node of the tree
|
||||||
to a node that is on disk. */
|
to a node that is on disk. */
|
||||||
struct disk_child {
|
struct disk_child {
|
||||||
__u32 dc2_block_number; /* Disk child's block number. */
|
__le32 dc2_block_number; /* Disk child's block number. */
|
||||||
__u16 dc2_size; /* Disk child's used space. */
|
__le16 dc2_size; /* Disk child's used space. */
|
||||||
__u16 dc2_reserved;
|
__le16 dc2_reserved;
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
#define DC_SIZE (sizeof(struct disk_child))
|
#define DC_SIZE (sizeof(struct disk_child))
|
||||||
@@ -1115,7 +1122,7 @@ struct reiserfs_path var = {ILLEGAL_PATH_ELEMENT_OFFSET, }
|
|||||||
#define DIRECTORY_FOUND 15
|
#define DIRECTORY_FOUND 15
|
||||||
|
|
||||||
/* Size of pointer to the unformatted node. */
|
/* Size of pointer to the unformatted node. */
|
||||||
#define UNFM_P_SIZE (sizeof(__u32))
|
#define UNFM_P_SIZE (sizeof(__le32))
|
||||||
|
|
||||||
#define MAX_KEY1_OFFSET 0xffffffff
|
#define MAX_KEY1_OFFSET 0xffffffff
|
||||||
#define MAX_KEY2_OFFSET 0xfffffffffffffffLL
|
#define MAX_KEY2_OFFSET 0xfffffffffffffffLL
|
||||||
|
|||||||
+19
-15
@@ -7,7 +7,7 @@
|
|||||||
#define REISERFSPROGS_SWAB_H
|
#define REISERFSPROGS_SWAB_H
|
||||||
|
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#include <asm/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
#define __swab16(x) \
|
#define __swab16(x) \
|
||||||
({ \
|
({ \
|
||||||
@@ -42,23 +42,27 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
#ifndef le32_to_cpu
|
#ifndef le32_to_cpu
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
#ifdef __CHECKER__
|
||||||
|
#define __force __attribute__((force))
|
||||||
|
#else
|
||||||
|
#define __force
|
||||||
|
#endif
|
||||||
|
|
||||||
# define cpu_to_le16(val) (val)
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
# define le16_to_cpu(val) (val)
|
#define cpu_to_le64(x) ((__force __le64)(__u64)(x))
|
||||||
# define cpu_to_le32(val) (val)
|
#define le64_to_cpu(x) ((__force __u64)(__le64)(x))
|
||||||
# define le32_to_cpu(val) (val)
|
#define cpu_to_le32(x) ((__force __le32)(__u32)(x))
|
||||||
# define cpu_to_le64(val) (val)
|
#define le32_to_cpu(x) ((__force __u32)(__le32)(x))
|
||||||
# define le64_to_cpu(val) (val)
|
#define cpu_to_le16(x) ((__force __le16)(__u16)(x))
|
||||||
|
#define le16_to_cpu(x) ((__force __u16)(__le16)(x))
|
||||||
|
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
#define cpu_to_le64(x) ((__force __le64)__swab64((x)))
|
||||||
# define cpu_to_le16(val) __swab16(val)
|
#define le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
|
||||||
# define le16_to_cpu(val) __swab16(val)
|
#define cpu_to_le32(x) ((__force __le32)__swab32((x)))
|
||||||
# define cpu_to_le32(val) __swab32(val)
|
#define le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
|
||||||
# define le32_to_cpu(val) __swab32(val)
|
#define cpu_to_le16(x) ((__force __le16)__swab16((x)))
|
||||||
# define cpu_to_le64(val) __swab64(val)
|
#define le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
|
||||||
# define le64_to_cpu(val) __swab64(val)
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# error "nuxi/pdp-endian archs are not supported"
|
# error "nuxi/pdp-endian archs are not supported"
|
||||||
|
|||||||
@@ -630,6 +630,7 @@ int reiserfs_bin_search(void *key, void *base, __u32 num, int width,
|
|||||||
#define BLOCKLIST__ELEMENT_NUMBER 10
|
#define BLOCKLIST__ELEMENT_NUMBER 10
|
||||||
|
|
||||||
/*element is block number and device*/
|
/*element is block number and device*/
|
||||||
|
/* XXX ENDIAN CHECK */
|
||||||
int blockdev_list_compare(const void *block1, const void *block2)
|
int blockdev_list_compare(const void *block1, const void *block2)
|
||||||
{
|
{
|
||||||
if (*(__u32 *) block1 < *(__u32 *) block2)
|
if (*(__u32 *) block1 < *(__u32 *) block2)
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ static int is_bad_indirect(reiserfs_filsys_t *fs, struct item_head *ih,
|
|||||||
char *item, check_unfm_func_t check_unfm_func)
|
char *item, check_unfm_func_t check_unfm_func)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
__u32 *ind = (__u32 *) item;
|
__le32 *ind = (__le32 *) item;
|
||||||
|
|
||||||
if (get_ih_item_len(ih) % UNFM_P_SIZE)
|
if (get_ih_item_len(ih) % UNFM_P_SIZE)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1147,8 +1147,8 @@ void get_set_sd_field(int field, struct item_head *ih, void *sd,
|
|||||||
|
|
||||||
static int comp_ids(const void *p1, const void *p2)
|
static int comp_ids(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
__u32 id1 = le32_to_cpu(*(__u32 *) p1);
|
__u32 id1 = le32_to_cpu(*(__le32 *) p1);
|
||||||
__u32 id2 = le32_to_cpu(*(__u32 *) p2);
|
__u32 id2 = le32_to_cpu(*(__le32 *) p2);
|
||||||
|
|
||||||
if (id1 < id2)
|
if (id1 < id2)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1161,14 +1161,14 @@ static int comp_ids(const void *p1, const void *p2)
|
|||||||
|
|
||||||
int is_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
int is_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
||||||
{
|
{
|
||||||
__u32 *objectid_map;
|
__le32 *objectid_map;
|
||||||
__u32 count = get_sb_oid_cursize(fs->fs_ondisk_sb);
|
__u32 count = get_sb_oid_cursize(fs->fs_ondisk_sb);
|
||||||
int ret;
|
int ret;
|
||||||
__u32 pos;
|
__u32 pos;
|
||||||
__u32 le_id = cpu_to_le32(objectid);
|
__le32 le_id = cpu_to_le32(objectid);
|
||||||
|
|
||||||
objectid_map =
|
objectid_map =
|
||||||
(__u32 *) ((char *)fs->fs_ondisk_sb +
|
(__le32 *) ((char *)fs->fs_ondisk_sb +
|
||||||
reiserfs_super_block_size(fs->fs_ondisk_sb));
|
reiserfs_super_block_size(fs->fs_ondisk_sb));
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
@@ -1186,7 +1186,7 @@ int is_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
|||||||
void mark_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
void mark_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
__u32 *objectid_map;
|
__le32 *objectid_map;
|
||||||
int cursize;
|
int cursize;
|
||||||
|
|
||||||
if (is_objectid_used(fs, objectid)) {
|
if (is_objectid_used(fs, objectid)) {
|
||||||
@@ -1194,7 +1194,7 @@ void mark_objectid_used(reiserfs_filsys_t *fs, __u32 objectid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
objectid_map =
|
objectid_map =
|
||||||
(__u32 *) ((char *)fs->fs_ondisk_sb +
|
(__le32 *) ((char *)fs->fs_ondisk_sb +
|
||||||
reiserfs_super_block_size(fs->fs_ondisk_sb));
|
reiserfs_super_block_size(fs->fs_ondisk_sb));
|
||||||
cursize = get_sb_oid_cursize(fs->fs_ondisk_sb);
|
cursize = get_sb_oid_cursize(fs->fs_ondisk_sb);
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -333,14 +333,14 @@ static void start_new_sequence(__u32 * start, int *len, __u32 new)
|
|||||||
|
|
||||||
static int sequence_finished(__u32 start, int *len, __u32 new)
|
static int sequence_finished(__u32 start, int *len, __u32 new)
|
||||||
{
|
{
|
||||||
if (le32_to_cpu(start) == INT_MAX)
|
if (start == INT_MAX)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (start == 0 && new == 0) {
|
if (start == 0 && new == 0) {
|
||||||
(*len)++;
|
(*len)++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (start != 0 && (le32_to_cpu(start) + *len) == le32_to_cpu(new)) {
|
if (start != 0 && (start + *len) == new) {
|
||||||
(*len)++;
|
(*len)++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -353,20 +353,21 @@ static void print_sequence(FILE * fp, __u32 start, int len)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (len == 1)
|
if (len == 1)
|
||||||
reiserfs_warning(fp, " %u", le32_to_cpu(start));
|
reiserfs_warning(fp, " %u", start);
|
||||||
else
|
else
|
||||||
reiserfs_warning(fp, " %u(%d)", le32_to_cpu(start), len);
|
reiserfs_warning(fp, " %u(%d)", start, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_indirect_item(FILE * fp, struct buffer_head *bh, int item_num)
|
void print_indirect_item(FILE * fp, struct buffer_head *bh, int item_num)
|
||||||
{
|
{
|
||||||
struct item_head *ih;
|
struct item_head *ih;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
__u32 *unp, prev = INT_MAX;
|
__le32 *unp;
|
||||||
|
__u32 prev = INT_MAX;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
ih = item_head(bh, item_num);
|
ih = item_head(bh, item_num);
|
||||||
unp = (__u32 *) ih_item_body(bh, ih);
|
unp = (__le32 *) ih_item_body(bh, ih);
|
||||||
|
|
||||||
if (get_ih_item_len(ih) % UNFM_P_SIZE)
|
if (get_ih_item_len(ih) % UNFM_P_SIZE)
|
||||||
reiserfs_warning(fp, "print_indirect_item: invalid item len");
|
reiserfs_warning(fp, "print_indirect_item: invalid item len");
|
||||||
@@ -1016,13 +1017,13 @@ void print_objectid_map(FILE * fp, reiserfs_filsys_t *fs)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct reiserfs_super_block *sb;
|
struct reiserfs_super_block *sb;
|
||||||
__u32 *omap;
|
__le32 *omap;
|
||||||
|
|
||||||
sb = fs->fs_ondisk_sb;
|
sb = fs->fs_ondisk_sb;
|
||||||
if (fs->fs_format == REISERFS_FORMAT_3_6)
|
if (fs->fs_format == REISERFS_FORMAT_3_6)
|
||||||
omap = (__u32 *) (sb + 1);
|
omap = (__le32 *) (sb + 1);
|
||||||
else if (fs->fs_format == REISERFS_FORMAT_3_5)
|
else if (fs->fs_format == REISERFS_FORMAT_3_5)
|
||||||
omap = (__u32 *) ((struct reiserfs_super_block_v1 *)sb + 1);
|
omap = (__le32 *) ((struct reiserfs_super_block_v1 *)sb + 1);
|
||||||
else {
|
else {
|
||||||
reiserfs_warning(fp,
|
reiserfs_warning(fp,
|
||||||
"print_objectid_map: proper signature is not found\n");
|
"print_objectid_map: proper signature is not found\n");
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ struct reiserfs_key root_dir_key = { 0, 0, {{0, 0},} };
|
|||||||
struct reiserfs_key parent_root_dir_key = { 0, 0, {{0, 0},} };
|
struct reiserfs_key parent_root_dir_key = { 0, 0, {{0, 0},} };
|
||||||
struct reiserfs_key lost_found_dir_key = { 0, 0, {{0, 0},} };
|
struct reiserfs_key lost_found_dir_key = { 0, 0, {{0, 0},} };
|
||||||
static struct reiserfs_key badblock_key =
|
static struct reiserfs_key badblock_key =
|
||||||
{ BADBLOCK_DIRID, BADBLOCK_OBJID, {{0, 0},} };
|
{ cpu_to_le32(BADBLOCK_DIRID), cpu_to_le32(BADBLOCK_OBJID),
|
||||||
|
{{cpu_to_le32(0), cpu_to_le32(0)},} };
|
||||||
|
|
||||||
__u16 root_dir_format = 0;
|
__u16 root_dir_format = 0;
|
||||||
__u16 lost_found_dir_format = 0;
|
__u16 lost_found_dir_format = 0;
|
||||||
@@ -597,7 +598,7 @@ static int comp_dir_entries(const void *p1, const void *p2)
|
|||||||
{
|
{
|
||||||
__u32 off1, off2;
|
__u32 off1, off2;
|
||||||
|
|
||||||
off1 = d32_get((__u32 *) p1, 0);
|
off1 = d32_get((__le32 *) p1, 0);
|
||||||
off2 = *(__u32 *) p2;
|
off2 = *(__u32 *) p2;
|
||||||
|
|
||||||
if (off1 < off2)
|
if (off1 < off2)
|
||||||
@@ -1412,14 +1413,14 @@ void mark_badblock(reiserfs_filsys_t *fs,
|
|||||||
struct reiserfs_path *badblock_path, void *data)
|
struct reiserfs_path *badblock_path, void *data)
|
||||||
{
|
{
|
||||||
struct item_head *tmp_ih;
|
struct item_head *tmp_ih;
|
||||||
__u32 *ind_item;
|
__le32 *ind_item;
|
||||||
__u32 i;
|
__u32 i;
|
||||||
|
|
||||||
if (!fs->fs_badblocks_bm)
|
if (!fs->fs_badblocks_bm)
|
||||||
create_badblock_bitmap(fs, NULL);
|
create_badblock_bitmap(fs, NULL);
|
||||||
|
|
||||||
tmp_ih = tp_item_head(badblock_path);
|
tmp_ih = tp_item_head(badblock_path);
|
||||||
ind_item = (__u32 *) tp_item_body(badblock_path);
|
ind_item = (__le32 *) tp_item_body(badblock_path);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
||||||
reiserfs_bitmap_set_bit(fs->fs_badblocks_bm,
|
reiserfs_bitmap_set_bit(fs->fs_badblocks_bm,
|
||||||
@@ -1434,7 +1435,7 @@ void add_badblock_list(reiserfs_filsys_t *fs, int replace)
|
|||||||
struct tree_balance tb;
|
struct tree_balance tb;
|
||||||
struct reiserfs_path badblock_path;
|
struct reiserfs_path badblock_path;
|
||||||
struct item_head badblock_ih;
|
struct item_head badblock_ih;
|
||||||
__u32 ni;
|
__le32 ni;
|
||||||
|
|
||||||
__u64 offset;
|
__u64 offset;
|
||||||
__u32 i, j;
|
__u32 i, j;
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ inline int B_IS_IN_TREE(struct buffer_head *p_s_bh)
|
|||||||
int comp_short_keys(const void *k1, const void *k2)
|
int comp_short_keys(const void *k1, const void *k2)
|
||||||
{
|
{
|
||||||
int n_key_length = REISERFS_SHORT_KEY_LEN;
|
int n_key_length = REISERFS_SHORT_KEY_LEN;
|
||||||
__u32 *p_s_key1 = (__u32 *) k1;
|
__le32 *p_s_key1 = (__le32 *) k1;
|
||||||
__u32 *p_s_key2 = (__u32 *) k2;
|
__le32 *p_s_key2 = (__le32 *) k2;
|
||||||
__u32 u1, u2;
|
__u32 u1, u2;
|
||||||
|
|
||||||
for (; n_key_length--; ++p_s_key1, ++p_s_key2) {
|
for (; n_key_length--; ++p_s_key1, ++p_s_key2) {
|
||||||
@@ -173,11 +173,14 @@ int bin_search(void *p_v_key, /* Key to search for. */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Minimal possible key. It is never in the tree. */
|
/* Minimal possible key. It is never in the tree. */
|
||||||
const struct reiserfs_key MIN_KEY = { 0, 0, {{0, 0},} };
|
const struct reiserfs_key MIN_KEY =
|
||||||
|
{ cpu_to_le32(0), cpu_to_le32(0),
|
||||||
|
{{cpu_to_le32(0), cpu_to_le32(0)},} };
|
||||||
|
|
||||||
/* Maximal possible key. It is never in the tree. */
|
/* Maximal possible key. It is never in the tree. */
|
||||||
const struct reiserfs_key MAX_KEY =
|
const struct reiserfs_key MAX_KEY =
|
||||||
{ 0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},} };
|
{ cpu_to_le32(0xffffffff), cpu_to_le32(0xffffffff),
|
||||||
|
{{cpu_to_le32(0xffffffff), cpu_to_le32(0xffffffff)},} };
|
||||||
|
|
||||||
/* Get delimiting key of the buffer by looking for it in the buffers in the
|
/* Get delimiting key of the buffer by looking for it in the buffers in the
|
||||||
path, starting from the bottom of the path, and going upwards. We must
|
path, starting from the bottom of the path, and going upwards. We must
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ static unsigned long move_formatted_block(reiserfs_filsys_t *fs,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (is_indirect_ih(ih)) {
|
if (is_indirect_ih(ih)) {
|
||||||
__u32 *indirect;
|
__le32 *indirect;
|
||||||
|
|
||||||
indirect = (__u32 *) ih_item_body(bh, ih);
|
indirect = (__le32 *) ih_item_body(bh, ih);
|
||||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||||
unsigned long unfm_block;
|
unsigned long unfm_block;
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -290,10 +290,11 @@ static void callback_new_badblocks(reiserfs_filsys_t *fs,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct item_head *tmp_ih;
|
struct item_head *tmp_ih;
|
||||||
__u32 *ind_item, i;
|
__le32 *ind_item;
|
||||||
|
__u32 i;
|
||||||
|
|
||||||
tmp_ih = tp_item_head(badblock_path);
|
tmp_ih = tp_item_head(badblock_path);
|
||||||
ind_item = (__u32 *) tp_item_body(badblock_path);
|
ind_item = (__le32 *) tp_item_body(badblock_path);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
||||||
if (reiserfs_bitmap_test_bit(fs->fs_badblocks_bm,
|
if (reiserfs_bitmap_test_bit(fs->fs_badblocks_bm,
|
||||||
@@ -314,10 +315,11 @@ static void callback_clear_badblocks(reiserfs_filsys_t *fs,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct item_head *tmp_ih;
|
struct item_head *tmp_ih;
|
||||||
__u32 *ind_item, i;
|
__le32 *ind_item;
|
||||||
|
__u32 i;
|
||||||
|
|
||||||
tmp_ih = tp_item_head(badblock_path);
|
tmp_ih = tp_item_head(badblock_path);
|
||||||
ind_item = (__u32 *) tp_item_body(badblock_path);
|
ind_item = (__le32 *) tp_item_body(badblock_path);
|
||||||
|
|
||||||
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++) {
|
||||||
reiserfs_bitmap_clear_bit(fs->fs_bitmap2, d32_get(ind_item, i));
|
reiserfs_bitmap_clear_bit(fs->fs_bitmap2, d32_get(ind_item, i));
|
||||||
|
|||||||
Reference in new issue
Block a user