I've encountered something very strange... as a result, I don't really know what question to ask exactly, other than: has anyone else seen this before?
Basically, I mount the SD card on /tmp/sd_card like so:
Code:
mkdir -p /tmp/sd_card
mount -t vfat -o noatime,nodiratime,iocharset=utf8,shortname=winnt /dev/sdmscard/sdmsa1 /tmp/sd_card
Then I run /tmp/sd_card/reader/main.sh which creates /tmp/sd_card/reader_out and tries to log its actions to /tmp/sd_card/reader_out/main.log like so (comments omitted):
Code:
#!/bin/sh
PATH="/usr/local/bin:/usr/bin:/sbin:/bin:/usr/local/sony/bin:/usr/sbin"
LD_LIBRARY_PATH="/opt/sony/ebook/application:/lib:/usr/lib:/usr/local/sony/lib:/opt/sony/ebook/lib"
SD_CARD=/tmp/sd_card
SD=$SD_CARD/reader
OUT=$SD_CARD/reader_out
export OUT SD
# working directory
WD=$SD
LOG=$OUT/main.log
export WD LOG
# Add our bin and lib on the SD reader
PATH="$WD/bin:$PATH"
LD_LIBRARY_PATH="$WD/lib:$LD_LIBRARY_PATH"
export PATH LD_LIBRARY_PATH
mkdir -p $OUT
echo main.sh begins > $LOG
$WD/programs/fb >> $LOG 2>&1
echo main.sh ends >> $LOG
sync
sync
return 0
After main.sh finishes running, I unmount the SD card:
Code:
sync
umount /tmp/sd_card
Now, here's the crazy bit. Note I call sync at least three times, but after I unmount, /reader_out/main.log is nowhere to be found on the SD card, it just gets lost. However, if I add
before the sync in main.sh, then /reader_out/main.log is there, with the right contents. If I don't do that, the file disappears, becoming a "lost chain", which might or might not cause filesystem issues (recoverable) on the SD card. During the entire time this script is running, tinyhttp is stopped (kill -STOP) so that it cannot interfere.
This also does not happen if I put the log under the /tmp filesystem and copy it across after main.sh finishes running.
Surely all relevant file buffers should be flushed upon a umount, but even if not, I call sync multiple times, only to get ignored. Grr.
If I can't figure this out I will reformat the SD card into ext2 rather than vfat, as it seems I've got a working ext2 filesystem driver installed on my reader now... maybe the problems will go away then.
My instinct tells me that the proprietary MS/SD card driver by SONY may well be buggy. Unfortunately, it's closed source, so I can't really confirm that.
Any ideas? This is the last roadblock to my being able to run programs off the SD card in a stable fashion