stat_result.st_ino from os.stat isn't constant on a network drive.

Andrew Nelson andyfaff at gmail.com
Tue Aug 25 20:20:02 EDT 2020


OS: windows 7
Python: 3.8

I am trying to track which files have been modified in a directory on a
network mount. When I call the os.stat function for a given file in
that directory the stat_result.st_ino changes every time I call it:

```
>>> os.stat('U:\data\current\myfile')
os.stat_result(st_mode=33206, st_ino=18446735965107825360, st_dev=33674366,
st_nlink=1, st_uid=0, st_gid=0, st_size=433874, st_atime=1598333128,
st_mtime=1598330233, st_ctime=1598329773)

>>> os.stat('U:\data\current\myfile')
os.stat_result(st_mode=33206, st_ino=18446735965183676432, st_dev=33674366,
st_nlink=1, st_uid=0, st_gid=0, st_size=433874, st_atime=1598333128,
st_mtime=1598330233, st_ctime=1598329773)
```
It's the same file, why on earth does the st_ino field change everytime?
st_ino is supposed to "uniquely identify the file for a given value of
st_dev."
If I do the same thing on a local file instead of on a network mount st_ino
is constant and doesn't change.

Is this a Python bug, or is it an issue with the way Windows deals with
network mounts?

Andrew.


More information about the Python-list mailing list