From: Christian Brauner Date: Sun, 7 Oct 2018 08:06:52 +0000 (+0200) Subject: storage: s/MAXPATHLEN/PATH_MAX/g X-Git-Tag: lxc-3.1.0~62^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=339de297af031e9d2cd48011a1072cb9ba4e5c37;p=thirdparty%2Flxc.git storage: s/MAXPATHLEN/PATH_MAX/g Signed-off-by: Christian Brauner --- diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c index 049074a45..b850611dc 100644 --- a/src/lxc/storage/btrfs.c +++ b/src/lxc/storage/btrfs.c @@ -462,7 +462,7 @@ bool btrfs_create_clone(struct lxc_conf *conf, struct lxc_storage *orig, { int ret; struct rsync_data data = {0, 0}; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; ret = rmdir(new->dest); if (ret < 0 && errno != ENOENT) diff --git a/src/lxc/storage/loop.c b/src/lxc/storage/loop.c index 8ea40e088..35cb13e06 100644 --- a/src/lxc/storage/loop.c +++ b/src/lxc/storage/loop.c @@ -237,7 +237,7 @@ bool loop_detect(const char *path) int loop_mount(struct lxc_storage *bdev) { int ret, loopfd; - char loname[MAXPATHLEN]; + char loname[PATH_MAX]; const char *src; if (strcmp(bdev->type, "loop")) @@ -301,7 +301,7 @@ static int do_loop_create(const char *path, uint64_t size, const char *fstype) { int fd, ret; off_t ret_size; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; const char *cmd_args[2] = {fstype, path}; /* create the new loopback file */ diff --git a/src/lxc/storage/lvm.c b/src/lxc/storage/lvm.c index 8bb16175d..6908e9066 100644 --- a/src/lxc/storage/lvm.c +++ b/src/lxc/storage/lvm.c @@ -111,7 +111,7 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool) { int len, ret; char *pathdup, *vg, *lv; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; char sz[24]; char *tp = NULL; struct lvcreate_args cmd_args = {0}; @@ -201,7 +201,7 @@ bool lvm_detect(const char *path) int fd; ssize_t ret; struct stat statbuf; - char devp[MAXPATHLEN], buf[4]; + char devp[PATH_MAX], buf[4]; if (!strncmp(path, "lvm:", 4)) return true; @@ -213,9 +213,9 @@ bool lvm_detect(const char *path) if (!S_ISBLK(statbuf.st_mode)) 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)); - if (ret < 0 || ret >= MAXPATHLEN) { + if (ret < 0 || ret >= PATH_MAX) { ERROR("Failed to create string"); return false; } @@ -335,7 +335,7 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz char *lv, *pathdup; char sz[24]; char fstype[100]; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; char repairchar; const char *origsrc; struct lvcreate_args cmd_args = {0}; @@ -506,7 +506,7 @@ bool lvm_create_clone(struct lxc_conf *conf, struct lxc_storage *orig, const char *thinpool; struct rsync_data data; const char *cmd_args[2]; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; char fstype[100] = "ext4"; uint64_t size = newsize; @@ -593,7 +593,7 @@ bool lvm_create_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, int lvm_destroy(struct lxc_storage *orig) { int ret; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; struct lvcreate_args cmd_args = {0}; 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, uint64_t sz; int ret, len; const char *cmd_args[2]; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; if (!specs) return -1; diff --git a/src/lxc/storage/overlay.c b/src/lxc/storage/overlay.c index a95c6b7e6..01546b1bf 100644 --- a/src/lxc/storage/overlay.c +++ b/src/lxc/storage/overlay.c @@ -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, const char *lxc_name, const char *lxc_path) { - char lxcpath[MAXPATHLEN]; + char lxcpath[PATH_MAX]; char **opts; int ret; size_t arrlen, i, len, rootfslen; @@ -766,8 +766,8 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs, } if (rootfs_path) { - ret = snprintf(lxcpath, MAXPATHLEN, "%s/%s", lxc_path, lxc_name); - if (ret < 0 || ret >= MAXPATHLEN) + ret = snprintf(lxcpath, PATH_MAX, "%s/%s", lxc_path, lxc_name); + if (ret < 0 || ret >= PATH_MAX) goto err; 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, const char *lxc_name, const char *newpath, const char *newname) { - char new_upper[MAXPATHLEN], new_work[MAXPATHLEN], old_upper[MAXPATHLEN], - old_work[MAXPATHLEN]; + char new_upper[PATH_MAX], new_work[PATH_MAX], old_upper[PATH_MAX], + old_work[PATH_MAX]; size_t i; struct lxc_list *iterator; char *cleanpath = NULL; @@ -852,13 +852,13 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path, } ret = - snprintf(old_work, MAXPATHLEN, "workdir=%s/%s", lxc_path, lxc_name); - if (ret < 0 || ret >= MAXPATHLEN) + snprintf(old_work, PATH_MAX, "workdir=%s/%s", lxc_path, lxc_name); + if (ret < 0 || ret >= PATH_MAX) goto err; ret = - snprintf(new_work, MAXPATHLEN, "workdir=%s/%s", cleanpath, newname); - if (ret < 0 || ret >= MAXPATHLEN) + snprintf(new_work, PATH_MAX, "workdir=%s/%s", cleanpath, newname); + if (ret < 0 || ret >= PATH_MAX) goto err; 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, if (!tmp) 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); - if (ret < 0 || ret >= MAXPATHLEN) + if (ret < 0 || ret >= PATH_MAX) goto err; - ret = snprintf(new_upper, MAXPATHLEN, "%s=%s/%s", tmp, + ret = snprintf(new_upper, PATH_MAX, "%s=%s/%s", tmp, cleanpath, newname); - if (ret < 0 || ret >= MAXPATHLEN) + if (ret < 0 || ret >= PATH_MAX) goto err; if (strstr(mnt_entry, old_upper)) { @@ -956,7 +956,7 @@ static int ovl_do_rsync(const char *src, const char *dest, { int ret = -1; struct rsync_data_char rdata = {0}; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; rdata.src = (char *)src; rdata.dest = (char *)dest; diff --git a/src/lxc/storage/rbd.c b/src/lxc/storage/rbd.c index daeb76e70..e02a629b9 100644 --- a/src/lxc/storage/rbd.c +++ b/src/lxc/storage/rbd.c @@ -104,7 +104,7 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n, int ret, len; char sz[24]; const char *cmd_args[2]; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; const char *rbdname = n; struct rbd_args args = {0}; @@ -198,7 +198,7 @@ int rbd_destroy(struct lxc_storage *orig) int ret; const char *src; char *rbdfullname; - char cmd_output[MAXPATHLEN]; + char cmd_output[PATH_MAX]; struct rbd_args args = {0}; size_t len; diff --git a/src/lxc/storage/storage.c b/src/lxc/storage/storage.c index 3a1053ea2..0a93a4d34 100644 --- a/src/lxc/storage/storage.c +++ b/src/lxc/storage/storage.c @@ -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 *oldname = c->name; const char *oldpath = c->config_path; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; struct rsync_data data = {0}; if (!src) { diff --git a/src/lxc/storage/storage_utils.c b/src/lxc/storage/storage_utils.c index 9efc939b1..67da0f9be 100644 --- a/src/lxc/storage/storage_utils.c +++ b/src/lxc/storage/storage_utils.c @@ -186,7 +186,7 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len) FILE *f; char *sp1, *sp2, *sp3; const char *l, *srcdev; - char devpath[MAXPATHLEN]; + char devpath[PATH_MAX]; char *line = NULL; if (!bdev || !bdev->src || !bdev->dest) @@ -415,11 +415,11 @@ const char *linkderef(const char *path, char *dest) if (!S_ISLNK(sbuf.st_mode)) return path; - ret = readlink(path, dest, MAXPATHLEN); + ret = readlink(path, dest, PATH_MAX); if (ret < 0) { SYSERROR("error reading link %s", path); return NULL; - } else if (ret >= MAXPATHLEN) { + } else if (ret >= PATH_MAX) { ERROR("link in %s too long", path); return NULL; } diff --git a/src/lxc/storage/zfs.c b/src/lxc/storage/zfs.c index a948755db..ba104da54 100644 --- a/src/lxc/storage/zfs.c +++ b/src/lxc/storage/zfs.c @@ -134,7 +134,7 @@ bool zfs_detect(const char *path) int ret; char *dataset; struct zfs_args cmd_args = {0}; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; if (!strncmp(path, "zfs:", 4)) return true; @@ -185,7 +185,7 @@ int zfs_mount(struct lxc_storage *bdev) char *mntdata, *tmp; const char *src; unsigned long mntflags; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; if (strcmp(bdev->type, "zfs")) return -22; @@ -287,7 +287,7 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig, struct lxc_storage *new, uint64_t newsize) { int ret; - char cmd_output[MAXPATHLEN], option[MAXPATHLEN]; + char cmd_output[PATH_MAX], option[PATH_MAX]; struct rsync_data data = {0, 0}; struct zfs_args cmd_args = {0}; const char *argv[] = {"zfs", /* 0 */ @@ -299,8 +299,8 @@ bool zfs_copy(struct lxc_conf *conf, struct lxc_storage *orig, NULL}; /* mountpoint */ - ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest); - if (ret < 0 || ret >= MAXPATHLEN) { + ret = snprintf(option, PATH_MAX, "mountpoint=%s", new->dest); + if (ret < 0 || ret >= PATH_MAX) { ERROR("Failed to create string"); return false; } @@ -348,7 +348,7 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, char *tmp, *snap_name, *snapshot; const char *orig_src; 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); if (*orig_src == '/') { @@ -423,8 +423,8 @@ bool zfs_snapshot(struct lxc_conf *conf, struct lxc_storage *orig, TRACE("Created zfs snapshot \"%s\"", snapshot); } - ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", new->dest); - if (ret < 0 || ret >= MAXPATHLEN) { + ret = snprintf(option, PATH_MAX, "mountpoint=%s", new->dest); + if (ret < 0 || ret >= PATH_MAX) { ERROR("Failed to create string"); free(snapshot); return -1; @@ -455,7 +455,7 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, char *dataset, *tmp; const char *orig_src; size_t dataset_len, len; - char cmd_output[MAXPATHLEN] = {0}; + char cmd_output[PATH_MAX] = {0}; if (!orig->src || !orig->dest) return -1; @@ -586,7 +586,7 @@ int zfs_destroy(struct lxc_storage *orig) bool found; char *parent_snapshot = NULL; 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); @@ -714,7 +714,7 @@ int zfs_create(struct lxc_storage *bdev, const char *dest, const char *n, int ret; size_t len; 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 */ "create", /* 1 */ "-o", "", /* 2, 3 */ @@ -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); - ret = snprintf(option, MAXPATHLEN, "mountpoint=%s", bdev->dest); - if (ret < 0 || ret >= MAXPATHLEN) { + ret = snprintf(option, PATH_MAX, "mountpoint=%s", bdev->dest); + if (ret < 0 || ret >= PATH_MAX) { ERROR("Failed to create string"); return -1; }