Commit 4c8ab83b by dlezcano

Make use of realpath

From: Daniel Lezcano <daniel.lezcano@free.fr> The realpath function is more convenient to build the absolute path of the rootfs. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 9b0f0477
...@@ -455,17 +455,15 @@ static int configure_rootfs(const char *name, const char *rootfs) ...@@ -455,17 +455,15 @@ static int configure_rootfs(const char *name, const char *rootfs)
char path[MAXPATHLEN]; char path[MAXPATHLEN];
char absrootfs[MAXPATHLEN]; char absrootfs[MAXPATHLEN];
char fstab[MAXPATHLEN]; char fstab[MAXPATHLEN];
char *pwd;
int ret;
FILE *f; FILE *f;
int ret;
snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name); if (!realpath(rootfs, absrootfs)) {
lxc_log_syserror("failed to get real path for '%s'", rootfs);
pwd = get_current_dir_name(); return -1;
}
snprintf(absrootfs, MAXPATHLEN, "%s/%s", pwd, rootfs);
free(pwd); snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
if (access(absrootfs, F_OK)) { if (access(absrootfs, F_OK)) {
lxc_log_syserror("'%s' is not accessible", absrootfs); lxc_log_syserror("'%s' is not accessible", absrootfs);
...@@ -486,6 +484,7 @@ static int configure_rootfs(const char *name, const char *rootfs) ...@@ -486,6 +484,7 @@ static int configure_rootfs(const char *name, const char *rootfs)
} }
ret = fprintf(f, "%s %s none bind 0 0\n", absrootfs, path); ret = fprintf(f, "%s %s none bind 0 0\n", absrootfs, path);
fclose(f); fclose(f);
if (ret < 0) { if (ret < 0) {
......
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