btrfs-progs: use PATH_MAX instead of BTRFS_PATH_NAME_MAX
The path bufferes should be PATH_MAX but BTRFS_PATH_NAME_MAX is shorter due to embedding in 4k aligned structures. The only reason to use BTRFS_PATH_NAME_MAX is for the respective structures btrfs_ioctl_vol_args::name. Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
c55415e4cb
commit
2e151027d2
6 changed files with 15 additions and 14 deletions
|
@ -829,7 +829,7 @@ static int cmd_show(int argc, char **argv)
|
|||
/* default, search both kernel and udev */
|
||||
int where = -1;
|
||||
int type = 0;
|
||||
char mp[BTRFS_PATH_NAME_MAX + 1];
|
||||
char mp[PATH_MAX];
|
||||
char path[PATH_MAX];
|
||||
__u8 fsid[BTRFS_FSID_SIZE];
|
||||
char uuid_buf[BTRFS_UUID_UNPARSED_SIZE];
|
||||
|
|
|
@ -270,7 +270,7 @@ static int cmd_subvolid_resolve(int argc, char **argv)
|
|||
int ret;
|
||||
int fd = -1;
|
||||
u64 subvol_id;
|
||||
char path[BTRFS_PATH_NAME_MAX + 1];
|
||||
char path[PATH_MAX];
|
||||
DIR *dirstream = NULL;
|
||||
|
||||
if (check_argc_exact(argc, 3))
|
||||
|
@ -293,7 +293,7 @@ static int cmd_subvolid_resolve(int argc, char **argv)
|
|||
goto out;
|
||||
}
|
||||
|
||||
path[BTRFS_PATH_NAME_MAX] = '\0';
|
||||
path[PATH_MAX] = '\0';
|
||||
printf("%s\n", path);
|
||||
|
||||
out:
|
||||
|
|
|
@ -979,7 +979,7 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt,
|
|||
goto out;
|
||||
}
|
||||
|
||||
root_subvol_path = malloc(BTRFS_PATH_NAME_MAX);
|
||||
root_subvol_path = malloc(PATH_MAX);
|
||||
if (!root_subvol_path) {
|
||||
ret = -ENOMEM;
|
||||
fprintf(stderr, "ERROR: couldn't allocate buffer for the root "
|
||||
|
@ -988,7 +988,7 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt,
|
|||
}
|
||||
|
||||
ret = btrfs_subvolid_resolve(r->mnt_fd, root_subvol_path,
|
||||
BTRFS_PATH_NAME_MAX, subvol_id);
|
||||
PATH_MAX, subvol_id);
|
||||
if (ret) {
|
||||
fprintf(stderr, "ERROR: couldn't resolve our subvol path\n");
|
||||
goto out;
|
||||
|
|
10
cmds-scrub.c
10
cmds-scrub.c
|
@ -390,7 +390,7 @@ static int scrub_open_file(const char *datafile, int m)
|
|||
static int scrub_open_file_r(const char *fn_base, const char *fn_local)
|
||||
{
|
||||
int ret;
|
||||
char datafile[BTRFS_PATH_NAME_MAX + 1];
|
||||
char datafile[PATH_MAX];
|
||||
ret = scrub_datafile(fn_base, fn_local, NULL,
|
||||
datafile, sizeof(datafile));
|
||||
if (ret < 0)
|
||||
|
@ -402,7 +402,7 @@ static int scrub_open_file_w(const char *fn_base, const char *fn_local,
|
|||
const char *tmp)
|
||||
{
|
||||
int ret;
|
||||
char datafile[BTRFS_PATH_NAME_MAX + 1];
|
||||
char datafile[PATH_MAX];
|
||||
ret = scrub_datafile(fn_base, fn_local, tmp,
|
||||
datafile, sizeof(datafile));
|
||||
if (ret < 0)
|
||||
|
@ -414,8 +414,8 @@ static int scrub_rename_file(const char *fn_base, const char *fn_local,
|
|||
const char *tmp)
|
||||
{
|
||||
int ret;
|
||||
char datafile_old[BTRFS_PATH_NAME_MAX + 1];
|
||||
char datafile_new[BTRFS_PATH_NAME_MAX + 1];
|
||||
char datafile_old[PATH_MAX];
|
||||
char datafile_new[PATH_MAX];
|
||||
ret = scrub_datafile(fn_base, fn_local, tmp,
|
||||
datafile_old, sizeof(datafile_old));
|
||||
if (ret < 0)
|
||||
|
@ -1128,7 +1128,7 @@ static int scrub_start(int argc, char **argv, int resume)
|
|||
struct scrub_file_record *last_scrub = NULL;
|
||||
char *datafile = strdup(SCRUB_DATA_FILE);
|
||||
char fsid[BTRFS_UUID_UNPARSED_SIZE];
|
||||
char sock_path[BTRFS_PATH_NAME_MAX + 1] = "";
|
||||
char sock_path[PATH_MAX] = "";
|
||||
struct scrub_progress_cycle spc;
|
||||
pthread_mutex_t spc_write_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
void *terr;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ctree.h"
|
||||
#include "send-utils.h"
|
||||
|
@ -481,9 +482,9 @@ struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
|
|||
if (type == subvol_search_by_path) {
|
||||
info->path = strdup(path);
|
||||
} else {
|
||||
info->path = malloc(BTRFS_PATH_NAME_MAX);
|
||||
info->path = malloc(PATH_MAX);
|
||||
ret = btrfs_subvolid_resolve(s->mnt_fd, info->path,
|
||||
BTRFS_PATH_NAME_MAX, root_id);
|
||||
PATH_MAX, root_id);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
4
utils.c
4
utils.c
|
@ -1060,7 +1060,7 @@ out:
|
|||
*/
|
||||
int open_path_or_dev_mnt(const char *path, DIR **dirstream)
|
||||
{
|
||||
char mp[BTRFS_PATH_NAME_MAX + 1];
|
||||
char mp[PATH_MAX];
|
||||
int fdmnt;
|
||||
|
||||
if (is_block_device(path)) {
|
||||
|
@ -2056,7 +2056,7 @@ int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
|
|||
struct btrfs_fs_devices *fs_devices_mnt = NULL;
|
||||
struct btrfs_ioctl_dev_info_args *di_args;
|
||||
struct btrfs_ioctl_dev_info_args tmp;
|
||||
char mp[BTRFS_PATH_NAME_MAX + 1];
|
||||
char mp[PATH_MAX];
|
||||
DIR *dirstream = NULL;
|
||||
|
||||
memset(fi_args, 0, sizeof(*fi_args));
|
||||
|
|
Loading…
Reference in a new issue