-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add missing filedesc
and fdescenttbl
in FreeBSD
#4327
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
ee9d810
to
49c2dd2
Compare
Cc @asomers for FreeBSD |
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 are a lot of new definitions here. I suggest you check how many of these fields you truly need to use. For those that you don't, you can make the field private and opaque. That eases the maintenance burden on libc, and makes it possible to change the fields later if needed.
// This is normally `struct file`. | ||
pub fde_file: *mut c_void, |
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.
Are you defining it as "c_void" instead of struct file
just so you won't have to add a definition for the latter, because you don't need it? In that case, I suggest you make the field private. That way it will be easier to change the field later.
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.
Yes, gonna do that.
pub fd_freefile: c_int, | ||
pub fd_refcnt: c_int, | ||
pub fd_holdcnt: c_int, | ||
pub fd_sx: sx, |
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.
You should make this field private and opaque. It isn't used by userspace.
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.
I made them private, but wdym by opaque? To get the size and alignment right, we still need to define the inner types, or do you mean something else?
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.
You should be able to get the size and alignment correct with a suitably constructed array of bytes, longs, etc. But if that's too much work then it's ok to define the real structs instead.
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.
I find it preferrable to have definitions matching C as it makes it easier for us to update it if changed but really as you prefer.
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.
For 1.0 we are going to make all opaque / padding fields MaybeUninit
, that could be an option here
feb4c4c
to
6150594
Compare
6150594
to
ca3621f
Compare
I didn't expect the segfault. XD |
FreeBSD13 CI has a spurious segfault. I have no idea why, haven't had a chance to look into it. Retried the job |
CI passed! \o/ |
@tgross35 Is there anything else to be done here? |
ca3621f
to
560c090
Compare
Just realized two things:
|
1b93184
to
e55f459
Compare
Rebased on |
I think this looks fine to me with one note that there should be a comment about why some of these are I'm not sure about the change to Could you add a permalink to the relevant headers in the PR descripton? |
filedesc
and fdescenttbl
in FreeBSD
About the changes to So although the pointer type changes, is it really an issue considering you cannot access the data as is? |
Oh also I added the permalinks in the first comment. |
e0c9011
to
5b5ec23
Compare
Good point, it's probably not a problem in practice then. I'm fine with backporting everything as long as Alan okays it. |
Thanks, that'd allow me to remove a lot of code from |
I'm ok with backporting the kinfo_proc change to the 0.2 branch. |
@asomers was there anything else you wanted here or is this good to merge? |
I would prefer that types like |
I'd prefer to keep the struct declaration. In future version, we can make the macro allow to have private types. |
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.
I think that is fine, should be easier than calculating by hand. We've had some CI problems this week but they should be fixed now so this is all set.
Would you be able to squash?
5b5ec23
to
a23e0e0
Compare
Sure, done. |
[ edited the message to be more specific - Trevor ] (backport <rust-lang#4327>) (cherry picked from commit a23e0e0)
[ edited the message to be more specific - Trevor ] (backport <rust-lang#4327>) (cherry picked from commit a23e0e0)
Types I need for sysinfo to allow to know how many open files a FreeBSD process has.
Item declarations can be found there: