[New-bugs-announce] [issue30480] samefile and sameopenfile fail for WebDAV mapped drives

Eryk Sun report at bugs.python.org
Fri May 26 04:50:27 EDT 2017

New submission from Eryk Sun:

os.path.samefile (used by shutil copyfile and move), os.path.sameopenfile, and pathlib.samefile rely on os.path.samestat (from genericpath.py), which compares corresponding st_dev and st_ino values. POSIX assures that the tuple (st_dev, st_ino) is unique. Windows makes no such assurance for the combination of the volume serial number (st_dev) and file index number (st_ino). The volume serial number isn't required to be unique or even non-zero ([MS-FSCC] 2.5.9), and the file index number may also be zero if the file system doesn't support it ([MS-FSCC] 2.4.20).

[MS-FSCC]: File System Control Codes

A WebDAV network drive exemplifies both cases. The volume serial number is zero, as is the file index number for every file and directory. Thus samestat() is true for every comparison on the drive, whether for a file or directory, and also when comparing files mounted on different WebDAV drives.

This isn't a common problem, but I think it's severe enough to warrant a separate Windows implementation of samefile and sameopenfile. If the corresponding st_dev and st_ino values are equal and either is zero, it should compare the final paths via _getfinalpathname. The latter would need to be modified to support passing a file descriptor for use with sameopenfile.

components: Windows
messages: 294538
nosy: eryksun, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: test needed
status: open
title: samefile and sameopenfile fail for WebDAV mapped drives
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list