diff -bur --exclude config.log org/nfs.c work/nfs.c --- org/nfs.c 2007-07-19 17:43:12.000000000 +0200 +++ work/nfs.c 2007-07-22 18:18:28.000000000 +0200 @@ -938,13 +938,13 @@ { static READDIRPLUS3res result; - /* - * we don't do READDIRPLUS since it involves filehandle and - * attribute getting which is impossible to do atomically - * from user-space - */ - result.status = NFS3ERR_NOTSUPP; - result.READDIRPLUS3res_u.resfail.dir_attributes.attributes_follow = FALSE; + char *path; + + PREP(path, argp->dir); + + // FIXME: dircount + result = read_dir_plus(path, argp->cookie, argp->cookieverf, argp->maxcount); + result.READDIRPLUS3res_u.resok.dir_attributes = get_post_stat(path, rqstp); return &result; } diff -bur --exclude config.log org/readdir.c work/readdir.c --- org/readdir.c 2007-07-19 17:43:16.000000000 +0200 +++ work/readdir.c 2007-07-23 21:50:12.000000000 +0200 @@ -24,6 +24,7 @@ #include "backend.h" #include "Config/exports.h" #include "error.h" +#include "attr.h" /* * maximum number of entries in readdir results @@ -78,12 +79,12 @@ * * fh_decomp must be called directly before to fill the stat cache */ -READDIR3res read_dir(const char *path, cookie3 cookie, cookieverf3 verf, - count3 count) +READDIRPLUS3res read_dir_plus(const char *path, cookie3 cookie, cookieverf3 verf, + count3 count, struct svc_req * req) { - READDIR3res result; - READDIR3resok resok; - static entry3 entry[MAX_ENTRIES]; + READDIRPLUS3res result; + READDIRPLUS3resok resok; + static entryplus3 entry[MAX_ENTRIES]; backend_statstruct buf; int res; backend_dirstream *search; @@ -119,7 +120,7 @@ resok.reply.entries = NULL; resok.reply.eof = TRUE; result.status = NFS3_OK; - result.READDIR3res_u.resok = resok; + result.READDIRPLUS3res_u.resok = resok; return result; } else { result.status = readdir_err(); @@ -159,6 +160,37 @@ entry[i].fileid = buf.st_ino; entry[i].name = &obj[i * NFS_MAXPATHLEN]; entry[i].cookie = cookie + 1 + i; + if (req) { + /* PLUS */ + entry[i].name_attributes = get_post_buf(buf, req); + entry[i].name_handle = fh_extend_post(path, buf.st_dev, + buf.st_ino, + backend_get_gen(buf, FD_NONE, this->d_name)); + + + /* + Det mest "rätta" är väl att anropa fh_extend_post. +Men: Den går inte via fh_cachen! Det är dåligt. + + + + + */ + + + + //fh_extend_post(argp->where.dir, buf.st_dev, buf.st_ino, gen); + //fh_extend_type(argp->where.dir, obj, S_IFDIR); + + + //fh = fh_extend(argp->what.dir, buf.st_dev, buf.st_ino, gen); + //fh_cache_add(buf.st_dev, buf.st_ino, obj); + + + + // FIXME: name_handle + } + entry[i].nextentry = NULL; /* account for entry size */ @@ -194,7 +226,55 @@ memcpy(resok.cookieverf, verf, NFS3_COOKIEVERFSIZE); result.status = NFS3_OK; - result.READDIR3res_u.resok = resok; + result.READDIRPLUS3res_u.resok = resok; + + return result; +} + +READDIR3res read_dir(const char *path, cookie3 cookie, cookieverf3 verf, count3 count) +{ + READDIR3res result; + READDIRPLUS3res resultplus; + READDIR3resok *resok; + READDIRPLUS3resok *resokplus; + static entry3 entryarr[MAX_ENTRIES]; + + resultplus = read_dir_plus(path, cookie, verf, count, NULL); + + /* shortcuts */ + resok = &result.READDIR3res_u.resok; + resokplus = &resultplus.READDIRPLUS3res_u.resok; + + /* Copy values */ + result.status = resultplus.status; + /* Overlaps with resfail */ + resok->dir_attributes = resokplus->dir_attributes; + if (resultplus.status == NFS3_OK) { + entry3 *entry = entryarr; + entryplus3 *entryplus; + + memcpy(resok->cookieverf, resokplus->cookieverf, sizeof(cookieverf3)); + resok->reply.eof = resokplus->reply.eof; + if (!resokplus->reply.entries) { + resok->reply.entries = NULL; + } else { + resok->reply.entries = &entry[0]; + } + + entryplus = resokplus->reply.entries; + while (entryplus) { + entry->fileid = entryplus->fileid; + entry->name = entryplus->name; + entry->cookie = entryplus->cookie; + if (entryplus->nextentry) { + entry->nextentry = entry + 1; + } else { + entry->nextentry = NULL; + } + entry++; + entryplus = entryplus->nextentry; + } + } return result; } diff -bur --exclude config.log org/readdir.h work/readdir.h --- org/readdir.h 2006-07-09 16:19:20.000000000 +0200 +++ work/readdir.h 2007-07-22 18:35:29.000000000 +0200 @@ -7,8 +7,8 @@ #ifndef UNFS3_READDIR_H #define UNFS3_READDIR_H -READDIR3res -read_dir(const char *path, cookie3 cookie, cookieverf3 verf, count3 count); +READDIR3res read_dir(const char *path, cookie3 cookie, cookieverf3 verf, count3 count); +READDIRPLUS3res read_dir_plus(const char *path, cookie3 cookie, cookieverf3 verf, count3 count, struct svc_req * req); uint32 directory_hash(const char *path); #endif