Lines 24-29
Link Here
|
24 |
#include "backend.h" |
24 |
#include "backend.h" |
25 |
#include "Config/exports.h" |
25 |
#include "Config/exports.h" |
26 |
#include "error.h" |
26 |
#include "error.h" |
|
|
27 |
#include "attr.h" |
27 |
|
28 |
|
28 |
/* |
29 |
/* |
29 |
* maximum number of entries in readdir results |
30 |
* maximum number of entries in readdir results |
Lines 78-89
Link Here
|
78 |
* |
79 |
* |
79 |
* fh_decomp must be called directly before to fill the stat cache |
80 |
* fh_decomp must be called directly before to fill the stat cache |
80 |
*/ |
81 |
*/ |
81 |
READDIR3res read_dir(const char *path, cookie3 cookie, cookieverf3 verf, |
82 |
READDIRPLUS3res read_dir_plus(const char *path, cookie3 cookie, cookieverf3 verf, |
82 |
count3 count) |
83 |
count3 count, struct svc_req * req) |
83 |
{ |
84 |
{ |
84 |
READDIR3res result; |
85 |
READDIRPLUS3res result; |
85 |
READDIR3resok resok; |
86 |
READDIRPLUS3resok resok; |
86 |
static entry3 entry[MAX_ENTRIES]; |
87 |
static entryplus3 entry[MAX_ENTRIES]; |
87 |
backend_statstruct buf; |
88 |
backend_statstruct buf; |
88 |
int res; |
89 |
int res; |
89 |
backend_dirstream *search; |
90 |
backend_dirstream *search; |
Lines 119-125
Link Here
|
119 |
resok.reply.entries = NULL; |
120 |
resok.reply.entries = NULL; |
120 |
resok.reply.eof = TRUE; |
121 |
resok.reply.eof = TRUE; |
121 |
result.status = NFS3_OK; |
122 |
result.status = NFS3_OK; |
122 |
result.READDIR3res_u.resok = resok; |
123 |
result.READDIRPLUS3res_u.resok = resok; |
123 |
return result; |
124 |
return result; |
124 |
} else { |
125 |
} else { |
125 |
result.status = readdir_err(); |
126 |
result.status = readdir_err(); |
Lines 159-164
Link Here
|
159 |
entry[i].fileid = buf.st_ino; |
160 |
entry[i].fileid = buf.st_ino; |
160 |
entry[i].name = &obj[i * NFS_MAXPATHLEN]; |
161 |
entry[i].name = &obj[i * NFS_MAXPATHLEN]; |
161 |
entry[i].cookie = cookie + 1 + i; |
162 |
entry[i].cookie = cookie + 1 + i; |
|
|
163 |
if (req) { |
164 |
/* PLUS */ |
165 |
entry[i].name_attributes = get_post_buf(buf, req); |
166 |
entry[i].name_handle = fh_extend_post(path, buf.st_dev, |
167 |
buf.st_ino, |
168 |
backend_get_gen(buf, FD_NONE, this->d_name)); |
169 |
|
170 |
|
171 |
/* |
172 |
Det mest "rätta" är väl att anropa fh_extend_post. |
173 |
Men: Den går inte via fh_cachen! Det är dåligt. |
174 |
|
175 |
|
176 |
|
177 |
|
178 |
*/ |
179 |
|
180 |
|
181 |
|
182 |
//fh_extend_post(argp->where.dir, buf.st_dev, buf.st_ino, gen); |
183 |
//fh_extend_type(argp->where.dir, obj, S_IFDIR); |
184 |
|
185 |
|
186 |
//fh = fh_extend(argp->what.dir, buf.st_dev, buf.st_ino, gen); |
187 |
//fh_cache_add(buf.st_dev, buf.st_ino, obj); |
188 |
|
189 |
|
190 |
|
191 |
// FIXME: name_handle |
192 |
} |
193 |
|
162 |
entry[i].nextentry = NULL; |
194 |
entry[i].nextentry = NULL; |
163 |
|
195 |
|
164 |
/* account for entry size */ |
196 |
/* account for entry size */ |
Lines 194-200
Link Here
|
194 |
memcpy(resok.cookieverf, verf, NFS3_COOKIEVERFSIZE); |
226 |
memcpy(resok.cookieverf, verf, NFS3_COOKIEVERFSIZE); |
195 |
|
227 |
|
196 |
result.status = NFS3_OK; |
228 |
result.status = NFS3_OK; |
197 |
result.READDIR3res_u.resok = resok; |
229 |
result.READDIRPLUS3res_u.resok = resok; |
|
|
230 |
|
231 |
return result; |
232 |
} |
233 |
|
234 |
READDIR3res read_dir(const char *path, cookie3 cookie, cookieverf3 verf, count3 count) |
235 |
{ |
236 |
READDIR3res result; |
237 |
READDIRPLUS3res resultplus; |
238 |
READDIR3resok *resok; |
239 |
READDIRPLUS3resok *resokplus; |
240 |
static entry3 entryarr[MAX_ENTRIES]; |
241 |
|
242 |
resultplus = read_dir_plus(path, cookie, verf, count, NULL); |
243 |
|
244 |
/* shortcuts */ |
245 |
resok = &result.READDIR3res_u.resok; |
246 |
resokplus = &resultplus.READDIRPLUS3res_u.resok; |
247 |
|
248 |
/* Copy values */ |
249 |
result.status = resultplus.status; |
250 |
/* Overlaps with resfail */ |
251 |
resok->dir_attributes = resokplus->dir_attributes; |
252 |
if (resultplus.status == NFS3_OK) { |
253 |
entry3 *entry = entryarr; |
254 |
entryplus3 *entryplus; |
255 |
|
256 |
memcpy(resok->cookieverf, resokplus->cookieverf, sizeof(cookieverf3)); |
257 |
resok->reply.eof = resokplus->reply.eof; |
258 |
if (!resokplus->reply.entries) { |
259 |
resok->reply.entries = NULL; |
260 |
} else { |
261 |
resok->reply.entries = &entry[0]; |
262 |
} |
263 |
|
264 |
entryplus = resokplus->reply.entries; |
265 |
while (entryplus) { |
266 |
entry->fileid = entryplus->fileid; |
267 |
entry->name = entryplus->name; |
268 |
entry->cookie = entryplus->cookie; |
269 |
if (entryplus->nextentry) { |
270 |
entry->nextentry = entry + 1; |
271 |
} else { |
272 |
entry->nextentry = NULL; |
273 |
} |
274 |
entry++; |
275 |
entryplus = entryplus->nextentry; |
276 |
} |
277 |
} |
198 |
|
278 |
|
199 |
return result; |
279 |
return result; |
200 |
} |
280 |
} |