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
Set license using %license
[platform/upstream/btrfs-progs.git]
/
cmds-device.c
diff --git
a/cmds-device.c
b/cmds-device.c
index
de62cd4
..
86459d1
100644
(file)
--- a/
cmds-device.c
+++ b/
cmds-device.c
@@
-32,6
+32,8
@@
#include "cmds-fi-usage.h"
#include "commands.h"
#include "cmds-fi-usage.h"
#include "commands.h"
+#include "help.h"
+#include "mkfs/common.h"
static const char * const device_cmd_group_usage[] = {
"btrfs device <command> [<args>]",
static const char * const device_cmd_group_usage[] = {
"btrfs device <command> [<args>]",
@@
-118,8
+120,8
@@
static int cmd_device_add(int argc, char **argv)
path = canonicalize_path(argv[i]);
if (!path) {
path = canonicalize_path(argv[i]);
if (!path) {
- error("could not canonicalize pathname '%s': %
s
",
- argv[i]
, strerror(errno)
);
+ error("could not canonicalize pathname '%s': %
m
",
+ argv[i]);
ret++;
goto error_out;
}
ret++;
goto error_out;
}
@@
-128,8
+130,7
@@
static int cmd_device_add(int argc, char **argv)
strncpy_null(ioctl_args.name, path);
res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
if (res < 0) {
strncpy_null(ioctl_args.name, path);
res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
if (res < 0) {
- error("error adding device '%s': %s",
- path, strerror(errno));
+ error("error adding device '%s': %m", path);
ret++;
}
free(path);
ret++;
}
free(path);
@@
-190,8
+191,7
@@
static int _cmd_device_remove(int argc, char **argv,
*/
if (res < 0 && (errno == ENOTTY || errno == EOPNOTSUPP)) {
if (is_devid) {
*/
if (res < 0 && (errno == ENOTTY || errno == EOPNOTSUPP)) {
if (is_devid) {
- error("device delete by id failed: %s",
- strerror(errno));
+ error("device delete by id failed: %m");
ret++;
continue;
}
ret++;
continue;
}
@@
-222,9
+222,16
@@
static int _cmd_device_remove(int argc, char **argv,
return !!ret;
}
return !!ret;
}
+#define COMMON_USAGE_REMOVE_DELETE \
+ "If 'missing' is specified for <device>, the first device that is", \
+ "described by the filesystem metadata, but not present at the mount", \
+ "time will be removed. (only in degraded mode)"
+
static const char * const cmd_device_remove_usage[] = {
"btrfs device remove <device>|<devid> [<device>|<devid>...] <path>",
"Remove a device from a filesystem",
static const char * const cmd_device_remove_usage[] = {
"btrfs device remove <device>|<devid> [<device>|<devid>...] <path>",
"Remove a device from a filesystem",
+ "",
+ COMMON_USAGE_REMOVE_DELETE,
NULL
};
NULL
};
@@
-235,7
+242,9
@@
static int cmd_device_remove(int argc, char **argv)
static const char * const cmd_device_delete_usage[] = {
"btrfs device delete <device>|<devid> [<device>|<devid>...] <path>",
static const char * const cmd_device_delete_usage[] = {
"btrfs device delete <device>|<devid> [<device>|<devid>...] <path>",
- "Remove a device from a filesystem",
+ "Remove a device from a filesystem (alias of \"btrfs device remove\")",
+ "",
+ COMMON_USAGE_REMOVE_DELETE,
NULL
};
NULL
};
@@
-300,8
+309,7
@@
static int cmd_device_scan(int argc, char **argv)
}
path = canonicalize_path(argv[i]);
if (!path) {
}
path = canonicalize_path(argv[i]);
if (!path) {
- error("could not canonicalize path '%s': %s",
- argv[i], strerror(errno));
+ error("could not canonicalize path '%s': %m", argv[i]);
ret = 1;
goto out;
}
ret = 1;
goto out;
}
@@
-344,8
+352,8
@@
static int cmd_device_ready(int argc, char **argv)
path = canonicalize_path(argv[optind]);
if (!path) {
path = canonicalize_path(argv[optind]);
if (!path) {
- error("could not canonicalize pathname '%s': %
s
",
- argv[optind]
, strerror(errno)
);
+ error("could not canonicalize pathname '%s': %
m
",
+ argv[optind]);
ret = 1;
goto out;
}
ret = 1;
goto out;
}
@@
-360,8
+368,8
@@
static int cmd_device_ready(int argc, char **argv)
strncpy_null(args.name, path);
ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args);
if (ret < 0) {
strncpy_null(args.name, path);
ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args);
if (ret < 0) {
- error("unable to determine if device '%s' is ready for mount: %
s
",
- path
, strerror(errno)
);
+ error("unable to determine if device '%s' is ready for mount: %
m
",
+ path);
ret = 1;
}
ret = 1;
}
@@
-398,6
+406,7
@@
static int cmd_device_stats(int argc, char **argv)
while (1) {
int c;
static const struct option long_options[] = {
while (1) {
int c;
static const struct option long_options[] = {
+ {"check", no_argument, NULL, 'c'},
{"reset", no_argument, NULL, 'z'},
{NULL, 0, NULL, 0}
};
{"reset", no_argument, NULL, 'z'},
{NULL, 0, NULL, 0}
};
@@
-454,8
+463,8
@@
static int cmd_device_stats(int argc, char **argv)
args.flags = flags;
if (ioctl(fdmnt, BTRFS_IOC_GET_DEV_STATS, &args) < 0) {
args.flags = flags;
if (ioctl(fdmnt, BTRFS_IOC_GET_DEV_STATS, &args) < 0) {
- error("device stats ioctl failed on %s: %
s
",
- path
, strerror(errno)
);
+ error("device stats ioctl failed on %s: %
m
",
+ path);
err |= 1;
} else {
char *canonical_path;
err |= 1;
} else {
char *canonical_path;
@@
-533,8
+542,8
@@
static int _cmd_device_usage(int fd, char *path, unsigned unit_mode)
for (i = 0; i < devcount; i++) {
printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
for (i = 0; i < devcount; i++) {
printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
- print_device_sizes(
fd,
&devinfo[i], unit_mode);
- print_device_chunks(
fd,
&devinfo[i], chunkinfo, chunkcount,
+ print_device_sizes(&devinfo[i], unit_mode);
+ print_device_chunks(&devinfo[i], chunkinfo, chunkcount,
unit_mode);
printf("\n");
}
unit_mode);
printf("\n");
}