Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"open: No such file or directory" on a certain SCP image #21

Open
natevw opened this issue Feb 4, 2020 · 3 comments
Open

"open: No such file or directory" on a certain SCP image #21

natevw opened this issue Feb 4, 2020 · 3 comments

Comments

@natevw
Copy link

natevw commented Feb 4, 2020

I have a directory full of SuperCard Pro image files (from an actual SCP device via its app). They all process just fine except for one random one which causes a cryptic error in SAMdisk 3.8.8 on macOS 10.14.6:

$ ./samdisk info test.scp
open: No such file or directory
$ file test.scp
test.scp: data
$ ./samdisk info test-404.scp
Error: invalid file: test-404.scp

I've renamed the file, moved it, checked permissions, etc. and it clearly seems to have something to do with the contents of the file rather than the file itself. Any idea what might be wrong?

@natevw
Copy link
Author

natevw commented Feb 4, 2020

So I ran this through lldb and discovered that the code is on some path that involves DADiskCreateFromBSDName which was unexpected since this isn't a disk image. That clue led me to BlockDevice code which recognizes a match when BlockDevice::IsFileHDD is true.

Turns out that this file has a size which happens to be an exact multiple of SECTOR_SIZE (512) and so rather than being treated as a SuperCardPro input it got handed to the BlockDevice class instead.

I was able to workaround this by appending an extra byte at the end of the file:

printf '\x00' >> test.scp

Not sure if this would still be an issue in the current version if it tries the SuperCardPro before the other driver, but it certainly seems to give the block device driver first dibs in the last macOS build that's available.

@simonowen
Copy link
Owner

Thanks for reporting this, and your analysis of the problem.

It all stems from SAMdisk's attempt to work out the type of arguments being passed on the command-line. Once it's decided (perhaps incorrectly) it goes all in on that assumed type, with no way to steer it back in the right direction -- that can lead to some confusing error messages. I think false-positives in IsFileHDD has become more of an issue over time because MAX_IMAGE_SIZE been increased from perhaps only 4MiB in early versions to the current 256MiB value, needed to accept multi-revolution flux images.

As a short-term fix I'd recommend having IsFileHDD always return false. I'll make a start on moving the other commands away from the argument detection where possible.

@natevw
Copy link
Author

natevw commented Feb 17, 2020

Ah, didn't realize the code published here would still compile on macOS.

A nice feature long-term would be letting us specify the input/output types explicitly instead of from the file and/or its name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants