summaryrefslogtreecommitdiff
path: root/netfs/fuse/fuseMisc.cpp
blob: 568cf521688c333afeba263d0c2e5237b1e3bb3d (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "pch.hpp"
#include "fuse.h"
#include <string.h>
#include <typeConvert.h>

int
NetFS::FuseApp::access(const char * p, int a)
{
	return -volume->access(reqEnv(), p, a);
}

int
NetFS::FuseApp::getattr(const char * p, struct stat * s)
{
	try {
		*s << AttrSource { volume->getattr(reqEnv(), p), boost::bind(&UserEntCache::getID, &uentries, _1), boost::bind(&GroupEntCache::getID, &gentries, _1) };
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::chmod(const char * p, mode_t m)
{
	try {
		volume->chmod(reqEnv(), p, m);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::chown(const char * p, uid_t u, gid_t g)
{
	try {
		volume->chown(reqEnv(), p, u, g);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::link(const char * p1, const char * p2)
{
	try {
		volume->link(reqEnv(), p1, p2);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::symlink(const char * p1, const char * p2)
{
	try {
		volume->symlink(reqEnv(), p1, p2);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::readlink(const char * p, char * p2, size_t s)
{
	try {
		std::string l = volume->readlink(reqEnv(), p);
		l.copy(p2, s);
		p2[l.length()] = '\0';
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::rename(const char * p1, const char * p2)
{
	try {
		volume->rename(reqEnv(), p1, p2);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}

int
NetFS::FuseApp::utimens(const char * path, const struct timespec times[2])
{
	try {
		volume->utimens(reqEnv(), path,
				times[0].tv_sec, times[0].tv_nsec, times[1].tv_sec, times[1].tv_nsec);
		return 0;
	}
	catch (NetFS::SystemError & e) {
		return -e.syserrno;
	}
}