assert(0);
}
+int Client::getdnames(DIR *d, char *buf, int buflen)
+{
+ DirResult *dirp = (DirResult*)d;
+ int ret = 0;
+
+ while (1) {
+ if (dirp->at_end())
+ return 0;
+
+ if (dirp->buffer.count(dirp->frag()) == 0) {
+ Mutex::Locker lock(client_lock);
+ _readdir_get_frag(dirp);
+ if (dirp->at_end())
+ return 0;
+ }
+
+ frag_t fg = dirp->frag();
+ uint32_t pos = dirp->fragpos();
+ assert(dirp->buffer.count(fg));
+ vector<DirEntry> &ent = dirp->buffer[fg];
+
+ if (ent.empty()) {
+ dout(10) << "empty frag " << fg << ", moving on to next" << dendl;
+ _readdir_next_frag(dirp);
+ continue;
+ }
+
+ assert(pos < ent.size());
+
+ // is there room?
+ int dlen = ent[pos].d_name.length();
+ const char *dname = ent[pos].d_name.c_str();
+ if (ret + dlen + 1 > buflen) {
+ if (!ret)
+ return -ERANGE; // the buffer is too small for the first name!
+ return ret;
+ }
+ memcpy(buf + ret, dname, dlen + 1);
+ ret += dlen + 1;
+
+ pos++;
+ dirp->offset++;
+
+ if (pos == ent.size())
+ _readdir_next_frag(dirp);
+ }
+ assert(0);
+}
+
+
int Client::closedir(DIR *dir)
{
int closedir(DIR *dirp);
int readdir_r(DIR *dirp, struct dirent *de);
int readdirplus_r(DIR *dirp, struct dirent *de, struct stat *st, int *stmask);
+ int getdnames(DIR *dirp, char *buf, int buflen); // get a bunch of dentries at once
void rewinddir(DIR *dirp);
loff_t telldir(DIR *dirp);
void seekdir(DIR *dirp, loff_t offset);
return client->readdirplus_r(dirp, de, st, stmask);
}
+extern "C" int ceph_getdnames(DIR *dirp, char *buf, int buflen)
+{
+ return client->getdnames(dirp, buf, buflen);
+}
+
extern "C" void ceph_rewinddir(DIR *dirp)
{
client->rewinddir(dirp);
int ceph_closedir(DIR *dirp);
int ceph_readdir_r(DIR *dirp, struct dirent *de);
int ceph_readdirplus_r(DIR *dirp, struct dirent *de, struct stat *st, int *stmask);
+int ceph_getdnames(DIR *dirp, char *name, int buflen);
void ceph_rewinddir(DIR *dirp);
loff_t ceph_telldir(DIR *dirp);
void ceph_seekdir(DIR *dirp, loff_t offset);