os.stat('<filename>')[stat.ST_INO] on Windows

Discussion in 'Python' started by Patrick Useldinger, Feb 27, 2005.

  1. What does the above yield on Windows? Are inodes supported on Windows
    NTFS, FAT, FAT32?
     
    Patrick Useldinger, Feb 27, 2005
    #1
    1. Advertising

  2. Patrick Useldinger

    Guest

    On Sun, Feb 27, 2005 at 10:16:34PM +0100, Patrick Useldinger wrote:
    > What does the above yield on Windows? Are inodes supported on Windows
    > NTFS, FAT, FAT32?


    Refer to the operating system documentation (msdn.microsoft.com?). os.stat is
    mostly a wrapper around whatever the OS provides. A quick glance at Python
    source code shows that maybe _stati64() or _wistat64() is the actual function
    used on windows.

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.6 (GNU/Linux)

    iD8DBQFCIkDoJd01MZaTXX0RAgACAJ9+H7OKtjIrJdyK/UArnK4OoEEY7QCcD7WO
    WuKIgnPXIvbd+Hx5iNZ2/L8=
    =Fj/b
    -----END PGP SIGNATURE-----
     
    , Feb 27, 2005
    #2
    1. Advertising

  3. wrote:
    > Refer to the operating system documentation (msdn.microsoft.com?).

    os.stat is
    > mostly a wrapper around whatever the OS provides. A quick glance at Python
    > source code shows that maybe _stati64() or _wistat64() is the actual function
    > used on windows.


    That doesn't really help: MSDN says

    """Number of the information node (the inode) for the file
    (UNIX-specific). On UNIX file systems, the inode describes the file date
    and time stamps, permissions, and content. When files are hard-linked to
    one another, they share the same inode. The inode, and therefore st_ino,
    has no meaning in the FAT, HPFS, or NTFS file systems.
    """

    So we know it has no meaning, but they won't tell us what its value is.
    Fortunately, MS ships the source of the CRT in VC, so we know st_ino
    is always 0 (as are st_uid and st_gid).

    Regards,
    Martin
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Feb 27, 2005
    #3
  4. Patrick Useldinger

    Tim Roberts Guest

    Patrick Useldinger <> wrote:
    >
    >What does the above yield on Windows?


    0.

    >Are inodes supported on Windows NTFS, FAT, FAT32?


    No. Inodes are strictly a Unix filesystem concept.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Mar 1, 2005
    #4
  5. Tim Roberts wrote:
    >>Are inodes supported on Windows NTFS, FAT, FAT32?

    >
    >
    > No. Inodes are strictly a Unix filesystem concept.


    I disagree. NTFS MFT records are so similar to inodes
    that their numbers could well be used in st_ino (except
    that they are 64-bit quantities, whereas st_ino
    typically has only 32 bits).

    Regards,
    Martin
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Mar 1, 2005
    #5
  6. Patrick Useldinger

    Tim Roberts Guest

    "Martin v. Löwis" <> wrote:
    >
    >Tim Roberts wrote:
    >>>Are inodes supported on Windows NTFS, FAT, FAT32?

    >>
    >> No. Inodes are strictly a Unix filesystem concept.

    >
    >I disagree. NTFS MFT records are so similar to inodes
    >that their numbers could well be used in st_ino (except
    >that they are 64-bit quantities, whereas st_ino
    >typically has only 32 bits).


    Hmmm, yes, but nearly 100% of Unix geeks have seen an inode number in their
    programming adventures, whereas I'll bet not 1 in 10,000 Windows hardliners
    has ever seen an MFT entry.

    There are things you can do with an inode number, but there's nothing you
    can do with an MFT ordinal.

    So, I'll grant that my answer was too specific, but I still believe the
    answer to the original question is "no".
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Mar 3, 2005
    #6
  7. Tim Roberts wrote:
    > Hmmm, yes, but nearly 100% of Unix geeks have seen an inode number in their
    > programming adventures, whereas I'll bet not 1 in 10,000 Windows hardliners
    > has ever seen an MFT entry.


    That is going to change. At my university, students learn what an MFT
    record is and how it is structured as part of the operating system
    course, just as they learn what an inode is.

    I'll grant you that a MFT records are less visible, primarily because
    people don't do hard links all that often. That might be changing as
    well.

    > There are things you can do with an inode number, but there's nothing you
    > can do with an MFT ordinal.


    Like what? On NTFS and Win32, you can even convert an inode number
    efficiently back to a path name (actually, all path names), something
    you cannot do on a typical Unix system (atleast not efficiently).

    > So, I'll grant that my answer was too specific, but I still believe the
    > answer to the original question is "no".


    Yes, but that's the stupidity of the MS C library, which doesn't use
    the nFileIndexHigh/nFileIndexLow fields of the
    BY_HANDLE_FILE_INFORMATION structure (it also is the stupidity of the
    Win32 API, which claims that you need an open file to support the
    notion of a file identifier).

    Regards,
    Martin
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Mar 3, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,035
    Travis Murray
    Aug 24, 2004
  2. Steven T. Hatton
    Replies:
    3
    Views:
    9,716
    Pete Becker
    Jun 2, 2005
  3. Magesh
    Replies:
    3
    Views:
    448
    Gordon Burditt
    Oct 5, 2007
  4. Rolf Krüger
    Replies:
    2
    Views:
    621
    Ian Collins
    Mar 12, 2008
  5. ruck
    Replies:
    10
    Views:
    1,281
Loading...

Share This Page