src/server/daemon/vfs.c

branch
webdav
changeset 286
864e2d701dd4
parent 277
7608af69739f
child 289
285d483db2fb
equal deleted inserted replaced
285:96e53bd94958 286:864e2d701dd4
122 ctx->user = acllist_getuser(sn, rq, rq->acllist); 122 ctx->user = acllist_getuser(sn, rq, rq->acllist);
123 ctx->acllist = rq->acllist; 123 ctx->acllist = rq->acllist;
124 ctx->aclreqaccess = rq->aclreqaccess; 124 ctx->aclreqaccess = rq->aclreqaccess;
125 ctx->pool = sn->pool; 125 ctx->pool = sn->pool;
126 ctx->vfs_errno = 0; 126 ctx->vfs_errno = 0;
127 ctx->error_response_set = 0;
127 return ctx; 128 return ctx;
128 } 129 }
129 130
130 SYS_FILE vfs_open(VFSContext *ctx, const char *path, int oflags) { 131 SYS_FILE vfs_open(VFSContext *ctx, const char *path, int oflags) {
131 WS_ASSERT(ctx); 132 WS_ASSERT(ctx);
142 if(sys_acl_check(ctx, access_mask, &sysacl)) { 143 if(sys_acl_check(ctx, access_mask, &sysacl)) {
143 return NULL; 144 return NULL;
144 } 145 }
145 } 146 }
146 SYS_FILE file = ctx->vfs->open(ctx, path, oflags); 147 SYS_FILE file = ctx->vfs->open(ctx, path, oflags);
147 ctx->aclreqaccess = m; // restore original access mask 148 ctx->aclreqaccess = m; // restore original access mask
149 if(!file && ctx) {
150 sys_set_error_status(ctx);
151 }
148 return file; 152 return file;
149 } 153 }
150 154
151 SYS_FILE vfs_openRO(VFSContext *ctx, const char *path) { 155 SYS_FILE vfs_openRO(VFSContext *ctx, const char *path) {
152 return vfs_open(ctx, path, O_RDONLY); 156 return vfs_open(ctx, path, O_RDONLY);
176 return -1; 180 return -1;
177 } 181 }
178 } 182 }
179 int ret = ctx->vfs->stat(ctx, path, buf); 183 int ret = ctx->vfs->stat(ctx, path, buf);
180 ctx->aclreqaccess = m; // restore original access mask 184 ctx->aclreqaccess = m; // restore original access mask
185 if(ret && ctx) {
186 sys_set_error_status(ctx);
187 }
181 return ret; 188 return ret;
182 } 189 }
183 190
184 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) { 191 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) {
185 WS_ASSERT(ctx); 192 WS_ASSERT(ctx);
186 WS_ASSERT(fd); 193 WS_ASSERT(fd);
187 WS_ASSERT(buf); 194 WS_ASSERT(buf);
188 195
189 return ctx->vfs->fstat(ctx, fd, buf); 196 int ret = ctx->vfs->fstat(ctx, fd, buf);
197 if(ret && ctx) {
198 sys_set_error_status(ctx);
199 }
200 return ret;
190 } 201 }
191 202
192 void vfs_close(SYS_FILE fd) { 203 void vfs_close(SYS_FILE fd) {
193 WS_ASSERT(fd); 204 WS_ASSERT(fd);
194 205
216 return NULL; 227 return NULL;
217 } 228 }
218 } 229 }
219 VFS_DIR dir = ctx->vfs->opendir(ctx, path); 230 VFS_DIR dir = ctx->vfs->opendir(ctx, path);
220 ctx->aclreqaccess = m; // restore original access mask 231 ctx->aclreqaccess = m; // restore original access mask
232 if(!dir && ctx) {
233 sys_set_error_status(ctx);
234 }
221 return dir; 235 return dir;
222 } 236 }
223 237
224 VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd) { 238 VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd) {
225 WS_ASSERT(ctx); 239 WS_ASSERT(ctx);
237 return NULL; 251 return NULL;
238 } 252 }
239 } 253 }
240 VFS_DIR dir = ctx->vfs->fdopendir(ctx, fd); 254 VFS_DIR dir = ctx->vfs->fdopendir(ctx, fd);
241 ctx->aclreqaccess = m; // restore original access mask 255 ctx->aclreqaccess = m; // restore original access mask
256 if(!dir && ctx) {
257 sys_set_error_status(ctx);
258 }
242 return dir; 259 return dir;
243 } 260 }
244 261
245 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry) { 262 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry) {
246 WS_ASSERT(dir); 263 WS_ASSERT(dir);
303 return -1; 320 return -1;
304 } 321 }
305 } 322 }
306 int ret = op(ctx, path); 323 int ret = op(ctx, path);
307 ctx->aclreqaccess = m; // restore original access mask 324 ctx->aclreqaccess = m; // restore original access mask
325 if(ret && ctx) {
326 sys_set_error_status(ctx);
327 }
308 return ret; 328 return ret;
309 } 329 }
310 330
311 /* system vfs implementation */ 331 /* system vfs implementation */
312 332
591 611
592 return 0; 612 return 0;
593 } 613 }
594 614
595 void sys_set_error_status(VFSContext *ctx) { 615 void sys_set_error_status(VFSContext *ctx) {
596 if(ctx->sn && ctx->rq) { 616 if(ctx->sn && ctx->rq && !ctx->error_response_set) {
597 int status = util_errno2status(ctx->vfs_errno); 617 int status = util_errno2status(ctx->vfs_errno);
598 protocol_status(ctx->sn, ctx->rq, status, NULL); 618 protocol_status(ctx->sn, ctx->rq, status, NULL);
619 ctx->error_response_set = TRUE;
599 } 620 }
600 } 621 }
601 622
602 ssize_t sys_file_read(SYS_FILE fd, void *buf, size_t nbyte) { 623 ssize_t sys_file_read(SYS_FILE fd, void *buf, size_t nbyte) {
603 return read(fd->fd, buf, nbyte); 624 return read(fd->fd, buf, nbyte);

mercurial