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

Unable to open() a readonly file O_RDONLY #125

Open
simonlaszcz opened this issue May 5, 2024 · 6 comments
Open

Unable to open() a readonly file O_RDONLY #125

simonlaszcz opened this issue May 5, 2024 · 6 comments

Comments

@simonlaszcz
Copy link

Given a write protected regular file (e.g. with st_mode = 33024),
the following fails:

fd = open(fname, O_RDONLY, 0)

On return fd is -1 and errno is EACCESS (36)

Tested on TOS 2.06

@rosenrost
Copy link
Contributor

This might be a duplicate of #124.

@simonlaszcz
Copy link
Author

Looking at the code in open.c, I can't see why it would fail. I've called stat() on the same file and the return value is 0.
I'll attempt some further debugging later as I can't believe my eyes.

@th-otto
Copy link
Contributor

th-otto commented May 6, 2024

You mention a file mode of 33024, which is octal 100400. So i assume you are trying this either on an ext2 partition (but then you would be using mint), or using the GEMDOS emulation of Hatari?

@simonlaszcz
Copy link
Author

simonlaszcz commented May 6, 2024

You mention a file mode of 33024, which is octal 100400. So i assume you are trying this either on an ext2 partition (but then you would be using mint), or using the GEMDOS emulation of Hatari?

Just a TOS partition (real hardware)
33024/0100400 is the value of st_mode returned from stat()
It's compiled using the 'struct stat' defined in libcmini/include/ext.h

@th-otto
Copy link
Contributor

th-otto commented May 6, 2024

I'm not sure whether that is the cause of the problem, but as noted in #124, the open() routine is compiled using <sys/stat.h> from mintlib, which is completely different (mintlib uses a structure as expected by the mint Fstat64() call).

@simonlaszcz
Copy link
Author

simonlaszcz commented May 6, 2024

I'm not sure whether that is the cause of the problem, but as noted in #124, the open() routine is compiled using <sys/stat.h> from mintlib, which is completely different (mintlib uses a structure as expected by the mint Fstat64() call).

That sounds very likely now - when I compiled my test stub using sys/stat.h (from mintlib), st_mode was 1

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

3 participants