summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-12-01 14:30:44 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-12-01 14:30:44 +0000
commit47e5007b5b0ff70ff2397791613e461debe2548b (patch)
tree89a97ec24e4424f5fd81902d5c0a3046676c108c
parentaec152269c3f82497801d80de563b41f32c6b930 (diff)
downloaddrakx-47e5007b5b0ff70ff2397791613e461debe2548b.tar
drakx-47e5007b5b0ff70ff2397791613e461debe2548b.tar.gz
drakx-47e5007b5b0ff70ff2397791613e461debe2548b.tar.bz2
drakx-47e5007b5b0ff70ff2397791613e461debe2548b.tar.xz
drakx-47e5007b5b0ff70ff2397791613e461debe2548b.zip
we need loop-aes for mountloop, so we use change_loop with a special device number
-rw-r--r--mdk-stage1/init.c8
-rw-r--r--mdk-stage1/lomount.c18
-rw-r--r--mdk-stage1/mount.c3
3 files changed, 22 insertions, 7 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
index 5209f1f50..f5e18bb03 100644
--- a/mdk-stage1/init.c
+++ b/mdk-stage1/init.c
@@ -241,6 +241,7 @@ void doklog()
void del_loops(void)
{
char loopdev[] = "/dev/loop0";
+ char chloopdev[] = "/dev/chloop0";
int i;
for (i=0; i<8; i++) {
int fd;
@@ -251,6 +252,13 @@ void del_loops(void)
printf("\t%s\n", loopdev);
close(fd);
}
+ chloopdev[11] = '0' + i;
+ fd = open(chloopdev, O_RDONLY, 0);
+ if (fd > 0) {
+ if (!ioctl(fd, LOOP_CLR_FD, 0))
+ printf("\t%s\n", chloopdev);
+ close(fd);
+ }
}
}
diff --git a/mdk-stage1/lomount.c b/mdk-stage1/lomount.c
index 791db0d0f..25f72c345 100644
--- a/mdk-stage1/lomount.c
+++ b/mdk-stage1/lomount.c
@@ -115,24 +115,26 @@ set_loop (const char *device, const char *file, int gz)
}
-char* find_free_loop(void)
+char* find_free_loop(int chloop)
{
char loopdev[] = "/dev/loop0";
+ char chloopdev[] = "/dev/chloop0";
+ char * ldev = chloop ? chloopdev : loopdev;
struct loop_info loopinfo;
int i;
for (i=0; i<8; i++) {
int fd;
- loopdev[9] = '0' + i;
- ensure_dev_exists(loopdev);
- fd = open(loopdev, O_RDONLY);
+ ldev[strlen(ldev)-1] = '0' + i;
+ ensure_dev_exists(ldev);
+ fd = open(ldev, O_RDONLY);
if (!ioctl(fd, LOOP_GET_STATUS, &loopinfo)) {
close(fd);
continue;
}
if (errno == ENXIO) {
- log_message("%s is available", loopdev);
+ log_message("%s is available", ldev);
close(fd);
- return strdup(loopdev);
+ return strdup(ldev);
} else {
log_perror("LOOP_GET_STATUS(unexpected error)");
close(fd);
@@ -165,17 +167,19 @@ lomount(char *loopfile, char *where, char **dev, int gz)
long int flag;
char * loopdev;
+ int chloop = 0;
flag = MS_MGC_VAL;
flag |= MS_RDONLY;
#ifdef MANDRAKE_MOVE
my_insmod("change_loop", ANY_DRIVER_TYPE, NULL);
+ chloop = 1;
#else
my_insmod("loop", ANY_DRIVER_TYPE, NULL);
#endif
- if (!(loopdev = find_free_loop())) {
+ if (!(loopdev = find_free_loop(chloop))) {
log_message("could not find a free loop");
return 1;
}
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
index d5ecba619..64ae759f9 100644
--- a/mdk-stage1/mount.c
+++ b/mdk-stage1/mount.c
@@ -130,6 +130,9 @@ int ensure_dev_exists(const char * dev)
} else if (ptr_begins_static_str(name, "loop")) {
major = 7;
minor = name[4] - '0';
+ } else if (ptr_begins_static_str(name, "chloop")) {
+ major = 100;
+ minor = name[6] - '0';
} else {
log_message("I don't know how to create device %s, please post bugreport to me!", dev);
return -1;