summaryrefslogtreecommitdiff
path: root/netfs/fuseMisc.cpp
blob: 274691685071eee2de9cfdb654bf205c8b4063d6 (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
#include "fuse.h"
#include "msgtypes.h"
#include <string.h>

int
NetFS::access(const char * p, int a)
{
	TypedPayloadReq<AccessRequest>::Ptr msg = new TypedPayloadReq<AccessRequest>(fuse_get_context());
	msg->data.access = a;
	msg->data.path = p;
	return -msg->exchange(this)->data.value;
}
int
NetFS::getattr(const char * p, struct stat * s)
{
	TypedPayloadReq<GetAttrRequest>::Ptr msg = new TypedPayloadReq<GetAttrRequest>(fuse_get_context());
	msg->data.path = p;
	TypedPayload<GetAttrReply>::Ptr rep = msg->exchange(this);
	*s = rep->data.val;
	return -rep->data.res;
}
int
NetFS::fgetattr(const char *, struct stat * s, fuse_file_info * fi)
{
	TypedPayloadReq<FgetAttrRequest>::Ptr msg = new TypedPayloadReq<FgetAttrRequest>(fuse_get_context());
	msg->data.handle = fi->fh;
	TypedPayload<GetAttrReply>::Ptr rep = msg->exchange(this);
	*s = rep->data.val;
	return -rep->data.res;
}
int
NetFS::chmod(const char * p, mode_t m)
{
	TypedPayloadReq<ChmodRequest>::Ptr msg = new TypedPayloadReq<ChmodRequest>(fuse_get_context());
	msg->data.path = p;
	msg->data.mode = m;
	return msg->exchange(this)->data.value;
}
int
NetFS::chown(const char * p, uid_t u, gid_t g)
{
	TypedPayloadReq<ChownRequest>::Ptr msg = new TypedPayloadReq<ChownRequest>(fuse_get_context());
	msg->data.path = p;
	msg->data.user = u;
	msg->data.group = g;
	return msg->exchange(this)->data.value;
}
int
NetFS::link(const char * p1, const char * p2)
{
	TypedPayloadReq<LinkRequest>::Ptr msg = new TypedPayloadReq<LinkRequest>(fuse_get_context());
	msg->data.path1 = p1;
	msg->data.path2 = p2;
	return msg->exchange(this)->data.value;
}
int
NetFS::symlink(const char * p1, const char * p2)
{
	TypedPayloadReq<SymlinkRequest>::Ptr msg = new TypedPayloadReq<SymlinkRequest>(fuse_get_context());
	msg->data.path1 = p1;
	msg->data.path2 = p2;
	return msg->exchange(this)->data.value;
}
int
NetFS::readlink(const char * p, char * p2, size_t s)
{
	TypedPayloadReq<ReadlinkRequest>::Ptr msg = new TypedPayloadReq<ReadlinkRequest>(fuse_get_context());
	msg->data.path = p;
	TypedPayload<ReadlinkReply>::Ptr rep = msg->exchange(this);
	strncpy(p2, rep->data.path.c_str(), std::min(rep->data.path.length(), s));
	return -rep->data.error;
}
int
NetFS::rename(const char * p1, const char * p2)
{
	TypedPayloadReq<RenameRequest>::Ptr msg = new TypedPayloadReq<RenameRequest>(fuse_get_context());
	msg->data.path1 = p1;
	msg->data.path2 = p2;
	return msg->exchange(this)->data.value;
}
int
NetFS::unlink(const char * p)
{
	TypedPayloadReq<UnlinkRequest>::Ptr msg = new TypedPayloadReq<UnlinkRequest>(fuse_get_context());
	msg->data.path = p;
	return msg->exchange(this)->data.value;
}