-
Notifications
You must be signed in to change notification settings - Fork 19
Store inode in Entry, add accessor #39
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
base: master
Are you sure you want to change the base?
Conversation
d50be64
to
03117b6
Compare
The 2nd commit may be not worth the costs of one additional file-descriptor. It started just Nevertheless the functionality to 'remeber' the orginal directory is missing this can be done store it on request (at construction time). The cost here is the file descriptor, not the memory. Eventually when the necessary rust features stabilize (or there is some way to implement it) I |
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 i think storing a duplicate dir is too costly.
I think this could be done in application wrapper. And when using that, I would probably put Dir
into Arc<Dir>
instead and use that instead of duplicating file descriptor. Arc<Dir>
is tremendously useful and I even considered to having it by default in this crate, but decided to be a bit more low-level and less opinionated. This change fits the same category.
src/list.rs
Outdated
@@ -37,6 +38,10 @@ impl Entry { | |||
pub fn simple_type(&self) -> Option<SimpleType> { | |||
self.file_type | |||
} | |||
/// Returns the inode number of this entry | |||
pub fn inode(&self) -> u64 { |
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.
Should be libc::ino_t
I think.
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 deliberately chosen the types from statx() (see #38) these are overall better suited than
the legacy types (which is a pain to deal with when differing in signedness). Arguably it
would been nice if statx() would define sx_ino_t or similar, but they are only aliases so
there isn't overly much value in doing so. In anticipation of statx() it would be a bit
awkward to return types as in struct stat which are sometimes inferior and kindof legacy.
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.
Note statx
is a linux-specific call. This library also works on macos and different bsd variants.
Other than that, using libc types is convenient if you want to use other libc functions on that types. Because otherwise it will work on some platform but have compilation errors on others.
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 am aware that statx() is linux only. but the types it uses are well chosen to be a superset of what 'struct stat' provides. My plan was to provide 'accessor' functions that use these statx() types even when statx() isn't available.
I have some hopes that eventually other vendors pick this up and it becomes standardized. Anyway it could be changed to 'struct stat' compatibility. (also in #38)
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.
Pushed a new version which uses ino_t, removed the origin experiment.
The later will need more work and a complete different approach.
I am after low level (as long it doesn't compromise the 'rust' feel) as well. I had Arc in mind but turned that down. |
03117b6
to
6855598
Compare
the d_ino field is mandatory in POSIX and clients (me) really need it when passing data around. Keeping it in the Entry saves an extra stat()/metadata query.
6855598
to
abef3ec
Compare
the d_ino field is mandatory in POSIX and clients (me) really need it when passing data
around. Keeping it in the Entry saves an extra stat()/metadata query.