Skip to content

Commit d2788f3

Browse files
committed
sdk/rust: Fix hostfs create_file() failing with EEXIST on existing files
Replace O_EXCL with O_TRUNC in create_file for both Linux and Darwin hostfs backends. The FUSE create op is called by the kernel for open(O_CREAT) on existing files (e.g. cargo overwriting .d dependency files), so create_file needs to truncate rather than fail. Higher-level callers already guard against unwanted overwrites with their own existence checks.
1 parent fef7b6a commit d2788f3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

sdk/rust/src/filesystem/hostfs_darwin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl FileSystem for HostFS {
673673
let file_fd = unsafe {
674674
libc::open(
675675
c_path.as_ptr(),
676-
libc::O_CREAT | libc::O_EXCL | libc::O_RDWR,
676+
libc::O_CREAT | libc::O_TRUNC | libc::O_RDWR,
677677
mode as libc::mode_t as libc::c_uint,
678678
)
679679
};

sdk/rust/src/filesystem/hostfs_linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ impl FileSystem for HostFS {
711711
libc::openat(
712712
parent_fd,
713713
c_name.as_ptr(),
714-
libc::O_CREAT | libc::O_EXCL | libc::O_RDWR,
714+
libc::O_CREAT | libc::O_TRUNC | libc::O_RDWR,
715715
mode as libc::mode_t,
716716
)
717717
};

0 commit comments

Comments
 (0)