storage: s/MAXPATHLEN/PATH_MAX/g

parent 3e2f74b7
...@@ -462,7 +462,7 @@ bool btrfs_create_clone(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -462,7 +462,7 @@ bool btrfs_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
{ {
int ret; int ret;
struct rsync_data data = {0, 0}; struct rsync_data data = {0, 0};
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
ret = rmdir(new->dest); ret = rmdir(new->dest);
if (ret < 0 && errno != ENOENT) if (ret < 0 && errno != ENOENT)
......
...@@ -237,7 +237,7 @@ bool loop_detect(const char *path) ...@@ -237,7 +237,7 @@ bool loop_detect(const char *path)
int loop_mount(struct lxc_storage *bdev) int loop_mount(struct lxc_storage *bdev)
{ {
int ret, loopfd; int ret, loopfd;
char loname[MAXPATHLEN]; char loname[PATH_MAX];
const char *src; const char *src;
if (strcmp(bdev->type, "loop")) if (strcmp(bdev->type, "loop"))
...@@ -301,7 +301,7 @@ static int do_loop_create(const char *path, uint64_t size, const char *fstype) ...@@ -301,7 +301,7 @@ static int do_loop_create(const char *path, uint64_t size, const char *fstype)
{ {
int fd, ret; int fd, ret;
off_t ret_size; off_t ret_size;
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
const char *cmd_args[2] = {fstype, path}; const char *cmd_args[2] = {fstype, path};
/* create the new loopback file */ /* create the new loopback file */
......
...@@ -111,7 +111,7 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool) ...@@ -111,7 +111,7 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool)
{ {
int len, ret; int len, ret;
char *pathdup, *vg, *lv; char *pathdup, *vg, *lv;
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
char sz[24]; char sz[24];
char *tp = NULL; char *tp = NULL;
struct lvcreate_args cmd_args = {0}; struct lvcreate_args cmd_args = {0};
...@@ -201,7 +201,7 @@ bool lvm_detect(const char *path) ...@@ -201,7 +201,7 @@ bool lvm_detect(const char *path)
int fd; int fd;
ssize_t ret; ssize_t ret;
struct stat statbuf; struct stat statbuf;
char devp[MAXPATHLEN], buf[4]; char devp[PATH_MAX], buf[4];
if (!strncmp(path, "lvm:", 4)) if (!strncmp(path, "lvm:", 4))
return true; return true;
...@@ -213,9 +213,9 @@ bool lvm_detect(const char *path) ...@@ -213,9 +213,9 @@ bool lvm_detect(const char *path)
if (!S_ISBLK(statbuf.st_mode)) if (!S_ISBLK(statbuf.st_mode))
return false; return false;
ret = snprintf(devp, MAXPATHLEN, "/sys/dev/block/%d:%d/dm/uuid", ret = snprintf(devp, PATH_MAX, "/sys/dev/block/%d:%d/dm/uuid",
major(statbuf.st_rdev), minor(statbuf.st_rdev)); major(statbuf.st_rdev), minor(statbuf.st_rdev));
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
ERROR("Failed to create string"); ERROR("Failed to create string");
return false; return false;
} }
...@@ -335,7 +335,7 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz ...@@ -335,7 +335,7 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
char *lv, *pathdup; char *lv, *pathdup;
char sz[24]; char sz[24];
char fstype[100]; char fstype[100];
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
char repairchar; char repairchar;
const char *origsrc; const char *origsrc;
struct lvcreate_args cmd_args = {0}; struct lvcreate_args cmd_args = {0};
...@@ -506,7 +506,7 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -506,7 +506,7 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig,
const char *thinpool; const char *thinpool;
struct rsync_data data; struct rsync_data data;
const char *cmd_args[2]; const char *cmd_args[2];
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
char fstype[100] = "ext4"; char fstype[100] = "ext4";
uint64_t size = newsize; uint64_t size = newsize;
...@@ -593,7 +593,7 @@ bool lvm_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -593,7 +593,7 @@ bool lvm_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
int lvm_destroy(struct lxc_storage *orig) int lvm_destroy(struct lxc_storage *orig)
{ {
int ret; int ret;
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
struct lvcreate_args cmd_args = {0}; struct lvcreate_args cmd_args = {0};
cmd_args.lv = lxc_storage_get_path(orig->src, "lvm"); cmd_args.lv = lxc_storage_get_path(orig->src, "lvm");
...@@ -616,7 +616,7 @@ int lvm_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -616,7 +616,7 @@ int lvm_create(struct lxc_storage *bdev, const char *dest, const char *n,
uint64_t sz; uint64_t sz;
int ret, len; int ret, len;
const char *cmd_args[2]; const char *cmd_args[2];
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
if (!specs) if (!specs)
return -1; return -1;
......
...@@ -737,7 +737,7 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen) ...@@ -737,7 +737,7 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen)
int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs, int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
const char *lxc_name, const char *lxc_path) const char *lxc_name, const char *lxc_path)
{ {
char lxcpath[MAXPATHLEN]; char lxcpath[PATH_MAX];
char **opts; char **opts;
int ret; int ret;
size_t arrlen, i, len, rootfslen; size_t arrlen, i, len, rootfslen;
...@@ -766,8 +766,8 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs, ...@@ -766,8 +766,8 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
} }
if (rootfs_path) { if (rootfs_path) {
ret = snprintf(lxcpath, MAXPATHLEN, "%s/%s", lxc_path, lxc_name); ret = snprintf(lxcpath, PATH_MAX, "%s/%s", lxc_path, lxc_name);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
goto err; goto err;
rootfs_dir = ovl_get_rootfs(rootfs_path, &rootfslen); rootfs_dir = ovl_get_rootfs(rootfs_path, &rootfslen);
...@@ -825,8 +825,8 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path, ...@@ -825,8 +825,8 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
const char *lxc_name, const char *newpath, const char *lxc_name, const char *newpath,
const char *newname) const char *newname)
{ {
char new_upper[MAXPATHLEN], new_work[MAXPATHLEN], old_upper[MAXPATHLEN], char new_upper[PATH_MAX], new_work[PATH_MAX], old_upper[PATH_MAX],
old_work[MAXPATHLEN]; old_work[PATH_MAX];
size_t i; size_t i;
struct lxc_list *iterator; struct lxc_list *iterator;
char *cleanpath = NULL; char *cleanpath = NULL;
...@@ -852,13 +852,13 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path, ...@@ -852,13 +852,13 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
} }
ret = ret =
snprintf(old_work, MAXPATHLEN, "workdir=%s/%s", lxc_path, lxc_name); snprintf(old_work, PATH_MAX, "workdir=%s/%s", lxc_path, lxc_name);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
goto err; goto err;
ret = ret =
snprintf(new_work, MAXPATHLEN, "workdir=%s/%s", cleanpath, newname); snprintf(new_work, PATH_MAX, "workdir=%s/%s", cleanpath, newname);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
goto err; goto err;
lxc_list_for_each(iterator, &lxc_conf->mount_list) { lxc_list_for_each(iterator, &lxc_conf->mount_list) {
...@@ -872,14 +872,14 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path, ...@@ -872,14 +872,14 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
if (!tmp) if (!tmp)
continue; continue;
ret = snprintf(old_upper, MAXPATHLEN, "%s=%s/%s", tmp, lxc_path, ret = snprintf(old_upper, PATH_MAX, "%s=%s/%s", tmp, lxc_path,
lxc_name); lxc_name);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
goto err; goto err;
ret = snprintf(new_upper, MAXPATHLEN, "%s=%s/%s", tmp, ret = snprintf(new_upper, PATH_MAX, "%s=%s/%s", tmp,
cleanpath, newname); cleanpath, newname);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
goto err; goto err;
if (strstr(mnt_entry, old_upper)) { if (strstr(mnt_entry, old_upper)) {
...@@ -956,7 +956,7 @@ static int ovl_do_rsync(const char *src, const char *dest, ...@@ -956,7 +956,7 @@ static int ovl_do_rsync(const char *src, const char *dest,
{ {
int ret = -1; int ret = -1;
struct rsync_data_char rdata = {0}; struct rsync_data_char rdata = {0};
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
rdata.src = (char *)src; rdata.src = (char *)src;
rdata.dest = (char *)dest; rdata.dest = (char *)dest;
......
...@@ -104,7 +104,7 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -104,7 +104,7 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n,
int ret, len; int ret, len;
char sz[24]; char sz[24];
const char *cmd_args[2]; const char *cmd_args[2];
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
const char *rbdname = n; const char *rbdname = n;
struct rbd_args args = {0}; struct rbd_args args = {0};
...@@ -198,7 +198,7 @@ int rbd_destroy(struct lxc_storage *orig) ...@@ -198,7 +198,7 @@ int rbd_destroy(struct lxc_storage *orig)
int ret; int ret;
const char *src; const char *src;
char *rbdfullname; char *rbdfullname;
char cmd_output[MAXPATHLEN]; char cmd_output[PATH_MAX];
struct rbd_args args = {0}; struct rbd_args args = {0};
size_t len; size_t len;
......
...@@ -331,7 +331,7 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname, ...@@ -331,7 +331,7 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
const char *src = c->lxc_conf->rootfs.path; const char *src = c->lxc_conf->rootfs.path;
const char *oldname = c->name; const char *oldname = c->name;
const char *oldpath = c->config_path; const char *oldpath = c->config_path;
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
struct rsync_data data = {0}; struct rsync_data data = {0};
if (!src) { if (!src) {
......
...@@ -186,7 +186,7 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len) ...@@ -186,7 +186,7 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len)
FILE *f; FILE *f;
char *sp1, *sp2, *sp3; char *sp1, *sp2, *sp3;
const char *l, *srcdev; const char *l, *srcdev;
char devpath[MAXPATHLEN]; char devpath[PATH_MAX];
char *line = NULL; char *line = NULL;
if (!bdev || !bdev->src || !bdev->dest) if (!bdev || !bdev->src || !bdev->dest)
...@@ -415,11 +415,11 @@ const char *linkderef(const char *path, char *dest) ...@@ -415,11 +415,11 @@ const char *linkderef(const char *path, char *dest)
if (!S_ISLNK(sbuf.st_mode)) if (!S_ISLNK(sbuf.st_mode))
return path; return path;
ret = readlink(path, dest, MAXPATHLEN); ret = readlink(path, dest, PATH_MAX);
if (ret < 0) { if (ret < 0) {
SYSERROR("error reading link %s", path); SYSERROR("error reading link %s", path);
return NULL; return NULL;
} else if (ret >= MAXPATHLEN) { } else if (ret >= PATH_MAX) {
ERROR("link in %s too long", path); ERROR("link in %s too long", path);
return NULL; return NULL;
} }
......
...@@ -134,7 +134,7 @@ bool zfs_detect(const char *path) ...@@ -134,7 +134,7 @@ bool zfs_detect(const char *path)
int ret; int ret;
char *dataset; char *dataset;
struct zfs_args cmd_args = {0}; struct zfs_args cmd_args = {0};
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
if (!strncmp(path, "zfs:", 4)) if (!strncmp(path, "zfs:", 4))
return true; return true;
...@@ -185,7 +185,7 @@ int zfs_mount(struct lxc_storage *bdev) ...@@ -185,7 +185,7 @@ int zfs_mount(struct lxc_storage *bdev)
char *mntdata, *tmp; char *mntdata, *tmp;
const char *src; const char *src;
unsigned long mntflags; unsigned long mntflags;
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
if (strcmp(bdev->type, "zfs")) if (strcmp(bdev->type, "zfs"))
return -22; return -22;
...@@ -287,7 +287,7 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -287,7 +287,7 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig,
struct lxc_storage *new, uint64_t newsize) struct lxc_storage *new, uint64_t newsize)
{ {
int ret; int ret;
char cmd_output[MAXPATHLEN], option[MAXPATHLEN]; char cmd_output[PATH_MAX], option[PATH_MAX];
struct rsync_data data = {0, 0}; struct rsync_data data = {0, 0};
struct zfs_args cmd_args = {0}; struct zfs_args cmd_args = {0};
const char *argv[] = {"zfs", /* 0 */ const char *argv[] = {"zfs", /* 0 */
...@@ -299,8 +299,8 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -299,8 +299,8 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig,
NULL}; NULL};
/* mountpoint */ /* mountpoint */
ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest); ret = snprintf(option, PATH_MAX, "mountpoint=%s", new->dest);
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
ERROR("Failed to create string"); ERROR("Failed to create string");
return false; return false;
} }
...@@ -348,7 +348,7 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -348,7 +348,7 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
char *tmp, *snap_name, *snapshot; char *tmp, *snap_name, *snapshot;
const char *orig_src; const char *orig_src;
struct zfs_args cmd_args = {0}; struct zfs_args cmd_args = {0};
char cmd_output[MAXPATHLEN] = {0}, option[MAXPATHLEN]; char cmd_output[PATH_MAX] = {0}, option[PATH_MAX];
orig_src = lxc_storage_get_path(orig->src, orig->type); orig_src = lxc_storage_get_path(orig->src, orig->type);
if (*orig_src == '/') { if (*orig_src == '/') {
...@@ -423,8 +423,8 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, ...@@ -423,8 +423,8 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig,
TRACE("Created zfs snapshot \"%s\"", snapshot); TRACE("Created zfs snapshot \"%s\"", snapshot);
} }
ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest); ret = snprintf(option, PATH_MAX, "mountpoint=%s", new->dest);
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
ERROR("Failed to create string"); ERROR("Failed to create string");
free(snapshot); free(snapshot);
return -1; return -1;
...@@ -455,7 +455,7 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, ...@@ -455,7 +455,7 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
char *dataset, *tmp; char *dataset, *tmp;
const char *orig_src; const char *orig_src;
size_t dataset_len, len; size_t dataset_len, len;
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
if (!orig->src || !orig->dest) if (!orig->src || !orig->dest)
return -1; return -1;
...@@ -586,7 +586,7 @@ int zfs_destroy(struct lxc_storage *orig) ...@@ -586,7 +586,7 @@ int zfs_destroy(struct lxc_storage *orig)
bool found; bool found;
char *parent_snapshot = NULL; char *parent_snapshot = NULL;
struct zfs_args cmd_args = {0}; struct zfs_args cmd_args = {0};
char cmd_output[MAXPATHLEN] = {0}; char cmd_output[PATH_MAX] = {0};
src = lxc_storage_get_path(orig->src, orig->type); src = lxc_storage_get_path(orig->src, orig->type);
...@@ -714,7 +714,7 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -714,7 +714,7 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n,
int ret; int ret;
size_t len; size_t len;
struct zfs_args cmd_args = {0}; struct zfs_args cmd_args = {0};
char cmd_output[MAXPATHLEN], option[MAXPATHLEN]; char cmd_output[PATH_MAX], option[PATH_MAX];
const char *argv[] = {"zfs", /* 0 */ const char *argv[] = {"zfs", /* 0 */
"create", /* 1 */ "create", /* 1 */
"-o", "", /* 2, 3 */ "-o", "", /* 2, 3 */
...@@ -750,8 +750,8 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -750,8 +750,8 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n,
} }
argv[7] = lxc_storage_get_path(bdev->src, bdev->type); argv[7] = lxc_storage_get_path(bdev->src, bdev->type);
ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", bdev->dest); ret = snprintf(option, PATH_MAX, "mountpoint=%s", bdev->dest);
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
ERROR("Failed to create string"); ERROR("Failed to create string");
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment