projects
/
platform
/
upstream
/
btrfs-progs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
btrfs-progs: replace test_issubvolume() with btrfs_util_is_subvolume()
[platform/upstream/btrfs-progs.git]
/
cmds-scrub.c
diff --git
a/cmds-scrub.c
b/cmds-scrub.c
index
de7005c
..
dabe7d9
100644
(file)
--- a/
cmds-scrub.c
+++ b/
cmds-scrub.c
@@
-44,6
+44,7
@@
#include "disk-io.h"
#include "commands.h"
#include "disk-io.h"
#include "commands.h"
+#include "help.h"
static const char * const scrub_cmd_group_usage[] = {
"btrfs scrub <command> [options] <path>|<device>",
static const char * const scrub_cmd_group_usage[] = {
"btrfs scrub <command> [options] <path>|<device>",
@@
-430,7
+431,7
@@
static int scrub_rename_file(const char *fn_base, const char *fn_local,
/*
* returns 0 if the key did not match (nothing was read)
* 1 if the key did match (success)
/*
* returns 0 if the key did not match (nothing was read)
* 1 if the key did match (success)
- * -1 if the key did match and an error occured
+ * -1 if the key did match and an error occur
r
ed
*/
static int scrub_kvread(int *i, int len, int avail, const char *buf,
const char *key, u64 *dest)
*/
static int scrub_kvread(int *i, int len, int avail, const char *buf,
const char *key, u64 *dest)
@@
-467,7
+468,7
@@
static struct scrub_file_record **scrub_read_file(int fd, int report_errors)
{
int avail = 0;
int old_avail = 0;
{
int avail = 0;
int old_avail = 0;
- char l[
16 * 1024
];
+ char l[
SZ_16K
];
int state = 0;
int curr = -1;
int i = 0;
int state = 0;
int curr = -1;
int i = 0;
@@
-481,7
+482,10
@@
static struct scrub_file_record **scrub_read_file(int fd, int report_errors)
again:
old_avail = avail - i;
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);
if (old_avail)
memmove(l, l + i, old_avail);
avail = read(fd, l + old_avail, sizeof(l) - old_avail);
@@
-650,7
+654,9
@@
skip:
} while (i < avail);
continue;
}
} while (i < avail);
continue;
}
- BUG();
+ error("internal error: unknown parser state %d near byte %d",
+ state, i);
+ return ERR_PTR(-EINVAL);
}
goto again;
}
}
goto again;
}
@@
-843,8
+849,7
@@
static void *scrub_one_dev(void *ctx)
IOPRIO_PRIO_VALUE(sp->ioprio_class,
sp->ioprio_classdata));
if (ret)
IOPRIO_PRIO_VALUE(sp->ioprio_class,
sp->ioprio_classdata));
if (ret)
- warning("setting ioprio failed: %s (ignored)",
- strerror(errno));
+ warning("setting ioprio failed: %m (ignored)");
ret = ioctl(sp->fd, BTRFS_IOC_SCRUB, &sp->scrub_args);
gettimeofday(&tv, NULL);
ret = ioctl(sp->fd, BTRFS_IOC_SCRUB, &sp->scrub_args);
gettimeofday(&tv, NULL);
@@
-1141,7
+1146,6
@@
static int scrub_start(int argc, char **argv, int resume)
int force = 0;
int nothing_to_resume = 0;
int force = 0;
int nothing_to_resume = 0;
- optind = 1;
while ((c = getopt(argc, argv, "BdqrRc:n:f")) != -1) {
switch (c) {
case 'B':
while ((c = getopt(argc, argv, "BdqrRc:n:f")) != -1) {
switch (c) {
case 'B':
@@
-1190,8
+1194,8
@@
static int scrub_start(int argc, char **argv, int resume)
if (mkdir_p(datafile)) {
warning_on(!do_quiet,
if (mkdir_p(datafile)) {
warning_on(!do_quiet,
- "cannot create scrub data file, mkdir %s failed: %
s
. Status recording disabled",
- datafile
, strerror(errno)
);
+ "cannot create scrub data file, mkdir %s failed: %
m
. Status recording disabled",
+ datafile);
do_record = 0;
}
free(datafile);
do_record = 0;
}
free(datafile);
@@
-1262,7
+1266,7
@@
static int scrub_start(int argc, char **argv, int resume)
spc.progress = calloc(fi_args.num_devices * 2, sizeof(*spc.progress));
if (!t_devs || !sp || !spc.progress) {
spc.progress = calloc(fi_args.num_devices * 2, sizeof(*spc.progress));
if (!t_devs || !sp || !spc.progress) {
- error_on(!do_quiet, "scrub failed: %
s", strerror(errno)
);
+ error_on(!do_quiet, "scrub failed: %
m"
);
err = 1;
goto out;
}
err = 1;
goto out;
}
@@
-1341,9
+1345,9
@@
static int scrub_start(int argc, char **argv, int resume)
ret = listen(prg_fd, 100);
if (ret == -1) {
warning_on(!do_quiet,
ret = listen(prg_fd, 100);
if (ret == -1) {
warning_on(!do_quiet,
- "failed to open the progress status socket at %s: %
s
. Progress cannot be queried",
+ "failed to open the progress status socket at %s: %
m
. Progress cannot be queried",
sock_path[0] ? sock_path :
sock_path[0] ? sock_path :
- SCRUB_PROGRESS_SOCKET_PATH
, strerror(errno)
);
+ SCRUB_PROGRESS_SOCKET_PATH);
if (prg_fd != -1) {
close(prg_fd);
prg_fd = -1;
if (prg_fd != -1) {
close(prg_fd);
prg_fd = -1;
@@
-1367,8
+1371,7
@@
static int scrub_start(int argc, char **argv, int resume)
if (do_background) {
pid = fork();
if (pid == -1) {
if (do_background) {
pid = fork();
if (pid == -1) {
- error_on(!do_quiet, "cannot scrub, fork failed: %s",
- strerror(errno));
+ error_on(!do_quiet, "cannot scrub, fork failed: %m");
err = 1;
goto out;
}
err = 1;
goto out;
}
@@
-1386,8
+1389,8
@@
static int scrub_start(int argc, char **argv, int resume)
}
ret = wait(&stat);
if (ret != pid) {
}
ret = wait(&stat);
if (ret != pid) {
- error_on(!do_quiet, "wait failed (ret=%d): %
s
",
- ret
, strerror(errno)
);
+ error_on(!do_quiet, "wait failed (ret=%d): %
m
",
+ ret);
err = 1;
goto out;
}
err = 1;
goto out;
}
@@
-1675,7
+1678,6
@@
static int cmd_scrub_status(int argc, char **argv)
int err = 0;
DIR *dirstream = NULL;
int err = 0;
DIR *dirstream = NULL;
- optind = 1;
while ((c = getopt(argc, argv, "dR")) != -1) {
switch (c) {
case 'd':
while ((c = getopt(argc, argv, "dR")) != -1) {
switch (c) {
case 'd':
@@
-1716,8
+1718,7
@@
static int cmd_scrub_status(int argc, char **argv)
fdres = socket(AF_UNIX, SOCK_STREAM, 0);
if (fdres == -1) {
fdres = socket(AF_UNIX, SOCK_STREAM, 0);
if (fdres == -1) {
- error("failed to create socket to receive progress information: %s",
- strerror(errno));
+ error("failed to create socket to receive progress information: %m");
err = 1;
goto out;
}
err = 1;
goto out;
}