|
1 | 1 | /**
|
2 |
| -* Written by Ricardo Macedo. |
3 |
| -* Copyright (c) 2021 INESC TEC. |
4 |
| -**/ |
| 2 | + * Written by Ricardo Macedo. |
| 3 | + * Copyright (c) 2021 INESC TEC. |
| 4 | + **/ |
5 | 5 |
|
6 | 6 | #ifndef LDPAIO_POSIX_PASSTHROUGH_HPP
|
7 | 7 | #define LDPAIO_POSIX_PASSTHROUGH_HPP
|
8 | 8 |
|
9 | 9 | #define __USE_GNU
|
10 | 10 | #define _GNU_SOURCE
|
11 | 11 |
|
12 |
| -#include <sys/types.h> |
13 |
| -#include <sys/stat.h> |
| 12 | +#include <dlfcn.h> |
14 | 13 | #include <fcntl.h>
|
| 14 | +#include <sys/stat.h> |
| 15 | +#include <sys/types.h> |
15 | 16 | #include <unistd.h>
|
16 |
| -#include <dlfcn.h> |
17 | 17 |
|
18 | 18 | namespace ldpaio {
|
19 | 19 |
|
20 |
| - typedef ssize_t (*real_read_t)(int, void*, size_t); |
| 20 | +typedef ssize_t (*real_read_t) (int, void*, size_t); |
| 21 | +typedef ssize_t (*real_write_t) (int, const void*, size_t); |
| 22 | +typedef ssize_t (*real_pread_t) (int, void*, size_t, off_t); |
| 23 | +typedef ssize_t (*real_pwrite_t) (int, const void*, size_t, off_t); |
| 24 | +typedef ssize_t (*real_open_t) (const char*, int); |
| 25 | +typedef ssize_t (*real_open_2_t) (const char*, int, mode_t); |
| 26 | + |
| 27 | + |
| 28 | +class PosixPassthrough { |
21 | 29 |
|
22 |
| - ssize_t passthrough_read (int fd, void* buf, ssize_t counter); |
| 30 | +public: |
23 | 31 |
|
24 |
| - ssize_t passthrough_write (int fd, const void* buf, ssize_t counter); |
| 32 | + static ssize_t passthrough_read (int fd, void *buf, ssize_t counter); |
25 | 33 |
|
26 |
| - ssize_t passthrough_pread (int fd, void* buf, ssize_t counter, off_t offset); |
| 34 | + static ssize_t passthrough_write (int fd, const void *buf, ssize_t counter); |
27 | 35 |
|
28 |
| - ssize_t passthrough_pwrite (int fd, const void* buf, ssize_t counter, off_t offset); |
| 36 | + static ssize_t passthrough_pread (int fd, void *buf, ssize_t counter, off_t offset); |
29 | 37 |
|
30 |
| - // open calls |
31 |
| - int passthrough_open (const char* pathname, int flags); |
| 38 | + static ssize_t passthrough_pwrite (int fd, const void *buf, ssize_t counter, off_t offset); |
32 | 39 |
|
33 |
| - int passthrough_open (const char* pathname, int flags, mode_t mode); |
| 40 | +// open calls |
| 41 | + static int passthrough_open (const char* pathname, int flags); |
34 | 42 |
|
35 |
| - int passthrough_creat (const char* pathname, mode_t mode); |
| 43 | + static int passthrough_open (const char* pathname, int flags, mode_t mode); |
36 | 44 |
|
37 |
| - int passthrough_openat (int dirfd, const char* pathname, int flags); |
| 45 | + static int passthrough_creat (const char* pathname, mode_t mode); |
38 | 46 |
|
39 |
| - int passthrough_openat (int dirfd, const char* pathname, int flags, mode_t mode); |
| 47 | + static int passthrough_openat (int dirfd, const char* pathname, int flags); |
40 | 48 |
|
41 |
| -} |
| 49 | + static int passthrough_openat (int dirfd, const char* pathname, int flags, mode_t mode); |
42 | 50 |
|
| 51 | +}; |
| 52 | +} // namespace ldpaio |
43 | 53 |
|
44 |
| -#endif //LDPAIO_POSIX_PASSTHROUGH_HPP |
| 54 | +#endif // LDPAIO_POSIX_PASSTHROUGH_HPP |
0 commit comments