Do you have to unmount the boot partition

This forum is for discussion about general software issues.

Do you have to unmount the boot partition

Postby mashley » Sat Apr 26, 2014 4:17 pm

Hi all

For my Raspberry Pi SNES case mod, I'm planning on making the root filesystem read only. I then intend to symlink the directory where the SNES emulator saves (the only thing which will be written to the SD card) to a directory on /boot, which I will leave read/write. Is it safe to power the system off without unmounting a FAT formatted boot partition?

Thanks in advance.

Edit - I should have said, the point of this is so I can power the console off without having to shut down the OS first (i.e. closer to how an original SNES would operate)
mashley
 
Posts: 28
Joined: Wed Apr 16, 2014 8:31 pm

Re: Do you have to unmount the boot partition

Postby WarheadsSE » Sat Apr 26, 2014 5:10 pm

No, that can/will piss off FAT partitions too. Think about what happens after a while if you pop a thumb drive in and out of a Windows machine a bunch of times. Eventually you need to fsck it and pray :)

You really should have the power button trigger a GPIO that is watched with input or those lines. After all, reset doesn't need to actually power cycle the board, most of the time, so that too can be done safely.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Do you have to unmount the boot partition

Postby mashley » Sat Apr 26, 2014 10:06 pm

Thanks very much for your reply! Good to know that I need to unmount even FAT partitions. I have the SNES reset switch wired up to GPIO pins which are monitored by a python script and halt the Pi when the button is pressed. But I would like to be able to power the machine off without having to shut down if possible, as the aim is for the machine to be as close to an original SNES as possible. I'm now considering modifying the snes9x source code to make it mount a separate partition just before and after loading and saving emulator save files. That way the filesystem should be safe as long as the Pi isn't powered off during game load/save operations.
mashley
 
Posts: 28
Joined: Wed Apr 16, 2014 8:31 pm

Re: Do you have to unmount the boot partition

Postby WarheadsSE » Sun Apr 27, 2014 3:47 pm

Or, just
$this->bbcode_second_pass_code('', ' mount -o remount,rw <path>
<save>
sync
mount -o remount,ro <path>
')
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Do you have to unmount the boot partition

Postby mashley » Sun Apr 27, 2014 5:13 pm

Yeah, that was the idea behind what I was thinking. I want this to happy transparently when I save the game within snes9x, so I'll probably modify the snes9x code to add calls to those shell commands wrapping around the original save function.
mashley
 
Posts: 28
Joined: Wed Apr 16, 2014 8:31 pm

Re: Do you have to unmount the boot partition

Postby WarheadsSE » Sun Apr 27, 2014 6:57 pm

Sounds to me like you're modifying something for an overly specific (read slightly selfish) need that may cause headaches for users in the future. I am not saying this is not the way to go, but see if you can find something outside modifying the sources of the existing package.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Do you have to unmount the boot partition

Postby mashley » Mon Apr 28, 2014 1:05 pm

Well, if there is another way of catching when snes9x is about to save the SRAM and remount the partition rw just before and then ro just after then I will gladly try it, but I can't think of how that could work. As for modifying the source, I'm not sure why this would be considered selfish or problematic for other users when the changes would be to a local copy of the source on my RPi.
mashley
 
Posts: 28
Joined: Wed Apr 16, 2014 8:31 pm

Re: Do you have to unmount the boot partition

Postby mashley » Wed Apr 30, 2014 5:18 pm

Just to follow up on this, I have succeeded in getting snes9x to remount the filesystem read/write when it saves the game's SRAM. It then saves the file and finally remounts the filesystem read only. In case anybody is interested, this meant adding calls to mount() in CMemory::SaveSRAM(), defined in memmap.cpp. Here's the modified function:

$this->bbcode_second_pass_code('', 'bool8_32 CMemory::SaveSRAM (const char *filename)
{
int size = Memory.SRAMSize ?
(1 << (Memory.SRAMSize + 3)) * 128 : 0;
#ifndef _ZAURUS
if (Settings.SRTC)
{
size += SRTC_SRAM_PAD;
S9xSRTCPreSaveState ();
}

if (Settings.SDD1)
S9xSDD1SaveLoggedData ();
#endif
if (size > 0x20000)
size = 0x20000;

if (size && *Memory.ROMFilename)
{
if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT, NULL) != 0) {
fprintf(stderr, "Could not remount root fs read/write");
return(FALSE);
}

FILE *file;
if ((file = fopen (filename, "wb")))
{
fwrite ((char *) ::SRAM, size, 1, file);
fclose (file);
#if defined(__linux)
chown (filename, getuid (), getgid ());
#endif
if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL) != 0) {
fprintf(stderr, "Could not remount roof fs read only. %s", strerror(errno));
}
return (TRUE);
}
}

if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL) != 0) {
fprintf(stderr, "Could not remount roof fs read only (2)");
}

return (FALSE);
}')
mashley
 
Posts: 28
Joined: Wed Apr 16, 2014 8:31 pm


Return to General

Who is online

Users browsing this forum: Google [Bot] and 26 guests