summaryrefslogtreecommitdiffstats
path: root/loader/init.c
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>2000-06-02 21:30:47 +0000
committerErik Troan <ewt@redhat.com>2000-06-02 21:30:47 +0000
commit5e4404c4bbd2b6c5662b6c062ec20711a4d15f16 (patch)
tree6b6382fcd3f4a1e76b4da9eb2b30f106e6aed4e7 /loader/init.c
parent6c6739352ad850b9b257239bd8e3626bec89e8c0 (diff)
downloadanaconda-5e4404c4bbd2b6c5662b6c062ec20711a4d15f16.tar.gz
anaconda-5e4404c4bbd2b6c5662b6c062ec20711a4d15f16.tar.xz
anaconda-5e4404c4bbd2b6c5662b6c062ec20711a4d15f16.zip
handle /tmp/cleanup
Diffstat (limited to 'loader/init.c')
-rw-r--r--loader/init.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/loader/init.c b/loader/init.c
index cf84790d8..08107b42e 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -445,6 +445,60 @@ void disableSwap(void) {
}
}
+int handleCleanup(void) {
+ int i;
+ char buf[4096];
+ int fd;
+ int loopfd;
+ char * start, * end;
+
+ fd = open("/tmp/cleanup", O_RDONLY, 0);
+ if (fd < 0) return 1;
+
+ i = read(fd, buf, sizeof(buf) - 1);
+ buf[i] = '\0';
+ close(fd);
+
+ start = buf;
+ while (*start) {
+ end = start;
+ while (*end && *end != '\n') end++;
+ if (!*end) return 0;
+ *end = '\0';
+
+ if (!strncmp(start, "lounsetup ", 10)) {
+ start += 10;
+ while (isspace(*start) && start < end) start++;
+ if (start == end) return 1;
+
+ loopfd = open(start, O_RDONLY, 0);
+ if (loopfd < 0) {
+ printf("\terror opening %s: %d\n", start, errno);
+ } else {
+ printf("disabling %s", start);
+ if (ioctl(loopfd, LOOP_CLR_FD, 0))
+ printf(" failed: %d", errno);
+ printf("\n");
+ }
+
+ close(loopfd);
+ } else if (!strncmp(start, "umount ", 7)) {
+ start += 7;
+ while (isspace(*start) && start < end) start++;
+ if (start == end) return 1;
+
+ printf("unmounting %s...", start);
+ if (umount(start) < 0)
+ printf(" failed (%d)", errno);
+ printf("\n");
+ }
+
+ start = end + 1;
+ }
+
+ return 0;
+}
+
int main(int argc, char **argv) {
pid_t installpid, childpid;
int waitStatus;
@@ -663,6 +717,8 @@ int main(int argc, char **argv) {
printf("disabling swap...\n");
disableSwap();
+ handleCleanup();
+
printf("unmounting filesystems...\n");
unmountFilesystems();