assert(0);
}
-int Client::getdnames(DIR *d, char *buf, int buflen)
+int Client::_getdents(DIR *dir, char *buf, int buflen, bool fullent)
{
- DirResult *dirp = (DirResult*)d;
+ DirResult *dirp = (DirResult *)dir;
int ret = 0;
while (1) {
// is there room?
int dlen = ent[pos].d_name.length();
- const char *dname = ent[pos].d_name.c_str();
+ if (fullent)
+ dlen += sizeof(struct dirent);
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);
+ if (fullent)
+ _readdir_fill_dirent((struct dirent *)(buf + ret), &ent[pos], dirp->offset);
+ else
+ memcpy(buf + ret, ent[pos].d_name.c_str(), dlen + 1);
ret += dlen + 1;
pos++;
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
+
+ int _getdents(DIR *dirp, char *buf, int buflen, bool ful); // get a bunch of dentries at once
+ int getdents(DIR *dirp, char *buf, int buflen) {
+ return _getdents(dirp, buf, buflen, true);
+ }
+ int getdnames(DIR *dirp, char *buf, int buflen) {
+ return _getdents(dirp, buf, buflen, false);
+ }
+
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_getdents(DIR *dirp, char *buf, int buflen)
+{
+ return client->getdents(dirp, buf, buflen);
+}
+
extern "C" int ceph_getdnames(DIR *dirp, char *buf, int buflen)
{
return client->getdnames(dirp, buf, buflen);
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_getdents(DIR *dirp, char *name, int buflen);
int ceph_getdnames(DIR *dirp, char *name, int buflen);
void ceph_rewinddir(DIR *dirp);
loff_t ceph_telldir(DIR *dirp);