Commit 9038528187

Motiejus Jakštys <motiejus@jakstys.lt>
2022-08-19 08:42:42
copy_file_range: fix zigification of TXTBSY
From `copy_file_range(2)` errors: ETXTBSY Either fd_in or fd_out refers to an active swap file. Same error will be used in the upcoming `ioctl_ficlonerange(2)`: ETXTBSY One of the files is a swap file. Swap files cannot share storage.
1 parent 3fa5415
Changed files (2)
lib
std
src
lib/std/os.zig
@@ -6251,7 +6251,7 @@ pub const CopyFileRangeError = error{
     NoSpaceLeft,
     Unseekable,
     PermissionDenied,
-    FileBusy,
+    SwapFile,
 } || PReadError || PWriteError || UnexpectedError;
 
 var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true);
@@ -6305,7 +6305,7 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len
             .NOSPC => return error.NoSpaceLeft,
             .OVERFLOW => return error.Unseekable,
             .PERM => return error.PermissionDenied,
-            .TXTBSY => return error.FileBusy,
+            .TXTBSY => return error.SwapFile,
             // these may not be regular files, try fallback
             .INVAL => {},
             // support for cross-filesystem copy added in Linux 5.3, use fallback
src/link.zig
@@ -426,7 +426,7 @@ pub const File = struct {
         NoSpaceLeft,
         Unseekable,
         PermissionDenied,
-        FileBusy,
+        SwapFile,
         SystemResources,
         OperationAborted,
         BrokenPipe,