y2err("not a directory path:" << base_path);
throw IOErrorException();
}
+
#ifdef ENABLE_XATTRS
setXaStatus();
#endif
close(dirfd);
throw IOErrorException();
}
+
#ifdef ENABLE_XATTRS
xastatus = dir.xastatus;
#endif
SDir::SDir(const SDir& dir)
: base_path(dir.base_path), path(dir.path)
{
- dirfd = dup(dir.dirfd);
+ dirfd = fcntl(dir.dirfd, F_DUPFD_CLOEXEC, 0);
if (dirfd == -1)
{
- y2err("dup failed" << " error:" << stringerror(errno));
+ y2err("fcntl(F_DUPFD_CLOEXEC) failed error:" << stringerror(errno));
throw IOErrorException();
}
+
#ifdef ENABLE_XATTRS
xastatus = dir.xastatus;
#endif
{
if (this != &dir)
{
-#ifdef ENABLE_XATTRS
- xastatus = dir.xastatus;
-#endif
::close(dirfd);
- dirfd = dup(dir.dirfd);
+ dirfd = fcntl(dir.dirfd, F_DUPFD_CLOEXEC, 0);
if (dirfd == -1)
{
- y2err("dup failed" << " error:" << stringerror(errno));
+ y2err("fcntl(F_DUPFD_CLOEXEC) failed error:" << stringerror(errno));
throw IOErrorException();
}
+
+#ifdef ENABLE_XATTRS
+ xastatus = dir.xastatus;
+#endif
}
return *this;
vector<string>
SDir::entries(entries_pred_t pred) const
{
- int fd = dup(dirfd);
+ int fd = fcntl(dirfd, F_DUPFD_CLOEXEC, 0);
if (fd == -1)
{
- y2err("dup failed" << " error:" << stringerror(errno));
+ y2err("fcntl(F_DUPFD_CLOEXEC) failed error:" << stringerror(errno));
throw IOErrorException();
}