]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: s/MAXPATHLEN/PATH_MAX/g
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 7 Oct 2018 08:06:52 +0000 (10:06 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 7 Oct 2018 08:06:52 +0000 (10:06 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/storage/btrfs.c
src/lxc/storage/loop.c
src/lxc/storage/lvm.c
src/lxc/storage/overlay.c
src/lxc/storage/rbd.c
src/lxc/storage/storage.c
src/lxc/storage/storage_utils.c
src/lxc/storage/zfs.c

index 049074a455d6cc71fa524174bccad61a2a17ef98..b850611dcb053850b05c95fa320a741b3e6347ec 100644 (file)
@@ -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)
index 8ea40e088f7eac26df3775e61f2756ede9ea735c..35cb13e068bf701d02533d453cedcf9d4422c80c 100644 (file)
@@ -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 */
index 8bb16175db4611f9ddb616584de83c14280be0e9..6908e9066c3dbecc914686132403735b85de2065 100644 (file)
@@ -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;
index a95c6b7e6eaa01da068269be776c6ca81dc33e0e..01546b1bf1a196953a161d0e230d6b52faac6a0f 100644 (file)
@@ -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;
index daeb76e708920d04b28b13e39d8d1edcf041f493..e02a629b9181bf93c235fefbc7fbf0a902d6ad34 100644 (file)
@@ -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;
 
index 3a1053ea23c8ef792a5f00fed9914e15c179aa50..0a93a4d34b39a111eb1975e1af74b129933e0314 100644 (file)
@@ -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) {
index 9efc939b185272d892b045c1c54adf48f1ebc059..67da0f9beddca9e48f43edc459aad0d6424a383d 100644 (file)
@@ -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;
        }
index a948755db558aaa506afaa5fedbd9f0d2197f6bf..ba104da54239aeb3da59bca985f21a0924ea2474 100644 (file)
@@ -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;
        }