From a896ed3944ade052af5ab68167cf21505b55286d Mon Sep 17 00:00:00 2001 From: Tudor Bosman Date: Tue, 14 May 2013 21:28:50 -0700 Subject: [PATCH] add openNoInt, truncateNoInt, ftruncateNoInt Test Plan: it compiles Reviewed By: soren@fb.com FB internal diff: D825286 --- folly/FileUtil.cpp | 12 ++++++++++++ folly/FileUtil.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/folly/FileUtil.cpp b/folly/FileUtil.cpp index 690280b9..393f5408 100644 --- a/folly/FileUtil.cpp +++ b/folly/FileUtil.cpp @@ -24,6 +24,10 @@ namespace folly { using namespace fileutil_detail; +int openNoInt(const char* name, int flags, mode_t mode) { + return wrapNoInt(open, name, flags, mode); +} + int closeNoInt(int fd) { int r = close(fd); // Ignore EINTR. On Linux, close() may only return EINTR after the file @@ -49,6 +53,14 @@ int fdatasyncNoInt(int fd) { return wrapNoInt(fdatasync, fd); } +int ftruncateNoInt(int fd, off_t len) { + return wrapNoInt(ftruncate, fd, len); +} + +int truncateNoInt(const char* path, off_t len) { + return wrapNoInt(truncate, path, len); +} + ssize_t readNoInt(int fd, void* buf, size_t count) { return wrapNoInt(read, fd, buf, count); } diff --git a/folly/FileUtil.h b/folly/FileUtil.h index 67e19213..81974871 100644 --- a/folly/FileUtil.h +++ b/folly/FileUtil.h @@ -19,7 +19,10 @@ #include "folly/Portability.h" +#include +#include #include +#include #include namespace folly { @@ -30,9 +33,12 @@ namespace folly { * until all data is written. Note that *Full wrappers weaken the thread * semantics of underlying system calls. */ +int openNoInt(const char* name, int flags, mode_t mode=0644); int closeNoInt(int fd); int fsyncNoInt(int fd); int fdatasyncNoInt(int fd); +int ftruncateNoInt(int fd, off_t len); +int truncateNoInt(const char* path, off_t len); ssize_t readNoInt(int fd, void* buf, size_t n); ssize_t preadNoInt(int fd, void* buf, size_t n, off_t offset); -- 2.34.1