You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
statfs in rustix 0.38 returned the raw linux-raw-sys statfs64 struct. rustix 1.0 changed this to a rustix StatFs struct that uses a Fsid struct for the f_fsid field. For the libc backend this is a alias to libc::fsid_t, the linux_raw backend defines the Fsid struct by itself.
The problem is that this struct is completely useless. Although this is also (kind of) true at the kernel level:
Nobody knows what f_fsid is supposed to contain (but see below).
, the situation in rustix is even more useless.
While you can not be rely on the meaning and ABI of f_fsid across different operating systems, you can use it within one operating system where it has the same meaning and ABI. However this is not really possible with rustix because there are no methods to access the value or do basic operations on it like compare for equality.
Ideas on getting out of this:
derive PartialEq in linux_raw (for libc backend this is already derived if extra_traits is used) to support comparing of two Fsid instances.
This does not fix the problem that you can not create a Fsid without transmute_copy (which should be same because of repr(C) with Copy).
add a function to expose "the raw value" (for all(?) operating systems "the raw value" can be transmuted to an u64?).
Likely impossible for libc backend without transmute(_copy).
The text was updated successfully, but these errors were encountered:
Do we know why the libc crate makes fsid_t's fields private? If we're contemplating using transmute to override that decision, perhaps we should just go upstream and propose making those fields public.
Do you have a use case that needs the raw value? Or would PartialEq, Eq, and maybe Hash be enough?
Do you have a use case that needs the raw value? Or would PartialEq, Eq, and maybe Hash be enough?
I migrated by code to use statx.{stx_dev_major,stx_dev_minor,stx_mnt_id} instead of statfs.f_fsid. Works too and does not need unsafe transmute_copy.
My use case was checking for equality of f_fsid but from statfs calls in difference processes. So I needed to serialize it to an u64 (actually u64.to_string()) to pass it to the other process. Thinking again one could also use BuildHasherDefault::<DefaultHasher>::new().hash_one(statfs.f_fsid) if Hash is derived. This should give a stable hash.
statfs
in rustix 0.38 returned the raw linux-raw-sysstatfs64
struct. rustix 1.0 changed this to a rustixStatFs
struct that uses aFsid
struct for thef_fsid
field. For thelibc
backend this is a alias tolibc::fsid_t
, thelinux_raw
backend defines theFsid
struct by itself.The problem is that this struct is completely useless. Although this is also (kind of) true at the kernel level:
, the situation in rustix is even more useless.
While you can not be rely on the meaning and ABI of
f_fsid
across different operating systems, you can use it within one operating system where it has the same meaning and ABI. However this is not really possible with rustix because there are no methods to access the value or do basic operations on it like compare for equality.Ideas on getting out of this:
PartialEq
inlinux_raw
(forlibc
backend this is already derived ifextra_traits
is used) to support comparing of twoFsid
instances.Fsid
withouttransmute_copy
(which should be same because ofrepr(C)
withCopy
).u64
?).libc
backend withouttransmute(_copy)
.The text was updated successfully, but these errors were encountered: