Disable usage of O_TMPFILE for now

This commit is contained in:
Jarred Sumner
2023-12-02 06:54:33 -08:00
parent 67c7769ddb
commit d45f2dae15

View File

@@ -2,13 +2,17 @@ const bun = @import("root").bun;
const std = @import("std");
const Environment = bun.Environment;
const O = std.os.O;
// O_TMPFILE doesn't seem to work very well.
const allow_tmpfile = false;
// To be used with files
// not folders!
pub const Tmpfile = struct {
destination_dir: bun.FileDescriptor = bun.invalid_fd,
tmpfilename: [:0]const u8 = "",
fd: bun.FileDescriptor = bun.invalid_fd,
using_tmpfile: bool = Environment.isLinux,
using_tmpfile: bool = allow_tmpfile,
pub fn create(
destination_dir: bun.FileDescriptor,
@@ -21,7 +25,7 @@ pub const Tmpfile = struct {
};
open: while (true) {
if (comptime Environment.isLinux) {
if (comptime allow_tmpfile) {
switch (bun.sys.openat(destination_dir, ".", O.WRONLY | O.TMPFILE | O.CLOEXEC, perm)) {
.result => |fd| {
tmpfile.fd = fd;
@@ -49,7 +53,7 @@ pub const Tmpfile = struct {
}
pub fn finish(this: *Tmpfile, destname: [:0]const u8) !void {
if (comptime Environment.isLinux) {
if (comptime allow_tmpfile) {
if (this.using_tmpfile) {
var retry = true;
const basename: [:0]const u8 = @ptrCast(std.fs.path.basename(destname));