• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2021 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <ditto/syscall.h>
16 
17 namespace dittosuite {
18 
GetSyscall()19 Syscall& Syscall::GetSyscall() {
20   static Syscall syscall;
21   return syscall;
22 }
23 
Access(const std::string & path_name,int mode)24 int Syscall::Access(const std::string& path_name, int mode) {
25   return access(path_name.c_str(), mode);
26 }
27 
Close(int fd)28 int Syscall::Close(int fd) {
29   return close(fd);
30 }
31 
CloseDir(DIR * dirp)32 int Syscall::CloseDir(DIR* dirp) {
33   return closedir(dirp);
34 }
35 
FAdvise(int fd,int64_t offset,int64_t len,int advice)36 int Syscall::FAdvise(int fd, int64_t offset, int64_t len, int advice) {
37   return posix_fadvise64(fd, offset, len, advice);
38 }
39 
FAllocate(int fd,int mode,int64_t offset,int64_t len)40 int Syscall::FAllocate(int fd, int mode, int64_t offset, int64_t len) {
41   return fallocate64(fd, mode, offset, len);
42 }
43 
FTruncate(int fd,int64_t length)44 int Syscall::FTruncate(int fd, int64_t length) {
45   return ftruncate64(fd, length);
46 }
47 
FStat(int filedes,struct stat64 * buf)48 int Syscall::FStat(int filedes, struct stat64* buf) {
49   return fstat64(filedes, buf);
50 }
51 
FSync(int fd)52 int Syscall::FSync(int fd) {
53   return fsync(fd);
54 }
55 
Open(const std::string & path_name,int flags,int mode)56 int Syscall::Open(const std::string& path_name, int flags, int mode) {
57   return open(path_name.c_str(), flags, mode);
58 }
59 
OpenDir(const std::string & name)60 DIR* Syscall::OpenDir(const std::string& name) {
61   return opendir(name.c_str());
62 }
63 
Read(int fd,char * buf,int64_t count,int64_t offset)64 int64_t Syscall::Read(int fd, char* buf, int64_t count, int64_t offset) {
65   return pread64(fd, buf, count, offset);
66 }
67 
ReadDir(DIR * dirp)68 struct dirent* Syscall::ReadDir(DIR* dirp) {
69   return readdir(dirp);
70 }
71 
ReadLink(const std::string & path_name,char * buf,int64_t bufsiz)72 int64_t Syscall::ReadLink(const std::string& path_name, char* buf, int64_t bufsiz) {
73   return readlink(path_name.c_str(), buf, bufsiz);
74 }
75 
Sync()76 void Syscall::Sync() {
77   return sync();
78 }
79 
Unlink(const std::string & path_name)80 int Syscall::Unlink(const std::string& path_name) {
81   return unlink(path_name.c_str());
82 }
83 
Write(int fd,char * buf,int64_t count,int64_t offset)84 int64_t Syscall::Write(int fd, char* buf, int64_t count, int64_t offset) {
85   return pwrite64(fd, buf, count, offset);
86 }
87 
88 }  // namespace dittosuite
89