Skip to content
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

Fix compilation error with target_env=ohos #2301

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ libc_bitflags!(
O_EXLOCK;
/// Same as `O_SYNC`.
#[cfg(any(bsd,
all(target_os = "linux", not(target_env = "musl")),
all(target_os = "linux", not(target_env = "musl"), not(target_env = "ohos")),
target_os = "redox"))]
O_FSYNC;
/// Allow files whose sizes can't be represented in an `off_t` to be opened.
Expand Down
19 changes: 17 additions & 2 deletions src/sys/statfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ type fs_type_t = libc::c_ulong;
type fs_type_t = libc::c_uint;
#[cfg(all(target_os = "linux", target_env = "musl"))]
type fs_type_t = libc::c_ulong;
#[cfg(all(target_os = "linux", target_env = "ohos"))]
type fs_type_t = libc::c_ulong;
#[cfg(all(target_os = "linux", target_env = "uclibc"))]
type fs_type_t = libc::c_int;
#[cfg(all(
target_os = "linux",
not(any(
target_arch = "s390x",
target_env = "musl",
target_env = "ohos",
target_env = "uclibc"
))
))]
Expand All @@ -73,6 +76,7 @@ type fs_type_t = libc::__fsword_t;
target_os = "android",
all(target_os = "linux", target_arch = "s390x"),
all(target_os = "linux", target_env = "musl"),
all(target_os = "linux", target_env = "ohos"),
all(
target_os = "linux",
not(any(target_arch = "s390x", target_env = "musl"))
Expand Down Expand Up @@ -279,7 +283,7 @@ pub const XENFS_SUPER_MAGIC: FsType =
#[cfg(linux_android)]
#[allow(missing_docs)]
pub const NSFS_MAGIC: FsType = FsType(libc::NSFS_MAGIC as fs_type_t);
#[cfg(all(linux_android, not(target_env = "musl")))]
#[cfg(all(linux_android, not(target_env = "musl"), not(target_env = "ohos")))]
#[allow(missing_docs)]
pub const XFS_SUPER_MAGIC: FsType = FsType(libc::XFS_SUPER_MAGIC as fs_type_t);

Expand Down Expand Up @@ -322,7 +326,8 @@ impl Statfs {
/// Optimal transfer block size
#[cfg(any(
target_os = "android",
all(target_os = "linux", target_env = "musl")
all(target_os = "linux", target_env = "musl"),
all(target_os = "linux", target_env = "ohos")
))]
pub fn optimal_transfer_size(&self) -> libc::c_ulong {
self.0.f_bsize
Expand All @@ -334,6 +339,7 @@ impl Statfs {
not(any(
target_arch = "s390x",
target_env = "musl",
target_env = "ohos",
target_env = "uclibc"
))
))]
Expand Down Expand Up @@ -379,6 +385,13 @@ impl Statfs {
self.0.f_bsize
}

/// Size of a block
// f_bsize on linux: https://github.com/torvalds/linux/blob/master/fs/nfs/super.c#L471
#[cfg(all(target_os = "linux", target_env = "ohos"))]
pub fn block_size(&self) -> libc::c_ulong {
self.0.f_bsize
}

/// Size of a block
// f_bsize on linux: https://github.com/torvalds/linux/blob/master/fs/nfs/super.c#L471
#[cfg(all(target_os = "linux", target_env = "uclibc"))]
Expand All @@ -393,6 +406,7 @@ impl Statfs {
not(any(
target_arch = "s390x",
target_env = "musl",
target_env = "ohos",
target_env = "uclibc"
))
))]
Expand Down Expand Up @@ -463,6 +477,7 @@ impl Statfs {
not(any(
target_arch = "s390x",
target_env = "musl",
target_env = "ohos",
target_env = "uclibc"
))
))]
Expand Down
2 changes: 1 addition & 1 deletion src/sys/statvfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ libc_bitflags!(
#[cfg(linux_android)]
ST_NODIRATIME;
/// Update access time relative to modify/change time
#[cfg(any(target_os = "android", all(target_os = "linux", not(target_env = "musl"))))]
#[cfg(any(target_os = "android", all(target_os = "linux", not(target_env = "musl"), not(target_env = "ohos"))))]
ST_RELATIME;
}
);
Expand Down