ihaveamac / ninfs

FUSE filesystem Python scripts for Nintendo console files
MIT License
436 stars 18 forks source link

[Linux / Docker] [Switch eMMC Backup] Partitions appear after mounting, but cannot access img files #71

Closed PabloZaiden closed 3 years ago

PabloZaiden commented 3 years ago

When trying to mount a Switch eMMC backup, the img files appear at the mount point. But when trying to access those files, it says that the files don't exist. I'm currently trying to read a decrypted PRODINFO partition:

root@b38e464e73e1:/emummc# mount_nandhac --keys prod.keys -S rawnand.bin.00 /emumount
[HAC] Found and using openssl lib.
root@b38e464e73e1:/emummc# ls /emumount/
BCPKG2-1-Normal-Main.img  BCPKG2-3-SafeMode-Main.img  BCPKG2-5-Repair-Main.img  PRODINFO.img   SAFE.img    USER.img
BCPKG2-2-Normal-Sub.img   BCPKG2-4-SafeMode-Sub.img   BCPKG2-6-Repair-Sub.img   PRODINFOF.img  SYSTEM.img
root@b38e464e73e1:/emummc# cat /emumount/PRODINFO.img
cat: /emumount/PRODINFO.img: No such file or directory
root@b38e464e73e1:/emummc#

This is being executed in a docker container (privileged mode), based on the ubuntu:focal image

ihaveamac commented 3 years ago

Something weird must be going on when it ninfs forks itself into the background since I noticed using -f for the foreground, then & on the bash prompt to fork to the background then, doesn't cause this issue.

root@f6ef04225d36:/emummc# mount_nandhac --keys prod.keys -S rawnand.bin.00 /emumount
[HAC] Found and using openssl lib.
root@f6ef04225d36:/emummc# file /emumount/SYSTEM.img
/emumount/SYSTEM.img: ERROR: cannot read `/emumount/SYSTEM.img' (No such file or directory)
root@f6ef04225d36:/emummc# fusermount -u /emumount
root@f6ef04225d36:/emummc# mount_nandhac --keys prod.keys -S rawnand.bin.00 /emumount -f &
[1] 3935
root@f6ef04225d36:/emummc# [HAC] Found and using openssl lib.

root@f6ef04225d36:/emummc# file /emumount/SYSTEM.img
/emumount/SYSTEM.img: DOS/MBR boot sector, code offset 0xe9+2, sectors/cluster 32, Media descriptor 0xf8, sectors/track 63, heads 16, sectors 5242880 (volumes > 32 MB), FAT (32 bit), sectors/FAT 1280, serial number 0x0, unlabeled
PabloZaiden commented 3 years ago

Thanks. Doing that now as a workaround, but will leave the issue open for visibility, until it’s fixed.

ihaveamac commented 3 years ago

Reminder (for me or anyone else) to test in docker (linux host):

Also reminder for me to change all the scripts to not force foreground when using fusepy logging (--do filename). I don't remember why it's like this.

ihaveamac commented 3 years ago

Now it works for some reason? Ubuntu 20.04 host, same one used to reproduce the error, but this time I used a Dockerfile.

Dockerfile:

FROM ubuntu:focal
RUN apt-get update && apt-get install -y python3 python3-pip fuse
RUN python3 -m pip install ninfs==2.0a3

Built with: sudo docker build -t ninfstest .

Ran with: sudo docker run -it --rm -v $PWD:/data --privileged ninfstest

Container output:

root@dac7ddc5e5fc:/# mount_nandhac --keys data/prod.keys -S data/2019-10-22/rawnand.bin.00 /mnt
[HAC] Found and using openssl lib.
root@dac7ddc5e5fc:/# ls /mnt
BCPKG2-1-Normal-Main.img    BCPKG2-5-Repair-Main.img  SAFE.img
BCPKG2-2-Normal-Sub.img     BCPKG2-6-Repair-Sub.img   SYSTEM.img
BCPKG2-3-SafeMode-Main.img  PRODINFO.img              USER.img
BCPKG2-4-SafeMode-Sub.img   PRODINFOF.img
root@dac7ddc5e5fc:/# file /mnt/SYSTEM.img 
/mnt/SYSTEM.img: DOS/MBR boot sector, code offset 0xe9+2, sectors/cluster 32, Media descriptor 0xf8, sectors/track 63, heads 16, sectors 5242880 (volumes > 32 MB), FAT (32 bit), sectors/FAT 1280, serial number 0x0, unlabeled
ihaveamac commented 9 months ago

Super late response but this turned out to be current directory problems. When forked into the background the current directory changed, so non-absolute paths had a chance of not working. So I changed it to convert paths to absolute.

https://github.com/ihaveamac/ninfs/commit/d5a215ef75df6797e2abd6daf1b5bb2026756573