Skip to content

Commit

Permalink
Refactor POSIX function usage in file_cache
Browse files Browse the repository at this point in the history
This commit changes the way POSIX functions are called in the file_cache module. Instead of importing the functions directly from libc, they are now referred to via the libc namespace. This improves code clarity by making it clear where these functions originate from.
  • Loading branch information
popcnt1 committed Jul 6, 2024
1 parent 436533a commit d568645
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/rooch-common/src/fs/file_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use libc::{posix_fadvise, POSIX_FADV_DONTNEED};
use std::fs::File;
use std::io::{Error, Result};
use std::os::unix::io::AsRawFd;
Expand All @@ -23,11 +22,11 @@ impl FileCacheManager {
pub fn drop_cache_range(&self, offset: u64, len: u64) -> Result<()> {
let fd = self.file.as_raw_fd();
let ret = unsafe {
posix_fadvise(
libc::posix_fadvise(
fd,
offset as libc::off_t,
len as libc::off_t,
POSIX_FADV_DONTNEED,
libc::POSIX_FADV_DONTNEED,
)
};

Expand Down

0 comments on commit d568645

Please sign in to comment.