-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmisc.cpp
59 lines (50 loc) · 1.37 KB
/
misc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstdarg>
#include "lib.h"
#include "shm.h"
#include "utils/timer.h"
namespace madfs {
extern "C" {
int unlink(const char* path) {
dram::ShmMgr::unlink_by_file_path(path);
int rc = posix::unlink(path);
LOG_DEBUG("posix::unlink(%s) = %d", path, rc);
return rc;
}
int rename(const char* oldpath, const char* newpath) {
if (access(newpath, F_OK) == 0) dram::ShmMgr::unlink_by_file_path(newpath);
int rc = posix::rename(oldpath, newpath);
LOG_DEBUG("posix::rename(%s, %s) = %d", oldpath, newpath, rc);
return rc;
}
int truncate([[maybe_unused]] const char* path, [[maybe_unused]] off_t length) {
PANIC("truncate not implemented");
return -1;
}
int ftruncate([[maybe_unused]] int fd, [[maybe_unused]] off_t length) {
PANIC("ftruncate not implemented");
return -1;
}
int flock([[maybe_unused]] int fd, [[maybe_unused]] int operation) {
PANIC("flock not implemented");
return -1;
}
int fcntl(int fd, int cmd, ... /* arg */) {
return 0;
va_list arg;
va_start(arg, cmd);
auto res = posix::fcntl(fd, cmd, arg);
va_end(arg);
LOG_DEBUG("posix::fcntl(%d, %d, ...) = %d", fd, cmd, res);
return res;
}
int fcntl64(int fd, int cmd, ... /* arg */) {
return 0;
va_list arg;
va_start(arg, cmd);
auto res = posix::fcntl(fd, cmd, arg);
va_end(arg);
LOG_DEBUG("posix::fcntl(%d, %d, ...) = %d", fd, cmd, res);
return res;
}
}
} // namespace madfs