summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/tools.c
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-10-19 21:30:12 +0100
committerColin Guthrie <colin@mageia.org>2013-10-29 20:29:07 +0000
commitc4321813f9f3cd4136203d52c0f20343d7722228 (patch)
treeba1cbb296d3d490142d670f88a2a76452a87829d /mdk-stage1/tools.c
parent7213bee2f13e551bffb7754846726833e196719b (diff)
downloaddrakx-c4321813f9f3cd4136203d52c0f20343d7722228.tar
drakx-c4321813f9f3cd4136203d52c0f20343d7722228.tar.gz
drakx-c4321813f9f3cd4136203d52c0f20343d7722228.tar.bz2
drakx-c4321813f9f3cd4136203d52c0f20343d7722228.tar.xz
drakx-c4321813f9f3cd4136203d52c0f20343d7722228.zip
stage1: Move the symlink creation from stage1 to init.
In order to run stage1 we now need to do things a little differently, namely that we move the symlinking fixups into 'init' itself which we will actually call as a kind of fake switch_root implementation to avoid hacking dracut too much[1]. As we run stage1 during dracut's 'mount' phase we should not do the symlink hacks so early otherwise it will mess up the rest of the dracut initqueue processing. Currently, the initrd's /usr is nuked and then symlinked, but to allow for easier debugging I now just bind mount the stage2 /usr over the top which allows us to unmount it again easily enough if we want to go back. We no longer touch the /bin, /sbin or /lib[64] symlinks as these are relative and simply bind mounting /usr is enough to fix all of them. 1. This scheme will have to change if we eventually swtich to a systemd based dracut invocation.
Diffstat (limited to 'mdk-stage1/tools.c')
-rw-r--r--mdk-stage1/tools.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index aca40c971..78108d6a9 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -148,65 +148,6 @@ enum return_type copy_file(char * from, char * to, void (*callback_func)(int ove
}
}
-enum return_type recursiveRemove(char *file)
-{
- struct stat sb;
-
- if (lstat(file, &sb) != 0) {
- log_message("failed to stat %s: %d", file, errno);
- return RETURN_ERROR;
- }
-
- /* only descend into subdirectories if device is same as dir */
- if (S_ISDIR(sb.st_mode)) {
- char * strBuf = alloca(strlen(file) + 1024);
- DIR * dir;
- struct dirent * d;
-
- if (!(dir = opendir(file))) {
- log_message("error opening %s: %d", file, errno);
- return RETURN_ERROR;
- }
- while ((d = readdir(dir))) {
- if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
- continue;
-
- strcpy(strBuf, file);
- strcat(strBuf, "/");
- strcat(strBuf, d->d_name);
-
- if (recursiveRemove(strBuf) != 0) {
- closedir(dir);
- return RETURN_ERROR;
- }
- }
- closedir(dir);
-
- if (rmdir(file)) {
- log_message("failed to rmdir %s: %d", file, errno);
- return RETURN_ERROR;
- }
- } else {
- if (unlink(file) != 0) {
- log_message("failed to remove %s: %d", file, errno);
- return RETURN_ERROR;
- }
- }
- return RETURN_OK;
-}
-
-enum return_type recursiveRemove_if_it_exists(char *file)
-{
- struct stat sb;
-
- if (lstat(file, &sb) != 0) {
- /* if file doesn't exist, simply return OK */
- return RETURN_OK;
- }
-
- return recursiveRemove(file);
-}
-
enum return_type mount_compressed_image(char *compressed_image, char *location_mount)
{
if (lomount(compressed_image, location_mount, NULL, 1)) {