tools: s/MAXPATHLEN/PATH_MAX/g

parent dc815306
......@@ -137,10 +137,10 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
} else {
char buffer[MAXPATHLEN];
char buffer[PATH_MAX];
int ret;
ret = c->get_cgroup_item(c, state_object, buffer, MAXPATHLEN);
ret = c->get_cgroup_item(c, state_object, buffer, PATH_MAX);
if (ret < 0) {
ERROR("Failed to retrieve value of '%s' for '%s:%s'",
state_object, my_args.lxcpath[0], my_args.name);
......
......@@ -263,17 +263,17 @@ static struct mnts *add_mnt(struct mnts **mnts, unsigned int *num, enum mnttype
static int mk_rand_ovl_dirs(struct mnts *mnts, unsigned int num, struct lxc_arguments *arg)
{
char upperdir[MAXPATHLEN];
char workdir[MAXPATHLEN];
char upperdir[PATH_MAX];
char workdir[PATH_MAX];
unsigned int i;
int ret;
struct mnts *m = NULL;
for (i = 0, m = mnts; i < num; i++, m++) {
if (m->mnt_type == LXC_MNT_OVL) {
ret = snprintf(upperdir, MAXPATHLEN, "%s/%s/delta#XXXXXX",
ret = snprintf(upperdir, PATH_MAX, "%s/%s/delta#XXXXXX",
arg->newpath, arg->newname);
if (ret < 0 || ret >= MAXPATHLEN)
if (ret < 0 || ret >= PATH_MAX)
return -1;
if (!mkdtemp(upperdir))
......@@ -285,9 +285,9 @@ static int mk_rand_ovl_dirs(struct mnts *mnts, unsigned int num, struct lxc_argu
}
if (m->mnt_type == LXC_MNT_OVL) {
ret = snprintf(workdir, MAXPATHLEN, "%s/%s/work#XXXXXX",
ret = snprintf(workdir, PATH_MAX, "%s/%s/work#XXXXXX",
arg->newpath, arg->newname);
if (ret < 0 || ret >= MAXPATHLEN)
if (ret < 0 || ret >= PATH_MAX)
return -1;
if (!mkdtemp(workdir))
......@@ -381,7 +381,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
struct lxc_arguments *arg, char **args, int flags)
{
char *premount;
char randname[MAXPATHLEN];
char randname[PATH_MAX];
unsigned int i;
int ret = 0;
bool bret = true, started = false;
......@@ -391,8 +391,8 @@ static int do_clone_ephemeral(struct lxc_container *c,
attach_options.env_policy = LXC_ATTACH_CLEAR_ENV;
if (!arg->newname) {
ret = snprintf(randname, MAXPATHLEN, "%s/%s_XXXXXX", arg->newpath, arg->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(randname, PATH_MAX, "%s/%s_XXXXXX", arg->newpath, arg->name);
if (ret < 0 || ret >= PATH_MAX)
return -1;
if (!mkdtemp(randname))
......@@ -481,7 +481,7 @@ destroy_and_put:
if (started)
clone->shutdown(clone, -1);
ret = clone->get_config_item(clone, "lxc.ephemeral", tmp_buf, MAXPATHLEN);
ret = clone->get_config_item(clone, "lxc.ephemeral", tmp_buf, PATH_MAX);
if (ret > 0 && strcmp(tmp_buf, "0"))
clone->destroy(clone);
......
......@@ -84,11 +84,11 @@ static bool do_destroy(struct lxc_container *c)
{
int ret;
bool bret = true;
char path[MAXPATHLEN];
char path[PATH_MAX];
/* First check whether the container has dependent clones or snapshots. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;
if (file_exists(path)) {
......@@ -96,8 +96,8 @@ static bool do_destroy(struct lxc_container *c)
return false;
}
ret = snprintf(path, MAXPATHLEN, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;
if (rmdir(path) < 0 && errno != ENOENT) {
......@@ -138,7 +138,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
struct lxc_container *c1;
struct stat fbuf;
bool bret = false;
char path[MAXPATHLEN];
char path[PATH_MAX];
char *buf = NULL;
char *lxcpath = NULL;
char *lxcname = NULL;
......@@ -147,8 +147,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
ssize_t bytes;
/* Destroy clones. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;
fd = open(path, O_RDONLY | O_CLOEXEC);
......@@ -195,8 +195,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
}
/* Destroy snapshots located in the containers snap/ folder. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;
if (rmdir(path) < 0 && errno != ENOENT)
......
......@@ -129,11 +129,11 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
static bool set_argv(struct lxc_container *c, struct lxc_arguments *args)
{
int ret;
char buf[MAXPATHLEN];
char buf[PATH_MAX];
char **components, **p;
buf[0] = '\0';
ret = c->get_config_item(c, "lxc.execute.cmd", buf, MAXPATHLEN);
ret = c->get_config_item(c, "lxc.execute.cmd", buf, PATH_MAX);
if (ret < 0)
return false;
......
......@@ -182,7 +182,7 @@ static int get_namespace_flags(char *namespaces)
static bool lookup_user(const char *optarg, uid_t *uid)
{
char name[MAXPATHLEN];
char name[PATH_MAX];
struct passwd pwent;
struct passwd *pwentp = NULL;
char *buf;
......
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