summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-08-23 12:00:30 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-08-23 12:00:30 -0700
commit057588f41af39460f46f36594ac1c5c962068289 (patch)
tree2df5baa778b464c38c500494486e2685843d95fe
parentfe5010380a3a18ca85f39403e8032de1dddbe905 (diff)
parent99a2ff7da99f8cf70976f05d4fe7aa28dd7afae5 (diff)
downloadceph-057588f41af39460f46f36594ac1c5c962068289.tar.gz
Merge pull request #535 from ceph/wip-readdir-r-sucks
Fix readdir_r invocation Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/os/BtrfsFileStoreBackend.cc5
-rw-r--r--src/os/FileStore.cc5
-rw-r--r--src/os/FlatIndex.cc5
-rw-r--r--src/os/LFNIndex.cc4
4 files changed, 11 insertions, 8 deletions
diff --git a/src/os/BtrfsFileStoreBackend.cc b/src/os/BtrfsFileStoreBackend.cc
index 9fa96babab7..ac7d1014ac7 100644
--- a/src/os/BtrfsFileStoreBackend.cc
+++ b/src/os/BtrfsFileStoreBackend.cc
@@ -320,8 +320,9 @@ int BtrfsFileStoreBackend::list_checkpoints(list<string>& ls)
list<string> snaps;
char path[PATH_MAX];
- struct dirent buf, *de;
- while (::readdir_r(dir, &buf, &de) == 0) {
+ char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
+ struct dirent *de;
+ while (::readdir_r(dir, (struct dirent *)&buf, &de) == 0) {
if (!de)
break;
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index 80561056daa..81407373685 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -3787,8 +3787,9 @@ int FileStore::list_collections(vector<coll_t>& ls)
return r;
}
- struct dirent sde, *de;
- while ((r = ::readdir_r(dir, &sde, &de)) == 0) {
+ char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
+ struct dirent *de;
+ while ((r = ::readdir_r(dir, (struct dirent *)&buf, &de)) == 0) {
if (!de)
break;
if (de->d_type == DT_UNKNOWN) {
diff --git a/src/os/FlatIndex.cc b/src/os/FlatIndex.cc
index f4a5ce3ab7d..db46750e411 100644
--- a/src/os/FlatIndex.cc
+++ b/src/os/FlatIndex.cc
@@ -387,7 +387,8 @@ int FlatIndex::collection_list_partial(const hobject_t &start,
}
int FlatIndex::collection_list(vector<hobject_t> *ls) {
- char dir_name[PATH_MAX], buf[PATH_MAX], new_name[PATH_MAX];
+ char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
+ char dir_name[PATH_MAX], new_name[PATH_MAX];
strncpy(dir_name, base_path.c_str(), sizeof(dir_name));
dir_name[sizeof(dir_name)-1]='\0';
@@ -399,7 +400,7 @@ int FlatIndex::collection_list(vector<hobject_t> *ls) {
vector< pair<ino_t,hobject_t> > inolist;
struct dirent *de;
- while (::readdir_r(dir, (struct dirent*)buf, &de) == 0) {
+ while (::readdir_r(dir, (struct dirent *)buf, &de) == 0) {
if (!de)
break;
// parse
diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc
index 09d0f02267f..029e8ad8197 100644
--- a/src/os/LFNIndex.cc
+++ b/src/os/LFNIndex.cc
@@ -378,7 +378,7 @@ int LFNIndex::list_objects(const vector<string> &to_list, int max_objs,
long *handle, map<string, hobject_t> *out) {
string to_list_path = get_full_path_subdir(to_list);
DIR *dir = ::opendir(to_list_path.c_str());
- char buf[PATH_MAX];
+ char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
int r;
if (!dir) {
return -errno;
@@ -438,7 +438,7 @@ int LFNIndex::list_subdirs(const vector<string> &to_list,
set<string> *out) {
string to_list_path = get_full_path_subdir(to_list);
DIR *dir = ::opendir(to_list_path.c_str());
- char buf[PATH_MAX];
+ char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];
if (!dir)
return -errno;