mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-06 13:53:14 +00:00
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: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
9b0f04774f
commit
4c8ab83be6
@ -455,18 +455,16 @@ static int configure_rootfs(const char *name, const char *rootfs)
|
||||
char path[MAXPATHLEN];
|
||||
char absrootfs[MAXPATHLEN];
|
||||
char fstab[MAXPATHLEN];
|
||||
char *pwd;
|
||||
int ret;
|
||||
FILE *f;
|
||||
int ret;
|
||||
|
||||
if (!realpath(rootfs, absrootfs)) {
|
||||
lxc_log_syserror("failed to get real path for '%s'", rootfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
|
||||
|
||||
pwd = get_current_dir_name();
|
||||
|
||||
snprintf(absrootfs, MAXPATHLEN, "%s/%s", pwd, rootfs);
|
||||
|
||||
free(pwd);
|
||||
|
||||
if (access(absrootfs, F_OK)) {
|
||||
lxc_log_syserror("'%s' is not accessible", absrootfs);
|
||||
return -1;
|
||||
@ -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);
|
||||
|
||||
fclose(f);
|
||||
|
||||
if (ret < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user