Skip to content

Commit bbe691e

Browse files
committed
"fix the building failure of the extend lseek on dir"
1 parent bb6391b commit bbe691e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

project/libfuse-fs/src/overlayfs/async_io.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::io::ErrorKind;
1313
use std::num::NonZeroU32;
1414
use std::sync::Arc;
1515
use std::sync::atomic::Ordering;
16-
use tracing::error;
1716
use tracing::info;
1817
use tracing::trace;
1918

@@ -937,7 +936,7 @@ impl Filesystem for OverlayFs {
937936
// This enables seekdir/telldir functionality on directories
938937
match whence {
939938
// SEEK_SET: Set the directory position to an absolute value
940-
libc::SEEK_SET => {
939+
x if x == libc::SEEK_SET as u32 => {
941940
// Validate offset bounds to prevent overflow
942941
// Directory offsets should not exceed i64::MAX
943942
if offset > i64::MAX as u64 {
@@ -949,11 +948,11 @@ impl Filesystem for OverlayFs {
949948
layer.lseek(req, real_inode, real_handle, offset, whence).await
950949
}
951950
// SEEK_CUR: Move relative to the current directory position
952-
libc::SEEK_CUR => {
951+
x if x == libc::SEEK_CUR as u32 => {
953952
// Get current position from underlying layer
954953
// This is needed to calculate the new position
955954
let current = match layer
956-
.lseek(req, real_inode, real_handle, 0, libc::SEEK_CUR)
955+
.lseek(req, real_inode, real_handle, 0, libc::SEEK_CUR as u32)
957956
.await
958957
{
959958
Ok(r) => r.offset,
@@ -971,7 +970,7 @@ impl Filesystem for OverlayFs {
971970
// Actually set the underlying offset to the new value so behavior
972971
// matches passthrough which uses libc::lseek64 to set the fd offset.
973972
match layer
974-
.lseek(req, real_inode, real_handle, new_offset, libc::SEEK_SET)
973+
.lseek(req, real_inode, real_handle, new_offset, libc::SEEK_SET as u32)
975974
.await
976975
{
977976
Ok(_) => Ok(ReplyLSeek { offset: new_offset }),

project/libfuse-fs/src/passthrough/async_io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ impl Filesystem for PassthroughFs {
18071807
// This enables seekdir/telldir functionality on directories
18081808
match whence {
18091809
// SEEK_SET: set directory offset to an absolute value
1810-
libc::SEEK_SET => {
1810+
x if x == libc::SEEK_SET as u32 => {
18111811
// Validate offset bounds to prevent overflow
18121812
// Directory offsets should not exceed i64::MAX
18131813
if offset > i64::MAX as u64 {
@@ -1825,7 +1825,7 @@ impl Filesystem for PassthroughFs {
18251825
Ok(ReplyLSeek { offset: res as u64 })
18261826
}
18271827
// SEEK_CUR: move relative to current directory offset
1828-
libc::SEEK_CUR => {
1828+
x if x == libc::SEEK_CUR as u32 => {
18291829
// Get current position using libc::lseek64 with offset 0
18301830
let cur = unsafe { libc::lseek64(file.as_raw_fd(), 0, libc::SEEK_CUR) };
18311831
if cur < 0 {
@@ -1860,9 +1860,9 @@ impl Filesystem for PassthroughFs {
18601860
let (_guard, file) = data.get_file_mut().await;
18611861

18621862
// Safe because this doesn't modify any memory and we check the return value.
1863-
// Use standard libc::lseek for regular files
1863+
// Use 64-bit seek for regular files to match kernel offsets
18641864
let res = unsafe {
1865-
libc::lseek(
1865+
libc::lseek64(
18661866
file.as_raw_fd(),
18671867
offset as libc::off64_t,
18681868
whence as libc::c_int,

0 commit comments

Comments
 (0)