DrvFs: Directory listing on mapped Windows network drives fails with EINVAL while direct file access works

Open
#42,221 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, linux

Research direction

Start by tracing the DrvFs/9P directory enumeration path for mapped SMB drives; the report identifies getdents64 returning EINVAL while direct file access succeeds. Reproduce with the supplied /etc/fstab automount setup and compare directory listing with direct access. Done means listing entries on the mapped drive succeeds; the issue does not name source files or tests.

Written by the indexing model from the issue text.

Description

wsl2
Windows Version

Windows 11 26H2 Build 26300.9457

WSL Version

3.0.3.0

Are you using WSL 1, WSL 2, or WSLC?
  • WSL 2
  • WSL 1
  • WSLC
Kernel Version

6.18.54.1-1

Distro Version

Ubuntu 24.04.5 LTS

Other Software
wsl --version
WSL-Version: 3.0.3.0
Kernelversion: 6.18.54.1-1
WSLg-Version: 1.0.79
MSRDC-Version: 1.2.7391
Direct3D-Version: 1.611.1-81528511
DXCore-Version: 10.0.26100.1-240331-1435.ge-release
Windows-Version: 10.0.26300.9457

Environment

Windows 11: 10.0.26300.9457

WSL package version: 3.0.3.0

Distribution: Ubuntu 24.04.5 LTS (WSL2)

Filesystem: DrvFs via 9P

Network storage: SMB share on an mapped as drive in Windows
Windows SMB network share mapped to drive The share is accessible through Windows Explorer and PowerShell.

systemd: enabled

Repro Steps
  1. Map an accessible SMB network share to drive F: in Windows.

  2. Verify that Windows can enumerate its directories using Get-ChildItem.

  3. In WSL2 (Ubuntu), ensure /mnt/f exists. (yes its defaulted exists here)

  4. Add the following entry to /etc/fstab:

    F: /mnt/f drvfs noauto,nofail,x-systemd.automount 0 0

  5. Reload systemd and activate the automount:

    sudo systemctl daemon-reload

    sudo systemctl start mnt-f.automount

  6. Access the mounted directory:

    ls -la /mnt/f

  7. Try listing an existing subdirectory:

    ls -la /mnt/f/<existing-directory>

  8. Attempt to access a known file directly using stat or a file-reading command.

The mount succeeds, and direct access to known files works. However, directory enumeration consistently fails with EINVAL.

Expected Behavior

WSL should enumerate the contents of a mapped Windows network drive through DrvFs, just as Windows Explorer and PowerShell do.

Commands such as ls, find, and other applications relying on directory enumeration should be able to access the directory entries.

Actual Behavior
getdents64(3, ..., 32768) = -1 EINVAL (Invalid argument)
ls: reading directory '/mnt/f': Invalid argument

The DrvFs mount succeeds and the network drive is accessible.

However, directory enumeration fails.

GNU ls reports:

ls: reading directory '/mnt/f': Invalid argument

In a Zsh session using a different ls frontend, the error is displayed as:

ls: .: Invalid argument (os error 22)

Both failures correspond to EINVAL (error 22).

A system call trace confirms:

getdents64(3, ..., 32768) = -1 EINVAL (Invalid argument)

Interestingly, accessing individual files by their known paths works correctly. File metadata can be retrieved, and file contents can be read successfully.

Windows PowerShell can enumerate the same directories without errors.

The problem appears to affect directory enumeration through DrvFs/9P rather than mounting or file access in general.

Diagnostic Logs

Relevant strace output:

getdents64(3, ..., 32768) = -1 EINVAL (Invalid argument)

Mount network drives in wsl

Dominant language
C++
Stars
34.4k
Forks
1.9k
Avg merge
1d 23h
Merged PRs (30d)
166

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/WSL

All issues in microsoft/WSL

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.