sdcard corruption

Get technical support from the community & developers with specific X16 programs if you can't find the solution elsewhere
(for general non-support related chat about programs please comment directly under the program in the software library)
Post Reply
Stefan
Posts: 456
Joined: Thu Aug 20, 2020 8:59 am

sdcard corruption

Post by Stefan »


Hi,

I've been testing to write sequential files to the sdcard image using the standard KERNAL routines (SETNAM, SETLFS, OPEN, CHKOUT and CHROUT) in emulator R38.

I've noticed that files sometimes get corrupted. It seems to happen if the sdcard is mounted on the host computer's file system at the same time as it's attached to the emulator.

However, writing to the sdcard seems stable if it's not mounted to the host system at the same time. I'm running macOS Catalina.

Yuki
Posts: 126
Joined: Mon Apr 27, 2020 1:50 am

sdcard corruption

Post by Yuki »


Yeah, it's never recommended to open a disk image with anything while it's mounted in the host filesystem, mostly due to caching and weird stuff the operating system do. It's not just an emulator problem, I'd say.

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

sdcard corruption

Post by SerErris »


Yep, I would not consider that a bug, other than that the emulator should exclusively mount it to avoid such tries. 

TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

sdcard corruption

Post by TomXP411 »


Yeah, there's no file contention management in the emulator OR in the host operating system. Disk images are not meant to be mounted by two different processes at once. In fact, I'm not sure how you actually managed that - the emulator and MacOS should have both set an exclusive lock on the file. The fact that you WERE able to open the image in the emulator while it was mounted in MacOS is actually the bug... MacOS should not have let you.

 

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

sdcard corruption

Post by SerErris »


You can open with lock or without ... systemcalls for both exist and there is nothing wrong with it. But maybe the emulator should use a locked opening.

Stefan
Posts: 456
Joined: Thu Aug 20, 2020 8:59 am

sdcard corruption

Post by Stefan »



59 minutes ago, SerErris said:




You can open with lock or without ... systemcalls for both exist and there is nothing wrong with it. But maybe the emulator should use a locked opening.



Yes.

However, I think you may call it a feature, and keep the emulator as is ? No problem, as long as you're aware.

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

sdcard corruption

Post by SerErris »



19 hours ago, Stefan said:




Yes.



However, I think you may call it a feature, and keep the emulator as is ? No problem, as long as you're aware.



Agreed ... as long as you do not write to it at the same time ... you might use it to read some debugging from PC side from it. 

Post Reply