summaryrefslogtreecommitdiff
path: root/netfs/fuseMisc.cpp
blob: 4a855b9ff9468e29f74e7a7c3e9bd88222b950a6 (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
111
112
113
114
115
116
117
118
119
120
121
#include "fuse.h"
#include <string.h>

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

int
NetFS::getattr(const char * p, struct stat * s)
{
	try {
		NetFSComms::Attr a = filesystem->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 = entries.getUID(a.uid);
		s->st_gid = entries.getGID(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 {
		filesystem->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 {
		filesystem->chown(reqEnv(), p, u, g);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

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

int
NetFS::symlink(const char * p1, const char * p2)
{
	try {
		filesystem->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 = filesystem->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 {
		filesystem->rename(reqEnv(), p1, p2);
		return 0;
	}
	catch (NetFSComms::SystemError & e) {
		return -e.syserrno;
	}
}

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