none
Wrong path type and size on mounted samba share on Windows 10 RRS feed

  • Question

  • Hi,

    I have been asked at answers.microsoft.com to ask my question here.

    I use a pretty simple python script (also tried a nodejs script) like the one at the end to find all files in a directory and its subdirectories together with their file size and modified time. Therefore the script uses stat syscall to retrieve information about a path: type (regular file, directory etc.), size, modified time.

    If I run the script on a local folder on Windows 10, Windows 7 and Ubuntu everything works fine. If I run the script on Windows 7 or Ubuntu on a folder that is a mounted samba share, everything works fine, too.

    However, if I run the script on Windows 10 on a folder that is on a mounted samba share, things start to get weird. I get error messages like the following:

    C:\Users\Biggie\Scripts>python test.py
    Traceback (most recent call last):
      File "test.py", line 10, in <module>
        childs = listdir(next)
    WindowsError: [Error 267] The directory name is invalid: 'y:\\some\\path\\file.jpg\\*.*'


    This happens, because the result of the stat call states that the path is a directory, although it is a regular jpg file. If I start an interactive python or nodejs shell and call stat for the reported file, the return value looks ok this time (correct type, size etc.). It looks like the samba client on Windows 10 bungles when too many stat calls are issued in a short time interval.

    Is this a known problem? To me it looks like a fatal bug. Is there a way to get around is problem by using some Windows 10 settings?

    In my case the script is actually the base for a backup application ... which will totally do the wrong thing if file sizes and types are returned incorrectly.

    Note: I tested 2 Windows clients running Windows 10. The 3 tested samba servers are running Ubuntu using pretty much Ubuntu's default smbd configs (besides share definitions). I also tried to force SMB2 but that didn't change anything.

    Appendix:

    The python script. The nodejs script (not listed here) does pretty much the same thing:

    from os import listdir, stat
    from os.path import join
    from stat import *
    
    files = []
    todo = ['y:\\'] # y:\\ is a mounted samba share
    
    while len(todo) > 0:
        next = todo.pop(0)
        childs = listdir(next)
        for child in childs:
            childPath = join(next, child)
            childStat = stat(childPath)
            mode = childStat.st_mode
            if S_ISREG(mode):
                files.append(childStat)
            elif S_ISDIR(mode):
                todo.append(childPath)
    
    print len(files) # Will not be called because error is thrown before on Windows 10



    Wednesday, February 13, 2019 7:50 AM

All replies

  • This is not a Python forum.  Please post your script in a Python forum.  This forum is for administrative scripting. and a PowerShell only forum.

    Please excuse the "contingent staff" they do not have much experience with technical questions and likely don't know what Python is.


    \_(ツ)_/

    Thursday, February 14, 2019 7:18 AM
  • This is not a Python forum.  Please post your script in a Python forum.  This forum is for administrative scripting. and a PowerShell only forum.

    Please excuse the "contingent staff" they do not have much experience with technical questions and likely don't know what Python is.


    \_(ツ)_/

    This is not about python or nodejs or any other programming language. It is about Windows 10 delivering wrong information on a low level. Probably, I can also write a PS code to trigger the bug. Moreover this thread was posted in the network section, not a PS section. Maybe you can tell me where I can send a bug report to Microsoft?
    Thursday, February 14, 2019 10:13 AM
  • To get help from MS about issues with Windows contact MS Support directly.  If they decide it is a bug the support incident will be free.

    Also note that W10 does not support SMB 1..  The server you are connecting to must support SMB 2.0 or later.

    If you search you will find articles on this and also some possible workarounds.

    You would have had better luck if you had asked a simpler question like asking why W10 cannot connect to an SMB share. All of the talk about Python and nodejs obscured the question.


    \_(ツ)_/


    • Edited by jrv Thursday, February 14, 2019 10:29 AM
    Thursday, February 14, 2019 10:17 AM
  • Thursday, February 14, 2019 10:30 AM
  • I would have asked a simpler question if the question was simpler ;) But it is not. It is not about connecting to a samba share. The connection is fine. BTW I tested SMB3 and 2. I already know that SMB1 is not supported anymore :)

    It seems that the problem takes place if too many requests on filesize/types are issued (on an existing samba connection). Windows 10 seems to mix up them. But maybe you're right and I need to contact MS directly.

    Thursday, February 14, 2019 11:01 AM