Chromium Code Reviews| Index: util/file/file_io_posix.cc |
| diff --git a/util/file/file_io_posix.cc b/util/file/file_io_posix.cc |
| index 60bc9a8daaac1473a1f49c01f76433c77cc7b7e7..2f4709149b0c27a18e9fc28e828d3c062d54e888 100644 |
| --- a/util/file/file_io_posix.cc |
| +++ b/util/file/file_io_posix.cc |
| @@ -15,6 +15,7 @@ |
| #include "util/file/file_io.h" |
| #include <fcntl.h> |
| +#include <sys/file.h> |
| #include <unistd.h> |
| #include "base/files/file_path.h" |
| @@ -100,6 +101,19 @@ FileHandle LoggingOpenFileForWrite(const base::FilePath& path, |
| return fd; |
| } |
| +bool LoggingLockFile(FileHandle file, FileLocking locking) { |
| + int operation = locking == FileLocking::kShared ? LOCK_SH : LOCK_EX; |
|
Robert Sesek
2015/03/20 22:46:55
nit: lost () around the expr
scottmg
2015/03/20 23:03:19
Will add that in followup.
|
| + int rv = HANDLE_EINTR(flock(file, operation)); |
|
Robert Sesek
2015/03/20 22:46:55
Drop HANDLE_EINTR since you don't have it on 112?
Mark Mentovai
2015/03/20 22:59:21
Robert Sesek wrote:
scottmg
2015/03/20 23:03:19
I thought it was required here looking at http://l
|
| + PLOG_IF(ERROR, rv != 0) << "flock"; |
| + return rv == 0; |
| +} |
| + |
| +bool LoggingUnlockFile(FileHandle file) { |
| + int rv = flock(file, LOCK_UN); |
| + PLOG_IF(ERROR, rv != 0) << "flock"; |
| + return rv == 0; |
| +} |
| + |
| FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) { |
| off_t rv = lseek(file, offset, whence); |
| PLOG_IF(ERROR, rv < 0) << "lseek"; |