-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add unlink(2) implementation for CP/M. #235
base: default
Are you sure you want to change the base?
Conversation
Thanks very much! I've left a couple of comments. |
Hello -- Thanks. |
That is, github review comments, not code comments! They should show up in the github UI here, above this message: #235 |
Embarrassingly, my GitHub UI appears to be broken (though I am using Chrome on Windows atm): there is no github review anywhere for me... |
Hello @ibara, hello @davidgiven, I do not see any GitHub review comments either (?). Meanwhile I have a few queries of my own on this PR:
(My knowledge of the CP/M interface is admittedly quite limited — but I had been looking at Microsoft's GW-BASIC implementation of the Thank you! |
My knowledge of the CP/M interface is also limited. I freely and fully admit to stealing this code from another library file (maybe open?) and modifying it until it did the right thing for my use case. I am sure it needs lots of improvement! |
uint8_t olduser; | ||
|
||
__init_file_descriptors(); | ||
while (fd != NUM_FILE_DESCRIPTORS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while since I looked at this code, but I believe that this chunk is trying to find a free FCBE structure for use when parsing the filename, right? I think it would actually be more efficient to have a static structure used by unlink()
instead --- the size of the structure is probably smaller than the size of the code needed to manage allocating one.
|
||
if (cpm_delete_file(&fcbe->fcb) == 0xff) | ||
{ | ||
fcbe->fcb.f[0] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUIC, this will leak the FCBE if the call succeeds. (I assume you don't want to allocate one permanently, right?)
Very very belatedly someone told me that github doesn't actually send reviews until you do something unobvious. Hopefully I've done that now. Sorry for the delay. |
Hello --
When compiling C code for CP/M, unlink is accepted by the compiler via the unistd.h header but then fails when linking due to an undefined reference for _unlink.
This PR adds an unlink implementation for CP/M.
I am not 100% sure the errno = EIO is the correct errno for when cpm_delete_file returns 0xff, but this is good enough for my needs.
Thanks!