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: convert: Fix inline file extent creation condition
[platform/upstream/btrfs-progs.git]
/
cmds-inspect.c
diff --git
a/cmds-inspect.c
b/cmds-inspect.c
index
4b7cea0
..
afd7fe4
100644
(file)
--- a/
cmds-inspect.c
+++ b/
cmds-inspect.c
@@
-31,9
+31,7
@@
#include "disk-io.h"
#include "commands.h"
#include "btrfs-list.h"
#include "disk-io.h"
#include "commands.h"
#include "btrfs-list.h"
-#include "cmds-inspect-dump-tree.h"
-#include "cmds-inspect-dump-super.h"
-#include "cmds-inspect-tree-stats.h"
+#include "help.h"
static const char * const inspect_cmd_group_usage[] = {
"btrfs inspect-internal <command> <args>",
static const char * const inspect_cmd_group_usage[] = {
"btrfs inspect-internal <command> <args>",
@@
-54,7
+52,7
@@
static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend)
ret = ioctl(fd, BTRFS_IOC_INO_PATHS, &ipa);
if (ret < 0) {
ret = ioctl(fd, BTRFS_IOC_INO_PATHS, &ipa);
if (ret < 0) {
- error("ino paths ioctl: %
s", strerror(errno)
);
+ error("ino paths ioctl: %
m"
);
goto out;
}
goto out;
}
@@
-146,7
+144,7
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
struct btrfs_ioctl_logical_ino_args loi;
struct btrfs_data_container *inodes;
u64 size = 4096;
struct btrfs_ioctl_logical_ino_args loi;
struct btrfs_data_container *inodes;
u64 size = 4096;
- char full_path[
4096
];
+ char full_path[
PATH_MAX
];
char *path_ptr;
DIR *dirstream = NULL;
char *path_ptr;
DIR *dirstream = NULL;
@@
-173,7
+171,7
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
if (check_argc_exact(argc - optind, 2))
usage(cmd_inspect_logical_resolve_usage);
if (check_argc_exact(argc - optind, 2))
usage(cmd_inspect_logical_resolve_usage);
- size = min(size, (u64)
64 * 1024
);
+ size = min(size, (u64)
SZ_64K
);
inodes = malloc(size);
if (!inodes)
return 1;
inodes = malloc(size);
if (!inodes)
return 1;
@@
-191,7
+189,7
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
ret = ioctl(fd, BTRFS_IOC_LOGICAL_INO, &loi);
if (ret < 0) {
ret = ioctl(fd, BTRFS_IOC_LOGICAL_INO, &loi);
if (ret < 0) {
- error("logical ino ioctl: %
s", strerror(errno)
);
+ error("logical ino ioctl: %
m"
);
goto out;
}
goto out;
}
@@
-207,7
+205,10
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
ret = snprintf(full_path, bytes_left, "%s/", argv[optind+1]);
path_ptr = full_path + ret;
bytes_left -= ret + 1;
ret = snprintf(full_path, bytes_left, "%s/", argv[optind+1]);
path_ptr = full_path + ret;
bytes_left -= ret + 1;
- BUG_ON(bytes_left < 0);
+ if (bytes_left < 0) {
+ error("path buffer too small: %d bytes", bytes_left);
+ goto out;
+ }
for (i = 0; i < inodes->elem_cnt; i += 3) {
u64 inum = inodes->val[i];
for (i = 0; i < inodes->elem_cnt; i += 3) {
u64 inum = inodes->val[i];
@@
-230,8
+231,12
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
path_ptr[-1] = '/';
ret = snprintf(path_ptr, bytes_left, "%s",
name);
path_ptr[-1] = '/';
ret = snprintf(path_ptr, bytes_left, "%s",
name);
- BUG_ON(ret >= bytes_left);
free(name);
free(name);
+ if (ret >= bytes_left) {
+ error("path buffer too small: %d bytes",
+ bytes_left - ret);
+ goto out;
+ }
path_fd = btrfs_open_dir(full_path, &dirs, 1);
if (path_fd < 0) {
ret = -ENOENT;
path_fd = btrfs_open_dir(full_path, &dirs, 1);
if (path_fd < 0) {
ret = -ENOENT;
@@
-313,13
+318,13
@@
static int cmd_inspect_rootid(int argc, char **argv)
if (check_argc_exact(argc - optind, 1))
usage(cmd_inspect_rootid_usage);
if (check_argc_exact(argc - optind, 1))
usage(cmd_inspect_rootid_usage);
- fd = btrfs_open_dir(argv[optind], &dirstream, 1);
+ fd = btrfs_open_
file_or_
dir(argv[optind], &dirstream, 1);
if (fd < 0) {
ret = -ENOENT;
goto out;
}
if (fd < 0) {
ret = -ENOENT;
goto out;
}
- ret = lookup_
ino
_rootid(fd, &rootid);
+ ret = lookup_
path
_rootid(fd, &rootid);
if (ret) {
error("failed to lookup root id: %s", strerror(-ret));
goto out;
if (ret) {
error("failed to lookup root id: %s", strerror(-ret));
goto out;
@@
-479,7
+484,7
@@
static void adjust_dev_min_size(struct list_head *extents,
* chunk tree, so often this can lead to the need of allocating
* a new system chunk too, which has a maximum size of 32Mb.
*/
* chunk tree, so often this can lead to the need of allocating
* a new system chunk too, which has a maximum size of 32Mb.
*/
- *min_size +=
32 * 1024 * 1024
;
+ *min_size +=
SZ_32M
;
}
}
}
}
@@
-493,7
+498,7
@@
static int print_min_dev_size(int fd, u64 devid)
* possibility of deprecating/removing it has been discussed, so we
* ignore it here.
*/
* possibility of deprecating/removing it has been discussed, so we
* ignore it here.
*/
- u64 min_size =
1 * 1024 * 1024ull
;
+ u64 min_size =
SZ_1M
;
struct btrfs_ioctl_search_args args;
struct btrfs_ioctl_search_key *sk = &args.key;
u64 last_pos = (u64)-1;
struct btrfs_ioctl_search_args args;
struct btrfs_ioctl_search_key *sk = &args.key;
u64 last_pos = (u64)-1;
@@
-519,7
+524,7
@@
static int print_min_dev_size(int fd, u64 devid)
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
- error("tree search ioctl: %
s", strerror(errno)
);
+ error("tree search ioctl: %
m"
);
ret = 1;
goto out;
}
ret = 1;
goto out;
}