Skip to content

Commit

Permalink
ceph_mon: use readdir() as readdir_r() is deprecated
Browse files Browse the repository at this point in the history
see https://lwn.net/Articles/696469/, readdir_r() is deprecated by glibc
since 2.24. so let's use readdir() instead.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Sep 12, 2016
1 parent 3ff9da1 commit 99b7996
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/ceph_mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,20 @@ int check_mon_data_empty()
cerr << "opendir(" << mon_data << ") " << cpp_strerror(errno) << std::endl;
return -errno;
}
char buf[offsetof(struct dirent, d_name) + PATH_MAX + 1];

int code = 0;
struct dirent *de;
struct dirent *de = nullptr;
errno = 0;
while (!::readdir_r(dir, reinterpret_cast<struct dirent*>(buf), &de)) {
if (!de) {
if (errno) {
cerr << "readdir(" << mon_data << ") " << cpp_strerror(errno) << std::endl;
code = -errno;
}
break;
}
while ((de = ::readdir(dir))) {
if (string(".") != de->d_name &&
string("..") != de->d_name) {
code = -ENOTEMPTY;
break;
}
}
if (!de && errno) {
cerr << "readdir(" << mon_data << ") " << cpp_strerror(errno) << std::endl;
code = -errno;
}

::closedir(dir);

Expand Down

0 comments on commit 99b7996

Please sign in to comment.