/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#include "folly/FileUtil.h"
+#include <folly/FileUtil.h>
#include <cerrno>
#ifdef __APPLE__
#include <fcntl.h>
#endif
+#include <sys/file.h>
+#include <sys/socket.h>
-#include "folly/detail/FileUtilDetail.h"
+#include <folly/detail/FileUtilDetail.h>
namespace folly {
// Interestingly enough, the Single Unix Specification says that the state
// of the file descriptor is unspecified if close returns EINTR. In that
// case, the safe thing to do is also not to retry close() -- leaking a file
- // descriptor is probably better than closing the wrong file.
+ // descriptor is definitely better than closing the wrong file.
if (r == -1 && errno == EINTR) {
r = 0;
}
return wrapNoInt(fsync, fd);
}
+int dupNoInt(int fd) {
+ return wrapNoInt(dup, fd);
+}
+
+int dup2NoInt(int oldfd, int newfd) {
+ return wrapNoInt(dup2, oldfd, newfd);
+}
+
int fdatasyncNoInt(int fd) {
#if defined(__APPLE__)
return wrapNoInt(fcntl, fd, F_FULLFSYNC);
return wrapNoInt(truncate, path, len);
}
+int flockNoInt(int fd, int operation) {
+ return wrapNoInt(flock, fd, operation);
+}
+
+int shutdownNoInt(int fd, int how) {
+ return wrapNoInt(shutdown, fd, how);
+}
+
ssize_t readNoInt(int fd, void* buf, size_t count) {
return wrapNoInt(read, fd, buf, count);
}
return wrapvFull(readv, fd, iov, count);
}
-#ifdef FOLLY_HAVE_PREADV
+#if FOLLY_HAVE_PREADV
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(preadv, fd, iov, count, offset);
}
return wrapvFull(writev, fd, iov, count);
}
-#ifdef FOLLY_HAVE_PWRITEV
+#if FOLLY_HAVE_PWRITEV
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pwritev, fd, iov, count, offset);
}