From: Daniel Lezcano <daniel.lezcano@free.fr>
The realpath function is more convenient to build the absolute path of
the rootfs.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
char path[MAXPATHLEN];
char absrootfs[MAXPATHLEN];
char fstab[MAXPATHLEN];
char path[MAXPATHLEN];
char absrootfs[MAXPATHLEN];
char fstab[MAXPATHLEN];
- snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
-
- pwd = get_current_dir_name();
-
- snprintf(absrootfs, MAXPATHLEN, "%s/%s", pwd, rootfs);
+ if (!realpath(rootfs, absrootfs)) {
+ lxc_log_syserror("failed to get real path for '%s'", rootfs);
+ return -1;
+ }
+ snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
if (access(absrootfs, F_OK)) {
lxc_log_syserror("'%s' is not accessible", absrootfs);
if (access(absrootfs, F_OK)) {
lxc_log_syserror("'%s' is not accessible", absrootfs);
}
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);
if (ret < 0) {
fclose(f);
if (ret < 0) {