Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
persist: handle writing empty dr_tree
Browse files Browse the repository at this point in the history
Fix a bug: phoneixfs used to read error (num_keys) on empty
filesystem.  Don't assume that are always dr entries to write; when
there are no entries to write, write num_keys = 0.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
  • Loading branch information
artagnon committed Aug 28, 2012
1 parent 0bd8a8f commit 14de41e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ void dump_dr_tree(struct node *root, FILE *outfile)
{
struct dir_record *dr;
uint16_t name_len;
register int i;
int i = 0;
node *iter;

if (!(iter = root))
if (!(iter = root)) {
/* Write num_keys = 0 */
fwrite(&i, sizeof(uint16_t), 1, outfile);
return;
}

while (!iter->is_leaf)
iter = iter->pointers[0];
Expand Down

0 comments on commit 14de41e

Please sign in to comment.