diff --git a/utils.c b/utils.c index 0106251..3313ee8 100644 --- a/utils.c +++ b/utils.c @@ -29,6 +29,12 @@ void adjust_dev_path(const char **dev_path) err(errno, "Can't change working directory to %s at %s()", *dev_path, __func__); } + if (!chroot(*dev_path)) { + assert(!chdir("/")); + } else if (errno != EPERM) { + err(errno, "Can't change root directory to %s at %s()", *dev_path, __func__); + } + *dev_path = "."; }