-
Notifications
You must be signed in to change notification settings - Fork 0
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
Research/write BSD implementation of ishidden #3
Comments
It appears that BSD also has the |
I spent a long time looking through the source of OpenZFS (see above). After many possible avenues, I wanted to actually some real code, however suddenly I couldn't even do it in C; function main(strs::String...)
io = IOBuffer()
for f in readdir("/lib", join = true)
isfile(f) || continue
try
run(pipeline(`nm --dynamic $f`, stdout = io, stderr = devnull))
cmd_out = lowercase(String(take!(io)))
any(occursin(s, cmd_out) for s in strs) && println(f)
finally
continue
end
end
end I figured out that there are also many object files in the Making good progress now that we
|
I should also note that this depends on ZFS, rather than FreeBSD |
At least as I understand it, hidden files on BSDs are the same as on Linux (and likely macOS). While FreeBSD can use ZFS, it doesn't have to; installers let you pick between UFS and ZFS with the former actually being the default for prebuilt VM images. Are you looking to implement |
@ararslan yeah, I realised that when I started looking into this, that the Luckily I don't have to locate any of the Your idea of finding all the mount points might be good though. Do you think that would be easier than what I explained above? The other thing I have to consider is: are all subfiles/directories of this Thank you for the useful information, that helps me to understand :) |
Some things to note regarding
Also, if you're doing this on FreeBSD, I recommend looking at the OpenZFS included in FreeBSD's monolithic source tree in case there are any differences compared to upstream. |
Thanks Alex, good to know about
Do you know how exactly to call structs (such as
Because I'm clearly doing it wrong! julia> ccall((:zfs_attr_table, "libzpool"), Cvoid, ())
signal (11): Segmentation fault
in expression starting at REPL[1]:1
zfs_attr_table at /usr/lib/libzpool.so (unknown line)
# ... Ultimately I need to find a way to create a
Indeed, I'm developing on FreeBSD currently. I've been looking lots at the OpenZFS source on GitHub, but I haven't looked at in within the machine itself. I'll see if I can find it. Also, do you know anything about how I might programmatically check if a file is stored on a ZFS partition? As this is no longer going to be a job for |
What do you mean by "call" in this case? If you define a Julia type with a layout compatible with the C struct, you can return objects with that type from typedef struct _t {
int a;
int b;
} t;
void populate_t(t* thing) { ... } then you can do struct T
a::Cint
b::Cint
end
t = Ref{T}()
ccall((:populate_t, libwhatever), Cvoid, (Ref{T},), t) (completely untested example but that's the gist). How exactly you go about it depends on the functions available from the library you're calling into.
You'd have to reference whatever the macro expands to in your call on the Julia side since C macros exist only during the preprocessor phase; a compiled library has no knowledge of whether some part of its code was generated by a macro.
You need julia> cglobal((:zfs_attr_table, "/lib/libzpool.so.2"))
Ptr{Nothing} @0x0000000895cdaf20
Unfortunately I don't, sorry 😕 |
BSD-related OS's (i.e., FreeBSD and macOS) can have the st_flags check applied to them (as I implemented this for macOS), so this function was moved out into a separate branch. ZFS function stubs were also created (with errors in case people try to use them at this stage in development) so that I can (hopefully soon) start implementing them. Addresses #1, #3, #12, #13
Thanks for your help with making structs from Julia. I hadn't figured that out yet, so I was just using Vectors, and indexing directly (instead of named fields). The problem with
Ah, that makes sense, I figured that would be the case.
Oh neat, I didn't know about this function! Potentially stupid question, but how do you actually use the result? It's a pointer to some object in memory, but I'm not sure how exactly to make that into an array or whatever it should be.
No worries, I'll figure something out. You've been ever so helpful, thank you Alex 🙂 |
You wouldn't find
That's not a stupid question at all. The crucial piece here is "whatever it should be," as what it should be will determine how you go about retrieving that. |
I read somewhere that BSD, like macOS, is another UNIX system that needs a unique
ishidden
method. Ensure this is well-researched and implemented if needed.The text was updated successfully, but these errors were encountered: