summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-12-05 14:05:12 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-12-05 14:05:12 +0000
commit103bd01b806de899a006b689ae648c3b33e45649 (patch)
treea7b8ee03964716c6606c05fdf6179785e0191169
parent37968dcdab04cce84263ad03ede5e88c83161cc8 (diff)
downloaddrakx-103bd01b806de899a006b689ae648c3b33e45649.tar
drakx-103bd01b806de899a006b689ae648c3b33e45649.tar.gz
drakx-103bd01b806de899a006b689ae648c3b33e45649.tar.bz2
drakx-103bd01b806de899a006b689ae648c3b33e45649.tar.xz
drakx-103bd01b806de899a006b689ae648c3b33e45649.zip
Andrey told me how to tell supermount to force unmount
-rw-r--r--mdk-stage1/init.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
index f5e18bb03..454433179 100644
--- a/mdk-stage1/init.c
+++ b/mdk-stage1/init.c
@@ -270,6 +270,15 @@ struct filesystem
int mounted;
};
+char* strcat(register char* s,register const char* t)
+{
+ char *dest=s;
+ s+=strlen(s);
+ for (;;)
+ if (!(*s = *t)) break; ++s; ++t;
+ return dest;
+}
+
/* attempt to unmount all filesystems in /proc/mounts */
void unmount_filesystems(void)
{
@@ -341,16 +350,37 @@ void unmount_filesystems(void)
#ifdef MANDRAKE_MOVE
if (!disallow_eject) {
- fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK, 0);
- if (fd > 0) {
- ioctl(fd, CDROM_LOCKDOOR, 0);
- close(fd);
- }
- fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK, 0);
+ fd = open("/proc/fs/supermount/subfs", O_RDONLY, 0);
if (fd > 0) {
- if (!ioctl(fd, CDROMEJECT, 0))
- goto ejected;
+ char devices[100][100];
+ int i = 0;
+ char * ptr1, * ptr2;
+ size = read(fd, buf, sizeof(buf) - 1);
+ buf[size] = '\0';
close(fd);
+ ptr1 = buf;
+ ptr2 = buf;
+ while (*ptr1 && *ptr2) {
+ char * ptrf = ptr1;
+ while (*ptr2 && *ptr2 != '\n')
+ ptr2++;
+ while (*ptrf && *ptrf != ' ')
+ ptrf++;
+ if (*ptrf)
+ *ptrf = '\0';
+ strcpy(devices[i], ptr1);
+ i++;
+ if (*ptr2)
+ ptr2++;
+ ptr1 = ptr2;
+ }
+ while (i >= 1) {
+ i--;
+ strcat(devices[i], " release force");
+ fd = open("/proc/fs/supermount/subfs", O_WRONLY, 0);
+ write(fd, devices[i], strlen(devices[i]));
+ close(fd);
+ }
}
fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK, 0);
if (fd > 0) {
@@ -362,8 +392,6 @@ void unmount_filesystems(void)
ioctl(fd, CDROMEJECT, 0);
close(fd);
}
- ejected:
- close(fd);
}
#endif