Draft: Implement ishidden for ZFS filesystems#20
Open
jakewilliami wants to merge 17 commits intomasterfrom
Open
Draft: Implement ishidden for ZFS filesystems#20jakewilliami wants to merge 17 commits intomasterfrom
jakewilliami wants to merge 17 commits intomasterfrom
Conversation
In Julia 1.6, nice libuv statfs bindings were added to Julia, which allows system-independent statfs calls. In Julia 1.8, this was made even nicer by tucking all of that logic into a struct, behind diskstat. While I would like to use this, it would mean not supporting versions < 1.6 for this functionality. I will have to think on it/ask some friends for their opinions. I also did some research/testing into ZFS type values for once we have the f_type field from statfs. Finally, I have (and will continue to) do testing into system-dependent offsets of the f_type field from statfs, in case we can indeed write some janky solution that will work < 1.6.
Added C programme in comment for offset research. macOS: $ gcc -o statfs statfs.c && ./statfs offsetof(struct statfs, f_type): 0x3c st.f_type: 0x1a BSD: $ gcc11 statfs.c -o statfs && ./statfs offsetof(struct statfs, f_type): 0x4 st.f_type: 0xde
Owner
Author
|
To relay some investigation from c95cb4f: However, this is not always consistent with Julia: |
Owner
Author
|
It appears that at offset Hence, perhaps on macOS I should check both offsets. |
I also finished cleaning up the macOS and BSD versions of iszfs. Interestingly, macOS appears to have both f_type and f_fssubtype fields set from statfs (despite the latter not actually being documented. I am still deciding whether or not our < 1.6 version is a good idea.
Owner
Author
|
For future reference, this is how I determine the offsets of flags: #include <stdio.h>
#include <stddef.h>
#include <sys/param.h>
#include <sys/mount.h>
int main() {
struct statfs st;
printf("offsetof(struct statfs, f_type): 0x%lx\n", offsetof(struct statfs, f_type));
statfs("/", &st);
printf("st.f_type: 0x%llx\n", (uint64_t) st.f_type);
return 0;
} |
Owner
Author
|
The equivalent of #20 (comment) for Linux: #include <stdio.h>
#include <stddef.h>
#include <sys/vfs> /* or <sys/statfs.h> */
int main() {
printf("sizeof(struct statfs): %ld\n", sizeof(struct statfs));
printf("offsetof(struct statfs, f_type): 0x%lx\n", offsetof(struct statfs, f_type));
struct statfs st;
statfs("/", &st);
printf("st.f_type: 0x%lx\n", st.f_type);
return 0;
}This produced: Which appears to be consistent within Julia: julia> statfs("/").ftype
0x000000000000ef53
julia> _iszfs("/")[0x01]
0x0000ef53 |
The statfs buffer I implemented previously had elements that were UInt8s, but after implementing Linux's _iszfs function, I realised that some statfs calls needed to store larger-sized integers. As such, we can now dynamically change the element type of the buffer and this will dynamically change the size of the array, and the appropriate offset (cld because Julia is indexed by one)
These values did not need to be defined for each OS branch if Julia version < 1.6
5a75cb6 to
c82f365
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ZFS has some special considerations for hidden files, namely the mount points of ZFS,[1], [2] or a ZFS-classified hidden file.[3], [4]
Addresses #3, #12, #13.
Tasks:
iszfsfunction_ishidden_zfs.zfs)z_pflagsfromznode,[5]xat_hiddenfromxvattr(which usesz_pflags),[6], [7], [8] or by obtaining theznodestruct from avnode[9], [10] and then parsingz_pflags.Unfortunately, I am very limited by what functions I have exported within the shared object files. Trying to keep it in pure Julia, but we will see. I've already spent far too long researching this, so I've made the decision that this feature will be implemented after this package is registered/released, in the interest of getting the package out there for use (as this feature is probably pretty niche).