Sun, 01 Nov 2020 08:24:21 +0100
add some references to issues
54 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2013 Olaf Wintermann. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
29 | #define _POSIX_PTHREAD_SEMANTIS |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
30 | |
54 | 31 | #include <stdio.h> |
32 | #include <stdlib.h> | |
33 | #include <unistd.h> | |
34 | #include <sys/types.h> | |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
35 | #include <aio.h> |
92
382bff43c6eb
fixed some includes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
36 | #include <ucx/map.h> |
382bff43c6eb
fixed some includes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
37 | |
54 | 38 | #include "../util/pool.h" |
171
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
39 | #include "netsite.h" |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
40 | #include "acl.h" |
54 | 41 | #include "vfs.h" |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
42 | #include "threadpools.h" |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
43 | #include "event.h" |
54 | 44 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
45 | #define VFS_MALLOC(pool, size) pool ? pool_malloc(pool, size) : malloc(size) |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
46 | #define VFS_FREE(pool, ptr) pool ? pool_free(pool, ptr) : free(ptr) |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
47 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
48 | static UcxMap *vfs_map; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
49 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
50 | static VFS sys_vfs = { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
51 | sys_vfs_open, |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
52 | sys_vfs_stat, |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
53 | sys_vfs_fstat, |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
54 | sys_vfs_opendir, |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
55 | sys_vfs_fdopendir, |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
56 | sys_vfs_mkdir, |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
57 | sys_vfs_unlink, |
247
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
58 | sys_vfs_rmdir, |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
59 | VFS_CHECKS_ACL, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
60 | NULL |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
61 | }; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
62 | |
54 | 63 | static VFS_IO sys_file_io = { |
64 | sys_file_read, | |
65 | sys_file_write, | |
189
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
66 | sys_file_pread, |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
67 | sys_file_pwrite, |
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
68 | sys_file_seek, |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
69 | sys_file_close, |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
70 | //sys_file_aioread, |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
71 | //sys_file_aiowrite, |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
72 | NULL, |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
73 | NULL |
54 | 74 | }; |
75 | ||
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
76 | static VFS_DIRIO sys_dir_io = { |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
77 | sys_dir_read, |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
78 | sys_dir_close |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
79 | }; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
80 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
81 | int vfs_init() { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
82 | vfs_map = ucx_map_new(16); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
83 | if(!vfs_map) { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
84 | return -1; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
85 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
86 | return 0; |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
87 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
88 | |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
89 | void vfs_add(char *name, VFS *vfs) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
90 | WS_ASSERT(name); |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
91 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
92 | if(!vfs_map) { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
93 | vfs_init(); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
94 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
95 | ucx_map_cstr_put(vfs_map, name, vfs); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
96 | } |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
97 | |
54 | 98 | VFSContext* vfs_request_context(Session *sn, Request *rq) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
99 | WS_ASSERT(sn); |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
100 | WS_ASSERT(rq); |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
101 | |
54 | 102 | VFSContext *ctx = pool_malloc(sn->pool, sizeof(VFSContext)); |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
103 | if(!ctx) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
104 | return NULL; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
105 | } |
54 | 106 | ctx->sn = sn; |
107 | ctx->rq = rq; | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
108 | ctx->vfs = rq->vfs ? rq->vfs : &sys_vfs; |
54 | 109 | ctx->user = acllist_getuser(sn, rq, rq->acllist); |
110 | ctx->acllist = rq->acllist; | |
111 | ctx->aclreqaccess = rq->aclreqaccess; | |
112 | ctx->pool = sn->pool; | |
113 | ctx->vfs_errno = 0; | |
114 | return ctx; | |
115 | } | |
116 | ||
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
117 | SYS_FILE vfs_open(VFSContext *ctx, const char *path, int oflags) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
118 | WS_ASSERT(ctx); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
119 | WS_ASSERT(path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
120 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
121 | uint32_t access_mask = ctx->aclreqaccess | acl_oflag2mask(oflags); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
122 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
123 | // ctx->aclreqaccess should be the complete access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
124 | uint32_t m = ctx->aclreqaccess; // save original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
125 | ctx->aclreqaccess = access_mask; // set mask for vfs->open call |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
126 | if((ctx->vfs->flags & VFS_CHECKS_ACL) != VFS_CHECKS_ACL) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
127 | // VFS does not evaluates the ACL itself, so we have to do it here |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
128 | SysACL sysacl; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
129 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
130 | return NULL; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
131 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
132 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
133 | SYS_FILE file = ctx->vfs->open(ctx, path, oflags); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
134 | ctx->aclreqaccess = m; // restore original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
135 | return file; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
136 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
137 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
138 | SYS_FILE vfs_openRO(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
139 | return vfs_open(ctx, path, O_RDONLY); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
140 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
141 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
142 | SYS_FILE vfs_openWO(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
143 | return vfs_open(ctx, path, O_WRONLY | O_CREAT); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
144 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
145 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
146 | SYS_FILE vfs_openRW(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
147 | return vfs_open(ctx, path, O_RDONLY | O_WRONLY | O_CREAT); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
148 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
149 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
150 | int vfs_stat(VFSContext *ctx, const char *path, struct stat *buf) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
151 | WS_ASSERT(ctx); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
152 | WS_ASSERT(path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
153 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
154 | uint32_t access_mask = ctx->aclreqaccess | ACL_READ_ATTRIBUTES; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
155 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
156 | // ctx->aclreqaccess should be the complete access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
157 | uint32_t m = ctx->aclreqaccess; // save original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
158 | ctx->aclreqaccess = access_mask; // set mask for vfs->open call |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
159 | if((ctx->vfs->flags & VFS_CHECKS_ACL) != VFS_CHECKS_ACL) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
160 | // VFS does not evaluates the ACL itself, so we have to do it here |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
161 | SysACL sysacl; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
162 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
163 | return -1; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
164 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
165 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
166 | int ret = ctx->vfs->stat(ctx, path, buf); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
167 | ctx->aclreqaccess = m; // restore original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
168 | return ret; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
169 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
170 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
171 | int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
172 | WS_ASSERT(ctx); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
173 | WS_ASSERT(fd); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
174 | WS_ASSERT(buf); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
175 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
176 | return ctx->vfs->fstat(ctx, fd, buf); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
177 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
178 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
179 | void vfs_close(SYS_FILE fd) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
180 | WS_ASSERT(fd); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
181 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
182 | fd->io->close(fd); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
183 | if(fd->ctx) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
184 | pool_free(fd->ctx->pool, fd); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
185 | } else { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
186 | free(fd); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
187 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
188 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
189 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
190 | VFS_DIR vfs_opendir(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
191 | WS_ASSERT(ctx); |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
192 | WS_ASSERT(path); |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
72
diff
changeset
|
193 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
194 | uint32_t access_mask = ctx->aclreqaccess | ACL_LIST; |
54 | 195 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
196 | // ctx->aclreqaccess should be the complete access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
197 | uint32_t m = ctx->aclreqaccess; // save original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
198 | ctx->aclreqaccess = access_mask; // set mask for vfs->open call |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
199 | if((ctx->vfs->flags & VFS_CHECKS_ACL) != VFS_CHECKS_ACL) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
200 | // VFS does not evaluates the ACL itself, so we have to do it here |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
201 | SysACL sysacl; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
202 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
203 | return NULL; |
54 | 204 | } |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
205 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
206 | VFS_DIR dir = ctx->vfs->opendir(ctx, path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
207 | ctx->aclreqaccess = m; // restore original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
208 | return dir; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
209 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
210 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
211 | VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
212 | WS_ASSERT(ctx); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
213 | WS_ASSERT(path); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
214 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
215 | uint32_t access_mask = ctx->aclreqaccess | ACL_LIST; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
216 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
217 | // ctx->aclreqaccess should be the complete access mask |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
218 | uint32_t m = ctx->aclreqaccess; // save original access mask |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
219 | ctx->aclreqaccess = access_mask; // set mask for vfs->open call |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
220 | if((ctx->vfs->flags & VFS_CHECKS_ACL) != VFS_CHECKS_ACL) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
221 | // VFS does not evaluates the ACL itself, so we have to do it here |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
222 | SysACL sysacl; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
223 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
224 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
225 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
226 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
227 | VFS_DIR dir = ctx->vfs->fdopendir(ctx, fd); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
228 | ctx->aclreqaccess = m; // restore original access mask |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
229 | return dir; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
230 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
231 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
232 | int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
233 | WS_ASSERT(dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
234 | WS_ASSERT(entry); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
235 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
236 | return dir->io->readdir(dir, entry, 0); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
237 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
238 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
239 | int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
240 | WS_ASSERT(dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
241 | WS_ASSERT(entry); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
242 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
243 | return dir->io->readdir(dir, entry, 1); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
244 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
245 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
246 | void vfs_closedir(VFS_DIR dir) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
247 | WS_ASSERT(dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
248 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
249 | dir->io->close(dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
250 | if(dir->ctx) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
251 | VFS_FREE(dir->ctx->pool, dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
252 | } else { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
253 | free(dir); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
254 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
255 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
256 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
257 | int vfs_mkdir(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
258 | WS_ASSERT(ctx); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
259 | WS_ASSERT(path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
260 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
261 | return vfs_path_op(ctx, path, ctx->vfs->mkdir, ACL_ADD_FILE); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
262 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
263 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
264 | int vfs_unlink(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
265 | WS_ASSERT(ctx); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
266 | WS_ASSERT(path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
267 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
268 | return vfs_path_op(ctx, path, ctx->vfs->unlink, ACL_DELETE); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
269 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
270 | |
247
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
271 | int vfs_rmdir(VFSContext *ctx, const char *path) { |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
272 | WS_ASSERT(ctx); |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
273 | WS_ASSERT(path); |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
274 | |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
275 | return vfs_path_op(ctx, path, ctx->vfs->rmdir, ACL_DELETE); |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
276 | } |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
277 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
278 | // private |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
279 | int vfs_path_op(VFSContext *ctx, const char *path, vfs_op_f op, uint32_t access) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
280 | uint32_t access_mask = ctx->aclreqaccess; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
281 | access_mask |= access; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
282 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
283 | // ctx->aclreqaccess should be the complete access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
284 | uint32_t m = ctx->aclreqaccess; // save original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
285 | ctx->aclreqaccess = access_mask; // set mask for vfs function call |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
286 | if((ctx->vfs->flags & VFS_CHECKS_ACL) != VFS_CHECKS_ACL) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
287 | // VFS does not evaluates the ACL itself, so we have to do it here |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
288 | SysACL sysacl; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
289 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
290 | return -1; |
54 | 291 | } |
292 | } | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
293 | int ret = op(ctx, path); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
294 | ctx->aclreqaccess = m; // restore original access mask |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
295 | return ret; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
296 | } |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
297 | |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
298 | /* system vfs implementation */ |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
299 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
300 | SYS_FILE sys_vfs_open(VFSContext *ctx, const char *path, int oflags) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
301 | uint32_t access_mask = ctx->aclreqaccess; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
302 | pool_handle_t *pool = ctx->pool; |
54 | 303 | |
304 | // check ACLs | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
305 | SysACL sysacl; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
306 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
54 | 307 | return NULL; |
308 | } | |
309 | ||
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
310 | if(sysacl.acl) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
311 | if(!fs_acl_check(&sysacl, ctx->user, path, access_mask)) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
312 | acl_set_error_status(ctx->sn, ctx->rq, sysacl.acl, ctx->user); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
313 | return NULL; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
314 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
315 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
316 | |
54 | 317 | // open file |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
318 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
319 | int fd = open(path, oflags, mode); |
54 | 320 | if(fd == -1) { |
321 | if(ctx) { | |
322 | ctx->vfs_errno = errno; | |
323 | sys_set_error_status(ctx); | |
324 | } | |
325 | return NULL; | |
326 | } | |
327 | ||
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
328 | // if a file system acl is active, we set the owner for newly created files |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
329 | if(((oflags & O_CREAT) == O_CREAT) && sysacl.user_uid != -1) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
330 | if(fchown(fd, sysacl.user_uid, sysacl.user_gid)) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
331 | perror("vfs_open: fchown"); |
171
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
332 | system_close(fd); |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
333 | return NULL; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
334 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
335 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
336 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
337 | VFSFile *file = VFS_MALLOC(pool, sizeof(VFSFile)); |
54 | 338 | if(!file) { |
171
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
339 | system_close(fd); |
54 | 340 | return NULL; |
341 | } | |
342 | file->ctx = ctx; | |
343 | file->data = NULL; | |
344 | file->fd = fd; | |
345 | file->io = &sys_file_io; | |
346 | return file; | |
347 | } | |
348 | ||
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
349 | int sys_vfs_stat(VFSContext *ctx, const char *path, struct stat *buf) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
350 | uint32_t access_mask = ctx->aclreqaccess; |
54 | 351 | |
352 | // check ACLs | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
353 | SysACL sysacl; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
354 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
57 | 355 | return -1; |
54 | 356 | } |
357 | ||
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
358 | if(sysacl.acl) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
359 | if(!fs_acl_check(&sysacl, ctx->user, path, access_mask)) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
360 | acl_set_error_status(ctx->sn, ctx->rq, sysacl.acl, ctx->user); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
361 | return -1; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
362 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
363 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
364 | |
54 | 365 | // stat |
366 | if(stat(path, buf)) { | |
367 | if(ctx) { | |
368 | ctx->vfs_errno = errno; | |
369 | sys_set_error_status(ctx); | |
370 | } | |
371 | return -1; | |
372 | } | |
373 | ||
374 | return 0; | |
375 | } | |
376 | ||
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
377 | int sys_vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf) { |
54 | 378 | // stat |
379 | if(fstat(fd->fd, buf)) { | |
380 | if(ctx) { | |
381 | ctx->vfs_errno = errno; | |
382 | } | |
383 | return -1; | |
384 | } | |
385 | ||
386 | return 0; | |
387 | } | |
388 | ||
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
389 | VFS_DIR sys_vfs_opendir(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
390 | uint32_t access_mask = ctx->aclreqaccess; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
391 | pool_handle_t *pool = ctx->pool; |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
392 | |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
393 | // check ACLs |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
394 | SysACL sysacl; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
395 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
396 | return NULL; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
397 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
398 | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
399 | if(sysacl.acl) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
400 | if(!fs_acl_check(&sysacl, ctx->user, path, access_mask)) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
401 | acl_set_error_status(ctx->sn, ctx->rq, sysacl.acl, ctx->user); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
402 | return NULL; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
403 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
404 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
405 | |
72 | 406 | // open directory |
407 | #ifdef BSD | |
69
4a10bc0ee80d
compiles on os x
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
67
diff
changeset
|
408 | DIR *sys_dir = opendir(path); |
97
09fbefc0e6a9
added ldap group support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
92
diff
changeset
|
409 | int dir_fd = sys_dir ? dirfd(sys_dir) : 0; |
72 | 410 | #else |
411 | int dir_fd = open(path, O_RDONLY); | |
412 | if(dir_fd == -1) { | |
413 | if(ctx) { | |
414 | ctx->vfs_errno = errno; | |
415 | sys_set_error_status(ctx); | |
416 | } | |
417 | return NULL; | |
418 | } | |
419 | DIR *sys_dir = fdopendir(dir_fd); | |
420 | #endif | |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
421 | if(!sys_dir) { |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
422 | if(ctx) { |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
423 | ctx->vfs_errno = errno; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
424 | sys_set_error_status(ctx); |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
425 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
426 | return NULL; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
427 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
428 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
429 | SysVFSDir *dir_data = VFS_MALLOC(pool, sizeof(SysVFSDir)); |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
430 | if(!dir_data) { |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
431 | closedir(sys_dir); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
432 | return NULL; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
433 | } |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
434 | long maxfilelen = fpathconf(dir_fd, _PC_NAME_MAX); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
435 | size_t entry_len = offsetof(struct dirent, d_name) + maxfilelen + 1; |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
436 | dir_data->cur = VFS_MALLOC(pool, entry_len); |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
437 | if(!dir_data->cur) { |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
438 | closedir(sys_dir); |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
439 | VFS_FREE(pool, dir_data); |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
440 | return NULL; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
441 | } |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
442 | dir_data->dir = sys_dir; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
443 | |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
444 | VFSDir *dir = VFS_MALLOC(pool, sizeof(VFSDir)); |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
445 | if(!dir) { |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
446 | closedir(sys_dir); |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
447 | VFS_FREE(pool, dir_data->cur); |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
448 | VFS_FREE(pool, dir_data); |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
449 | return NULL; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
450 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
451 | dir->ctx = ctx; |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
452 | dir->data = dir_data; |
72 | 453 | dir->fd = dir_fd; |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
454 | dir->io = &sys_dir_io; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
455 | return dir; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
456 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
457 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
458 | VFS_DIR sys_vfs_fdopendir(VFSContext *ctx, SYS_FILE fd) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
459 | uint32_t access_mask = ctx->aclreqaccess; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
460 | pool_handle_t *pool = ctx->pool; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
461 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
462 | // check ACLs |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
463 | SysACL sysacl; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
464 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
465 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
466 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
467 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
468 | if(sysacl.acl) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
469 | if(!fs_acl_check_fd(&sysacl, ctx->user, fd->fd, access_mask)) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
470 | acl_set_error_status(ctx->sn, ctx->rq, sysacl.acl, ctx->user); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
471 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
472 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
473 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
474 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
475 | // open directory |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
476 | DIR *sys_dir = fdopendir(fd->fd); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
477 | if(!sys_dir) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
478 | if(ctx) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
479 | ctx->vfs_errno = errno; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
480 | sys_set_error_status(ctx); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
481 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
482 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
483 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
484 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
485 | SysVFSDir *dir_data = VFS_MALLOC(pool, sizeof(SysVFSDir)); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
486 | if(!dir_data) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
487 | closedir(sys_dir); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
488 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
489 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
490 | long maxfilelen = fpathconf(fd->fd, _PC_NAME_MAX); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
491 | size_t entry_len = offsetof(struct dirent, d_name) + maxfilelen + 1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
492 | dir_data->cur = VFS_MALLOC(pool, entry_len); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
493 | if(!dir_data->cur) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
494 | closedir(sys_dir); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
495 | VFS_FREE(pool, dir_data); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
496 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
497 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
498 | dir_data->dir = sys_dir; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
499 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
500 | VFSDir *dir = VFS_MALLOC(pool, sizeof(VFSDir)); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
501 | if(!dir) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
502 | closedir(sys_dir); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
503 | VFS_FREE(pool, dir_data->cur); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
504 | VFS_FREE(pool, dir_data); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
505 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
506 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
507 | dir->ctx = ctx; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
508 | dir->data = dir_data; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
509 | dir->fd = fd->fd; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
510 | dir->io = &sys_dir_io; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
511 | return dir; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
512 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
513 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
514 | int sys_vfs_mkdir(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
515 | return sys_path_op(ctx, path, sys_mkdir); |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
516 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
517 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
518 | int sys_vfs_unlink(VFSContext *ctx, const char *path) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
519 | return sys_path_op(ctx, path, sys_unlink); |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
520 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
521 | |
247
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
522 | int sys_vfs_rmdir(VFSContext *ctx, const char *path) { |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
523 | return sys_path_op(ctx, path, sys_rmdir); |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
524 | } |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
525 | |
54 | 526 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
527 | int sys_path_op(VFSContext *ctx, const char *path, sys_op_f op) { |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
528 | uint32_t access_mask = ctx->aclreqaccess; |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
529 | |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
530 | // check ACLs |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
531 | SysACL sysacl; |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
532 | if(sys_acl_check(ctx, access_mask, &sysacl)) { |
57 | 533 | return -1; |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
534 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
535 | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
536 | if(sysacl.acl) { |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
537 | if(!fs_acl_check(&sysacl, ctx->user, path, access_mask)) { |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
538 | acl_set_error_status(ctx->sn, ctx->rq, sysacl.acl, ctx->user); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
539 | return -1; |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
540 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
541 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
542 | |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
543 | // do path operation |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
544 | if(op(ctx, path, &sysacl)) { |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
545 | // error |
165
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
546 | ctx->vfs_errno = errno; |
6942a8c3e737
refactors vfs code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
547 | sys_set_error_status(ctx); |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
548 | return -1; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
549 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
550 | |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
551 | return 0; |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
552 | } |
54 | 553 | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
554 | int sys_acl_check(VFSContext *ctx, uint32_t access_mask, SysACL *sysacl) { |
67
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
555 | if(sysacl) { |
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
556 | sysacl->acl = NULL; |
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
557 | } |
54 | 558 | if(!ctx) { |
559 | return 0; | |
560 | } | |
561 | ||
562 | ACLListHandle *acllist = ctx->acllist; | |
563 | if(acllist) { | |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
564 | ACLList *acl = acl_evallist( |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
565 | acllist, |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
566 | ctx->user, |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
567 | access_mask, |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
568 | &sysacl->acl); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
569 | |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
570 | if(acl) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
571 | acl_set_error_status(ctx->sn, ctx->rq, acl, ctx->user); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
572 | return 1; |
54 | 573 | } |
574 | } | |
575 | ||
576 | return 0; | |
577 | } | |
578 | ||
579 | void sys_set_error_status(VFSContext *ctx) { | |
580 | if(ctx->sn && ctx->rq) { | |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
581 | int status = util_errno2status(ctx->vfs_errno); |
54 | 582 | protocol_status(ctx->sn, ctx->rq, status, NULL); |
583 | } | |
584 | } | |
585 | ||
586 | ssize_t sys_file_read(SYS_FILE fd, void *buf, size_t nbyte) { | |
587 | return read(fd->fd, buf, nbyte); | |
588 | } | |
589 | ||
590 | ssize_t sys_file_write(SYS_FILE fd, const void *buf, size_t nbyte) { | |
591 | return write(fd->fd, buf, nbyte); | |
592 | } | |
593 | ||
189
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
594 | ssize_t sys_file_pread(SYS_FILE fd, void *buf, size_t nbyte, off_t offset) { |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
595 | return pread(fd->fd, buf, nbyte, offset); |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
596 | } |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
597 | |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
598 | ssize_t sys_file_pwrite(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset) { |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
599 | return pwrite(fd->fd, buf, nbyte, offset); |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
600 | } |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
601 | |
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
602 | off_t sys_file_seek(SYS_FILE fd, off_t offset, int whence) { |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
603 | return lseek(fd->fd, offset, whence); |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
604 | } |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
605 | |
54 | 606 | void sys_file_close(SYS_FILE fd) { |
171
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
607 | system_close(fd->fd); |
54 | 608 | } |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
609 | |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
610 | int sys_file_aioread(aiocb_s *aiocb) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
611 | WS_ASSERT(aiocb->buf); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
612 | WS_ASSERT(aiocb->nbytes > 0); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
613 | return ev_aioread(aiocb->filedes->fd, aiocb); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
614 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
615 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
616 | int sys_file_aiowrite(aiocb_s *aiocb) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
617 | WS_ASSERT(aiocb->buf); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
618 | WS_ASSERT(aiocb->nbytes > 0); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
619 | return ev_aiowrite(aiocb->filedes->fd, aiocb); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
620 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
621 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
622 | |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
623 | int sys_dir_read(VFS_DIR dir, VFS_ENTRY *entry, int getstat) { |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
624 | SysVFSDir *dirdata = dir->data; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
625 | struct dirent *result = NULL; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
626 | int s = readdir_r(dirdata->dir, dirdata->cur, &result); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
627 | if(!s && result) { |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
628 | char *name = result->d_name; |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
629 | if(!strcmp(name, ".") || !strcmp(name, "..")) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
630 | return sys_dir_read(dir, entry, getstat); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
631 | } else { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
632 | entry->name = name; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
633 | if(getstat) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
634 | // TODO: check ACLs again for new path |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
635 | entry->stat_errno = 0; |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
636 | if(fstatat(dir->fd, result->d_name, &entry->stat, 0)) { |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
637 | entry->stat_errno = errno; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
638 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
639 | entry->stat_extra = NULL; |
185
b4d7ccf4e06d
implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
172
diff
changeset
|
640 | } |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
641 | return 1; |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
642 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
643 | } else { |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
644 | return 0; |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
645 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
646 | } |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
647 | |
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
648 | void sys_dir_close(VFS_DIR dir) { |
105
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
649 | SysVFSDir *dirdata = dir->data; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
650 | closedir(dirdata->dir); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
651 | |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
652 | pool_handle_t *pool = dir->ctx->pool; |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
653 | if(pool) { |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
654 | pool_free(pool, dirdata->cur); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
655 | pool_free(pool, dirdata); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
656 | pool_free(pool, dir); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
657 | } else { |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
658 | free(dirdata->cur); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
659 | free(dirdata); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
660 | free(dir); |
63d9051fe35c
using readdir_r instead of readdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
97
diff
changeset
|
661 | } |
55
b7908bf38f9f
vfs can read directories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
662 | } |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
663 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
664 | int sys_mkdir(VFSContext *ctx, const char *path, SysACL *sysacl) { |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
665 | mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
63
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
666 | int ret = mkdir(path, mode); |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
667 | if(ret == 0) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
668 | if(sysacl->user_uid != -1) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
669 | if(chown(path, sysacl->user_uid, sysacl->user_gid)) { |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
670 | // TODO: error |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
671 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
672 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
673 | } |
66442f81f823
supports file system ACLs on Solaris
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
674 | return ret; |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
675 | } |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
676 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
677 | int sys_unlink(VFSContext *ctx, const char *path, SysACL *sysacl) { |
56
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
678 | return unlink(path); |
c6cf20b09043
added vfs_mkdir and vfs_unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
679 | } |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
680 | |
247
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
681 | int sys_rmdir(VFSContext *ctx, const char *path, SysACL *sysacl) { |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
682 | return rmdir(path); |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
683 | } |
1df803e06076
implement webdav delete for collections
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
684 | |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
685 | /* public file api */ |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
686 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
687 | NSAPI_PUBLIC int system_fread(SYS_FILE fd, void *buf, int nbyte) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
688 | return fd->io->read(fd, buf, nbyte); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
689 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
690 | |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
691 | NSAPI_PUBLIC int system_fwrite(SYS_FILE fd, const void *buf, int nbyte) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
692 | return fd->io->write(fd, buf, nbyte); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
693 | } |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
694 | |
189
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
695 | NSAPI_PUBLIC int system_pread(SYS_FILE fd, void *buf, int nbyte, off_t offset) { |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
696 | return fd->io->pread(fd, buf, nbyte, offset); |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
697 | } |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
698 | |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
699 | NSAPI_PUBLIC int system_pwrite(SYS_FILE fd, const void *buf, int nbyte, off_t offset) { |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
700 | return fd->io->pwrite(fd, buf, nbyte, offset); |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
701 | } |
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
702 | |
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
703 | NSAPI_PUBLIC off_t system_lseek(SYS_FILE fd, off_t offset, int whence) { |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
704 | return fd->io->seek(fd, offset, whence); |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
705 | } |
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
706 | |
58
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
707 | NSAPI_PUBLIC int system_fclose(SYS_FILE fd) { |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
708 | vfs_close(fd); |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
709 | return 0; |
66c22e54aa90
webdav uses the vfs api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
57
diff
changeset
|
710 | } |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
711 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
712 | // AIO API |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
713 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
714 | NSAPI_PUBLIC int system_aio_read(aiocb_s *aiocb) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
715 | if(!aiocb->event || !aiocb->evhandler) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
716 | return -1; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
717 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
718 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
719 | SYS_FILE file = aiocb->filedes; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
720 | aiocb->event->object = (intptr_t)aiocb; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
721 | if(file->io->opt_aioread) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
722 | return file->io->opt_aioread(aiocb); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
723 | } else { |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
724 | vfs_queue_aio(aiocb, VFS_AIO_READ); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
725 | return 0; |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
726 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
727 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
728 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
729 | NSAPI_PUBLIC int system_aio_write(aiocb_s *aiocb) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
730 | if(!aiocb->event || !aiocb->evhandler) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
731 | return -1; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
732 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
733 | |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
734 | SYS_FILE file = aiocb->filedes; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
735 | aiocb->event->object = (intptr_t)aiocb; |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
736 | if(file->io->opt_aiowrite) { |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
737 | return file->io->opt_aiowrite(aiocb); |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
738 | } else { |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
739 | vfs_queue_aio(aiocb, VFS_AIO_WRITE); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
740 | return 0; |
172
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
741 | } |
5580517faafc
adds public aio and poll api and asynchronous send_range function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
165
diff
changeset
|
742 | } |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
743 | |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
744 | static void* vfs_aio_read(aiocb_s *aiocb) { |
189
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
745 | int result = system_pread(aiocb->filedes, aiocb->buf, aiocb->nbytes, aiocb->offset); |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
746 | aiocb->result = result; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
747 | if(result < 0) { |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
748 | aiocb->result_errno = errno; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
749 | } |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
750 | event_send(aiocb->evhandler, aiocb->event); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
751 | return NULL; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
752 | } |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
753 | |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
754 | static void* vfs_aio_write(aiocb_s *aiocb) { |
189
a2438f6d1e73
adds vfs pread/pwrite functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
755 | int result = system_pwrite(aiocb->filedes, aiocb->buf, aiocb->nbytes, aiocb->offset); |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
756 | aiocb->result = result; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
757 | if(result < 0) { |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
758 | aiocb->result_errno = errno; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
759 | } |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
760 | event_send(aiocb->evhandler, aiocb->event); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
761 | return NULL; |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
762 | } |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
763 | |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
764 | void vfs_queue_aio(aiocb_s *aiocb, VFSAioOp op) { |
190
1f73302461e0
adds IO threadpool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
189
diff
changeset
|
765 | threadpool_t *pool = get_default_iopool(); // TODO: use specific IOPool |
187
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
766 | if(op == VFS_AIO_READ) { |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
767 | threadpool_run(pool, (job_callback_f)vfs_aio_read, aiocb); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
768 | } else if(VFS_AIO_WRITE) { |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
769 | threadpool_run(pool, (job_callback_f)vfs_aio_write, aiocb); |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
770 | } |
4384bfbb7e26
adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
771 | } |