2
2
FUSE: Filesystem in Userspace
3
Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
3
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5
5
This program can be distributed under the terms of the GNU LGPL.
6
6
See the file COPYING.LIB
75
75
attr->atime = stbuf->st_atime;
76
76
attr->mtime = stbuf->st_mtime;
77
77
attr->ctime = stbuf->st_ctime;
78
#ifdef FUSE_STAT_HAS_NANOSEC
79
attr->atimensec = ST_ATIM(stbuf).tv_nsec;
80
attr->mtimensec = ST_MTIM(stbuf).tv_nsec;
81
attr->ctimensec = ST_CTIM(stbuf).tv_nsec;
78
attr->atimensec = ST_ATIM_NSEC(stbuf);
79
attr->mtimensec = ST_MTIM_NSEC(stbuf);
80
attr->ctimensec = ST_CTIM_NSEC(stbuf);
85
83
static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
90
88
stbuf->st_size = attr->size;
91
89
stbuf->st_atime = attr->atime;
92
90
stbuf->st_mtime = attr->mtime;
93
#ifdef FUSE_STAT_HAS_NANOSEC
94
ST_ATIM(stbuf).tv_nsec = attr->atimensec;
95
ST_MTIM(stbuf).tv_nsec = attr->mtimensec;
91
ST_ATIM_NSEC_SET(stbuf, attr->atimensec);
92
ST_MTIM_NSEC_SET(stbuf, attr->mtimensec);
99
95
static size_t iov_length(const struct iovec *iov, size_t count)
153
149
destroy_req(req);
156
static int send_reply(fuse_req_t req, int error, const void *arg,
152
static int send_reply_iov(fuse_req_t req, int error, struct iovec *iov,
159
155
struct fuse_out_header out;
164
158
if (error <= -1000 || error > 0) {
169
163
out.unique = req->unique;
170
164
out.error = error;
172
165
iov[0].iov_base = &out;
173
166
iov[0].iov_len = sizeof(struct fuse_out_header);
174
if (argsize && !error) {
167
out.len = iov_length(iov, count);
170
fprintf(stderr, " unique: %llu, error: %i (%s), outsize: %i\n",
171
(unsigned long long) out.unique, out.error,
172
strerror(-out.error), out.len);
173
res = fuse_chan_send(req->ch, iov, count);
179
static int send_reply(fuse_req_t req, int error, const void *arg,
176
185
iov[1].iov_base = (void *) arg;
177
186
iov[1].iov_len = argsize;
179
out.len = iov_length(iov, count);
182
printf(" unique: %llu, error: %i (%s), outsize: %i\n",
183
out.unique, out.error, strerror(-out.error), out.len);
186
res = fuse_chan_send(req->ch, iov, count);
189
return send_reply_iov(req, error, iov, count);
192
int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
195
struct iovec *padded_iov;
197
padded_iov = malloc((count + 1) * sizeof(struct iovec));
198
if (padded_iov == NULL)
199
return fuse_reply_err(req, -ENOMEM);
201
memcpy(padded_iov + 1, iov, count * sizeof(struct iovec));
204
res = send_reply_iov(req, 0, padded_iov, count);
889
907
struct fuse_ll *f = req->f;
893
printf("INTERRUPT: %llu\n", (unsigned long long) arg->unique);
911
fprintf(stderr, "INTERRUPT: %llu\n", (unsigned long long) arg->unique);
897
913
req->u.i.unique = arg->unique;
947
printf("INIT: %u.%u\n", arg->major, arg->minor);
963
fprintf(stderr, "INIT: %u.%u\n", arg->major, arg->minor);
948
964
if (arg->major > 7 || (arg->major == 7 && arg->minor >= 6)) {
949
printf("flags=0x%08x\n", arg->flags);
950
printf("max_readahead=0x%08x\n", arg->max_readahead);
965
fprintf(stderr, "flags=0x%08x\n", arg->flags);
966
fprintf(stderr, "max_readahead=0x%08x\n", arg->max_readahead);
954
969
f->conn.proto_major = arg->major;
955
970
f->conn.proto_minor = arg->minor;
996
1011
outarg.max_write = f->conn.max_write;
999
printf(" INIT: %u.%u\n", outarg.major, outarg.minor);
1000
printf(" flags=0x%08x\n", outarg.flags);
1001
printf(" max_readahead=0x%08x\n", outarg.max_readahead);
1002
printf(" max_write=0x%08x\n", outarg.max_write);
1014
fprintf(stderr, " INIT: %u.%u\n", outarg.major, outarg.minor);
1015
fprintf(stderr, " flags=0x%08x\n", outarg.flags);
1016
fprintf(stderr, " max_readahead=0x%08x\n", outarg.max_readahead);
1017
fprintf(stderr, " max_write=0x%08x\n", outarg.max_write);
1006
1020
send_reply_ok(req, &outarg, arg->minor < 5 ? 8 : sizeof(outarg));
1112
1126
const void *inarg = buf + sizeof(struct fuse_in_header);
1113
1127
struct fuse_req *req;
1116
printf("unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu\n",
1117
(unsigned long long) in->unique,
1118
opname((enum fuse_opcode) in->opcode), in->opcode,
1119
(unsigned long) in->nodeid, len);
1130
fprintf(stderr, "unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu\n",
1131
(unsigned long long) in->unique,
1132
opname((enum fuse_opcode) in->opcode), in->opcode,
1133
(unsigned long) in->nodeid, len);
1123
1135
req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req));
1124
1136
if (req == NULL) {