-
Notifications
You must be signed in to change notification settings - Fork 7.7k
posix: fd_mgmt: implement dup(), dup2(), fseeko(), and ftello() #74096
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
Conversation
f29decd
to
b541f7f
Compare
cd2853b
to
00c8cf8
Compare
lib/posix/options/fd_mgmt.c
Outdated
/* this is here to make CI pass instead of adding extra commits to this PR */ | ||
__weak int zvfs_fileno(FILE *file) | ||
{ | ||
ARG_UNUSED(file); | ||
return -1; | ||
} | ||
|
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.
highlighting this just in case
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.
Yeah, it is the last commit, and should be dropped prior to being merged
This was added so I didn't need to include the whole posix-device-io pr here too
lib/os/fdtable.c
Outdated
fdtable[ret] = fdtable[fd]; | ||
fdtable[ret].offset = 0; | ||
k_mutex_init(&fdtable[fd].lock); | ||
k_condvar_init(&fdtable[fd].cond); |
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.
shouldn't it be :
k_mutex_init(&fdtable[rt].lock);
k_condvar_init(&fdtable[ret].cond);
otherwise you are changing the original descriptor afaiu.
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.
Oh jeez - yes! Good catch!!
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.
Fixed!
lib/os/fdtable.c
Outdated
(void)z_fd_ref(ret); | ||
} | ||
fdtable[ret] = fdtable[fd]; | ||
fdtable[ret].offset = 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.
shouldn't the new descriptor shares the same offset ?
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 possible that after a dup operation, the new FD might share the same offset. Let me double-check this behaviour on Linux and I'll update if needed.
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.
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.
Fixed!
Temporary DNM until all comments have been addressed. Needs a rebase as well. |
1fd91c5
1fd91c5
to
9772772
Compare
Leaving DNM until posix-device-io PR is merged, and then I'll remove the last commit from this PR. |
Implement the remaining functions from the POSIX_FD_MGMT Option Group that are part of POSIX, and add the CONFIG_REQUIRES_FULL_LIBC dependency to CONFIG_POSIX_FD_MGMT, to pull in the remaining C89 functions. The POSIX_FD_MGMT Option Group is required for PSE52, PSE53, and PSE54 Subprofiling Option Groups. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark the POSIX_FD_MGMT Option Group as supported. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
9772772
to
5e5dd21
Compare
Please add a refresh +1 @ycsin @ceolin @jukkar @vaishnavachath |
Implement the remaining functions from the
POSIX_FD_MGMT
Option Group that are part of POSIX, and add theCONFIG_REQUIRES_FULL_LIBC
dependency toCONFIG_POSIX_FD_MGMT
, to pull in the remaining C89 functions.The
POSIX_FD_MGMT
Option Group is required for PSE52, PSE53, and PSE54 Subprofiles.Note
If this goes in after #73978, the last commit in this PR can be dropped.
Doc Preview
Fixes #74097
Fixes #74098
Fixes #74099
Fixes #74100