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

int
NetFS::access(const char * p, int a)
{
	return -misc->access(reqEnv(), p, a);
}
int
NetFS::getattr(const char * p, struct stat * s)
{
	try {
		NetFSComms::Attr a = misc->getattr(reqEnv(), p);
		s->st_dev = a.dev;
		s->st_ino = a.inode;
		s->st_mode = a.mode;
		s->st_nlink = a.links;
		s->st_uid = a.uid;
		s->st_gid = a.gid;
		s->st_rdev = a.rdev;
		s->st_size = a.size;
		s->st_blksize = a.blockSize;
		s->st_blocks = a.blocks;
		s->st_atime = a.atime;
		s->st_mtime = a.mtime;
		s->st_ctime = a.ctime;
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

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

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

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

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

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

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