#include "disk-io.h"
#include "commands.h"
+#include "help.h"
static const char * const scrub_cmd_group_usage[] = {
"btrfs scrub <command> [options] <path>|<device>",
{
int avail = 0;
int old_avail = 0;
- char l[16 * 1024];
+ char l[SZ_16K];
int state = 0;
int curr = -1;
int i = 0;
again:
old_avail = avail - i;
- BUG_ON(old_avail < 0);
+ if (old_avail < 0) {
+ error("scrub record file corrupted near byte %d", i);
+ return ERR_PTR(-EINVAL);
+ }
if (old_avail)
memmove(l, l + i, old_avail);
avail = read(fd, l + old_avail, sizeof(l) - old_avail);
} while (i < avail);
continue;
}
- BUG();
+ error("internal error: unknown parser state %d near byte %d",
+ state, i);
+ return ERR_PTR(-EINVAL);
}
goto again;
}