"Invalid directory name" error over an SMB share

511 views
Skip to first unread message

Ricardo Fonseca

unread,
Aug 11, 2021, 2:35:16 PM8/11/21
to WinFsp

Hello Bill,

I'm having an issue with SMB shares over my own MemFS from that Java binding for WinFsp using JNR.

My setup consists of two Windows Server 2016 machines:
  • one where I mount my own MemFS and create a shared folder inside its mount point (let's call this machine the "server")
  • one where I access the shared folder via SMBv2/v3 (let's call this machine the "client")
The issue arises when I try to open, in the client machine, a simple text file inside the shared directory (I've tried with Notepad, Wordpad and Sublime): it shows an "invalid directory name" error with the path of the file being opened.

When I try opening the file from the server side, everything works fine.

Furthermore, when I use your own MemFS implementation, everything works fine as well from the client machine.

Have you ever had this issue before and then fixed it with something important being done in MemFS?

Thanks.

Cheers,
Ricardo

Ricardo Fonseca

unread,
Aug 18, 2021, 6:31:08 AM8/18/21
to WinFsp
Hello again Bill,

I have tested the issue with two Windows 10 x64 machines in the same LAN and the problem persists.
Below are the steps necessary to reproduce the problem.

On the server machine:
  1. Turn on network discovery (if you want, temporarily disable password protection)
  2. Create the folder "C:\Shares"
  3. Mount the file system with the mount point "C:\Shares\Mount"
  4. Open the mount point folder with Windows Explorer and create a new folder inside it (e.g., "C:\Shares\Mount\Share")
  5. Share the folder "Share" with "Everyone" having "Full Control"
    1. Right-click the folder "Share" and click Properties, then go to the "Sharing" tab
    2. Click "Advanced Sharing...", then tick the checkbox "Share this folder"
    3. Click "Permissions", then select the "Everyone" group and tick the checkbox "Full Control" under the "Allow" column
    4. Click "OK" etc.
  6. Change the folder permissions to allow "Everyone" to "Modify"
    1. Right-click the folder "Share" and click Properties, then go to the "Security" tab
    2. Click "Edit...", then click "Add...", type in "Everyone" and click "OK"
    3. Select the "Everyone" group and tick the checkbox "Modify" under the "Allow" column
    4. Click "OK" etc.
  7. Open the "Share" folder and create a new text file named "abc.txt"

On the client machine:
  1. Turn on network discovery
  2. Open the network location for the server and open the folder named "Share" (if the server is not viewable in the Network section of explorer, try accessing it by its LAN IP address directly)
  3. Open the file "abc.txt" with a text editor (I've tested with Notepad and Sublime)
  4. If the file opens, close it and open it again immediately, repeating it 2 or 3 times if necessary until the "Invalid directory name" error occurs

I tested the procedure with various file systems ( means the error occurred, means no error):
  • passthrough-x64.exe
  • passthrough-fuse3-x64.exe
  • winfspy.memfs
  • jnr-winfsp memfs
  • memfs-x64.exe
  • memfs-fuse3-x64.exe
  • plain NTFS

What could memfs-x64.exe and memfs-fuse3-x64.exe be doing specifically that solves this issue, especially when compared with the passthrough file systems?

At some point I believed the issue was due to reparse points being implemented in some file systems and not others, but I've recently implemented reparse points in jnr-winfsp and that didn't solve the problem.

Any ideas?
Thanks again.

Cheers,
Ricardo

Ricardo Fonseca

unread,
Aug 23, 2021, 7:07:28 AM8/23/21
to WinFsp
Hi again,

I figured out what the problem was. It turns out the index number in the returned file info must be set and different for each file...

This is currently a bug in the passthrough implementations, which are erroneously setting the index number to 0 always.

Cheers,
Ricardo
Reply all
Reply to author
Forward
0 new messages