|
From: Ronald P. R. <ron...@xs...> - 2012-06-24 12:49:35
|
Accidental double-mounting does happen to me occasionally, although I know I should take care that it does not happen.
Even if a solution like this would work, I suppose there is no way to prevent mounting of a disk image in OSX that is already mounted in SS/B2.
Ronald.
Op 24 jun. 2012, om 07:53 heeft Dave Vasilevsky het volgende geschreven:
> On a couple of occasions, disk images of mine have become corrupted
> due to accidental double-mounting in SheepShaver and/or BasiliskII. I
> propose we try and minimize the chance of this happening. Two
> situations need to be dealt with:
>
> 1. The host OS and SheepShaver (or B2) both have the disk mounted. We
> already try to prevent this with is_drive_mounted(), but it only works
> on Linux hosts, and only with real devices, not loop mounts.
>
> It should be possible to extend this to OS X. For real devices, using
> getmntinfo(3) should be straightforward. For disk images (the
> equivalent of loop mounts), we can use IOKit to try and detect that
> they're in use, though it uses undocumented IOKit properties. Some
> code I whipped up, without proper error checking or memory management:
>
> NSString *imgPath = @"/my/disk/image.img";
> NSData *imgData = [imgPath dataUsingEncoding:NSUTF8StringEncoding];
> CFMutableDictionaryRef match = IOServiceMatching("IOHDIXHDDrive");
> CFDictionaryAddValue(match, CFSTR(kIOPropertyMatchKey),
> [NSDictionary dictionaryWithObject: imgData forKey: @"image-path"]);
> io_service_t serv = IOServiceGetMatchingService(kIOMasterPortDefault,
> (CFDictionaryRef)match);
> if (serv) printf("It's mounted!\n");
>
> I don't know if there's a good API to check for loop mounts on Linux.
> Parse the output of losetup(8)? Some place in sysfs?
>
> 2. Multiple instances of B2/SS using the same disk image. We should be
> able to prevent this by using advisory locks in Sys_open().
>
>
> What do folks think? Worth working on?
>
> Cheers,
> Dave
>
|