utils: s/MAXPATHLEN/PATH_MAX/g

parent 1d11cb68
...@@ -84,7 +84,7 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev, ...@@ -84,7 +84,7 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev,
struct dirent *direntp; struct dirent *direntp;
DIR *dir; DIR *dir;
int ret, failed=0; int ret, failed=0;
char pathname[MAXPATHLEN]; char pathname[PATH_MAX];
bool hadexclude = false; bool hadexclude = false;
dir = opendir(dirname); dir = opendir(dirname);
...@@ -101,8 +101,8 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev, ...@@ -101,8 +101,8 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev,
!strcmp(direntp->d_name, "..")) !strcmp(direntp->d_name, ".."))
continue; continue;
rc = snprintf(pathname, MAXPATHLEN, "%s/%s", dirname, direntp->d_name); rc = snprintf(pathname, PATH_MAX, "%s/%s", dirname, direntp->d_name);
if (rc < 0 || rc >= MAXPATHLEN) { if (rc < 0 || rc >= PATH_MAX) {
ERROR("pathname too long"); ERROR("pathname too long");
failed=1; failed=1;
continue; continue;
...@@ -671,11 +671,11 @@ int detect_shared_rootfs(void) ...@@ -671,11 +671,11 @@ int detect_shared_rootfs(void)
bool switch_to_ns(pid_t pid, const char *ns) bool switch_to_ns(pid_t pid, const char *ns)
{ {
int fd, ret; int fd, ret;
char nspath[MAXPATHLEN]; char nspath[PATH_MAX];
/* Switch to new ns */ /* Switch to new ns */
ret = snprintf(nspath, MAXPATHLEN, "/proc/%d/ns/%s", pid, ns); ret = snprintf(nspath, PATH_MAX, "/proc/%d/ns/%s", pid, ns);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
return false; return false;
fd = open(nspath, O_RDONLY); fd = open(nspath, O_RDONLY);
...@@ -745,7 +745,7 @@ bool detect_ramfs_rootfs(void) ...@@ -745,7 +745,7 @@ bool detect_ramfs_rootfs(void)
char *on_path(const char *cmd, const char *rootfs) char *on_path(const char *cmd, const char *rootfs)
{ {
char *entry = NULL, *path = NULL; char *entry = NULL, *path = NULL;
char cmdpath[MAXPATHLEN]; char cmdpath[PATH_MAX];
int ret; int ret;
path = getenv("PATH"); path = getenv("PATH");
...@@ -758,11 +758,11 @@ char *on_path(const char *cmd, const char *rootfs) ...@@ -758,11 +758,11 @@ char *on_path(const char *cmd, const char *rootfs)
lxc_iterate_parts (entry, path, ":") { lxc_iterate_parts (entry, path, ":") {
if (rootfs) if (rootfs)
ret = snprintf(cmdpath, MAXPATHLEN, "%s/%s/%s", rootfs, ret = snprintf(cmdpath, PATH_MAX, "%s/%s/%s", rootfs,
entry, cmd); entry, cmd);
else else
ret = snprintf(cmdpath, MAXPATHLEN, "%s/%s", entry, cmd); ret = snprintf(cmdpath, PATH_MAX, "%s/%s", entry, cmd);
if (ret < 0 || ret >= MAXPATHLEN) if (ret < 0 || ret >= PATH_MAX)
continue; continue;
if (access(cmdpath, X_OK) == 0) { if (access(cmdpath, X_OK) == 0) {
...@@ -1184,20 +1184,20 @@ int safe_mount(const char *src, const char *dest, const char *fstype, ...@@ -1184,20 +1184,20 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
*/ */
int lxc_mount_proc_if_needed(const char *rootfs) int lxc_mount_proc_if_needed(const char *rootfs)
{ {
char path[MAXPATHLEN]; char path[PATH_MAX];
int link_to_pid, linklen, mypid, ret; int link_to_pid, linklen, mypid, ret;
char link[INTTYPE_TO_STRLEN(pid_t)] = {0}; char link[INTTYPE_TO_STRLEN(pid_t)] = {0};
ret = snprintf(path, MAXPATHLEN, "%s/proc/self", rootfs); ret = snprintf(path, PATH_MAX, "%s/proc/self", rootfs);
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
SYSERROR("proc path name too long"); SYSERROR("proc path name too long");
return -1; return -1;
} }
linklen = readlink(path, link, sizeof(link)); linklen = readlink(path, link, sizeof(link));
ret = snprintf(path, MAXPATHLEN, "%s/proc", rootfs); ret = snprintf(path, PATH_MAX, "%s/proc", rootfs);
if (ret < 0 || ret >= MAXPATHLEN) { if (ret < 0 || ret >= PATH_MAX) {
SYSERROR("proc path name too long"); SYSERROR("proc path name too long");
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