summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authordlehman <dlehman>2007-01-17 22:25:06 +0000
committerdlehman <dlehman>2007-01-17 22:25:06 +0000
commit48cb0bc9f3e2d13813f325964793e0944eb6e549 (patch)
tree648031edd19715fa38513e74103560f6de6452d6 /loader2
parent4bfd3e828da9acc763ca022fdfc73165fc556e71 (diff)
downloadanaconda-48cb0bc9f3e2d13813f325964793e0944eb6e549.tar.gz
anaconda-48cb0bc9f3e2d13813f325964793e0944eb6e549.tar.xz
anaconda-48cb0bc9f3e2d13813f325964793e0944eb6e549.zip
* loader2/method.c (unpackCpioBall): new function to unpack a
cpio ball into a specified root directory * loader2/method.c (copyUpdatesImg): if the updates can't be mounted try unpacking them as a cpio ball
Diffstat (limited to 'loader2')
-rw-r--r--loader2/method.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/loader2/method.c b/loader2/method.c
index 03c5e75e9..ebb92e71f 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -40,6 +40,7 @@
#include "../isys/imount.h"
#include "../isys/isys.h"
+#include "../isys/cpio.h"
#include "devt.h"
@@ -511,6 +512,38 @@ int copyDirectory(char * from, char * to) {
return 0;
}
+/*
+ * unpack a gzipped cpio ball into a tree rooted at rootDir
+ * returns 0 on success, 1 on failure
+ */
+int unpackCpioBall(char * ballPath, char * rootDir) {
+ gzFile fd;
+ char *buf, *cwd;
+ int rc = 1;
+
+ if (access(ballPath, R_OK))
+ return 1;
+
+ if (access(rootDir, R_OK))
+ mkdirChain(rootDir);
+
+ buf = (char *)malloc(PATH_MAX);
+ cwd = getcwd(buf, PATH_MAX);
+ if ((rc = chdir(rootDir)) == 0) {
+ fd = gunzip_open(path);
+ if (fd) {
+ if (!installCpioFile(fd, NULL, NULL, 0)) {
+ logMessage(INFO, "copied contents of %s into %s", ballPath,
+ rootDir);
+ rc = chdir(cwd);
+ return 0;
+ }
+ }
+ rc = chdir(cwd);
+ }
+
+ return 1;
+}
void copyUpdatesImg(char * path) {
if (!access(path, R_OK)) {
@@ -518,6 +551,8 @@ void copyUpdatesImg(char * path) {
copyDirectory("/tmp/update-disk", "/tmp/updates");
umountLoopback("/tmp/update-disk", "loop7");
unlink("/tmp/update-disk");
+ } else {
+ unpackCpioBall(path, "/tmp/updates");
}
}
}