add openNoInt, truncateNoInt, ftruncateNoInt
authorTudor Bosman <tudorb@fb.com>
Wed, 15 May 2013 04:28:50 +0000 (21:28 -0700)
committerOwen Yamauchi <oyamauchi@fb.com>
Mon, 3 Jun 2013 19:20:59 +0000 (12:20 -0700)
Test Plan: it compiles

Reviewed By: soren@fb.com

FB internal diff: D825286

folly/FileUtil.cpp
folly/FileUtil.h

index 690280b93314706b6cb03d640b49f93f60aaf7cd..393f54081907680578d44f517549a5267e4d766d 100644 (file)
@@ -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);
 }
index 67e19213341488886e0635d400f30ad0897a9471..81974871fc8866493958782b98af54bdfc5ebad2 100644 (file)
 
 #include "folly/Portability.h"
 
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <sys/uio.h>
+#include <fcntl.h>
 #include <unistd.h>
 
 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);