Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155305
b: refs/heads/master
c: 0611254
h: refs/heads/master
i:
  155303: e3eb302
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Jul 9, 2009
1 parent aa1b006 commit 2d74cc6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 431102fed3effe4e4e19678830ddab7f05c34bf9
refs/heads/master: 061125476039a9a998878468a6abe235b1cee347
28 changes: 26 additions & 2 deletions trunk/fs/ubifs/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ static int is_empty(void *buf, int len)
return 1;
}

/**
* first_non_ff - find offset of the first non-0xff byte.
* @buf: buffer to search in
* @len: length of buffer
*
* This function returns offset of the first non-0xff byte in @buf or %-1 if
* the buffer contains only 0xff bytes.
*/
static int first_non_ff(void *buf, int len)
{
uint8_t *p = buf;
int i;

for (i = 0; i < len; i++)
if (*p++ != 0xff)
return i;
return -1;
}

/**
* get_master_node - get the last valid master node allowing for corruption.
* @c: UBIFS file-system description object
Expand Down Expand Up @@ -649,8 +668,13 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
clean_buf(c, &buf, lnum, &offs, &len);
need_clean = 1;
} else {
ubifs_err("corrupt empty space at LEB %d:%d",
lnum, offs);
int corruption = first_non_ff(buf, len);

ubifs_err("corrupt empty space LEB %d:%d, corruption "
"starts at %d", lnum, offs, corruption);
/* Make sure we dump interesting non-0xFF data */
offs = corruption;
buf += corruption;
goto corrupted;
}
}
Expand Down

0 comments on commit 2d74cc6

Please sign in to comment.