Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone dirhandles without fchdir #23019

Draft
wants to merge 1 commit into
base: blead
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14087,12 +14087,14 @@ Duplicate a directory handle, returning a pointer to the cloned object.
=cut
*/

#define HAS_FDOPENDIR 1

DIR *
Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param)
{
DIR *ret;

#if defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR)
#if !defined(HAS_FDOPENDIR) && defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR)
DIR *pwd;
const Direntry_t *dirent;
char smallbuf[256]; /* XXX MAXPATHLEN, surely? */
Expand All @@ -14102,6 +14104,7 @@ Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param)
#endif

PERL_UNUSED_CONTEXT;
PERL_UNUSED_VAR(param);
PERL_ARGS_ASSERT_DIRP_DUP;

if (!dp)
Expand All @@ -14112,7 +14115,11 @@ Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param)
if (ret)
return ret;

#if defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR)
#ifdef HAS_FDOPENDIR

ret = fdopendir(dup(my_dirfd(dp)));

#elif defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR)

PERL_UNUSED_ARG(param);

Expand Down