Determine if directory as part of C code#611
Open
zapdos26 wants to merge 2 commits intoenvmodules:mainfrom
Open
Determine if directory as part of C code#611zapdos26 wants to merge 2 commits intoenvmodules:mainfrom
zapdos26 wants to merge 2 commits intoenvmodules:mainfrom
Conversation
Extend getFilesInDirectory (C extension) to return triplets
{path hidden is_dir} instead of pairs {path hidden}. The is_dir flag
is determined from d_type when available, falling back to stat() for
DT_UNKNOWN (NFS v3) and DT_LNK (symlinks to directories).
This feeds directly into the existing fknown_arr/dknown_arr mechanism
in findModulesFromDirsAndFiles, eliminating redundant per-file
'file isdirectory' stat calls.
Also update the Tcl fallback __getFilesInDirectory to return
the same triplet format using 'file isdirectory' (which follows
symlinks).
Signed-off-by: zapdos26 <zapdoskid@gmail.com>
Verify that symlinked directories are correctly identified as directories and their modules are discoverable via avail and load. This exercises the d_type/DT_LNK handling in the C extension. Signed-off-by: zapdos26 <zapdoskid@gmail.com>
Collaborator
|
@zapdos26 Thanks for your interest in the project. Could you demonstrate by adding a new test the issue with the existing code this pull request is trying to fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the detection and handling of directories, including symlinked directories, in both the C and Tcl code for module file discovery. The changes ensure that directories are correctly identified even when directory entries have ambiguous types (such as symlinks or NFS mounts), and that this information is consistently propagated through the Tcl logic. Additionally, new tests are added to verify correct behavior with symlinked directories.
Directory detection improvements
lib/envmodules.c, the logic inEnvmodules_GetFilesInDirectoryObjCmdnow determines whether a directory entry is a directory by first checkingd_type(when available), and falling back tostat()for ambiguous or symlinked entries. This ensures accurate identification of directories, including symlinks to directories..modulercand.versionfiles.Tcl logic updates
__getFilesInDirectoryis updated to include directory status in its output usingfile isdirectory ...for each entry, and this is propagated through the code.findModulesFromDirsAndFilesandfindModulesprocedures are updated to consume and record this directory status, avoiding redundantstatcalls and improving efficiency and correctness.Test improvements
testsuite/modules.80-deep/025-symlink-deep.exp) verifies that symlinked directories are correctly identified and traversed as directories.testsuite/modulefiles.deep/plainlink) is added to support the symlink-directory test.