Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

file id and object id

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi,
Could some body explain me the difference between file id and object
id. Also how to get a fileid of a file and open with it from kernel mode
and user mode???
Regards,

Sreejith S R
IBM Global Services Pvt. Ltd.
Golden Enclave, Airport Road,
Bangalore -17

Phone : 91-80-526 2355/7117 ext: 3024
Fax : 91-80-527 7374

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    The FileID is a 64bit number composed of two parts, A 48bit index into
    the MFT and a 16bit sequence number. The sequence number is incremented
    when an MFT entry is reused. The sequence number guarantees that
    someone with an old ID will not accidentally access the wrong file
    because the old file was deleted and a new file was created in its
    place.

    A FileId can be obtained by calling ZwQueryInformationFile using the
    FileInternalInformation information class. This is documented in the
    ntifskit in ntifs.h.

    An ObjectID is a GUID (a globally unique 128bit number) that can be
    assigned to a file. NTFS maintains a per-volume database of all
    objectIDs and their associated files.

    The reason ObjectID's were added to Windows 2000 was to support the
    notion of a unique ID that will never change for a given file no matter
    what volume/system it is moved to in the world. The existing fileID
    could not be used because it is related to the internal structure of the
    file system and changes as a file is copied.

    An example of objectID usage is the new link tracking service in Windows
    2000. I am sure you have had the problem where you created a shortcut
    on your desktop to some program or document. You later do something
    that moves the location of that program/document. You now click on your
    shortcut and receive an error because the program/document no longer
    exists at the path defined in the shortcut.

    In Windows 2000 if the shortcut has an objectID associated with it, it
    can query the link tracking service passing the given objectID. Since
    the objectID is globally unique, the link tracking service can locate
    this exact program/document across a group of system.

    The ObjectID FSCTL commands are documented in MSDN.

    I hope this helps,

    Neal Christiansen


    -----Original Message-----
    From: ssreejit@in.ibm.com [mailto:ssreejit@in.ibm.com]
    Sent: Wednesday, April 19, 2000 5:08 AM
    To: File Systems Developers
    Subject: [ntfsd] file id and object id


    Hi,
    Could some body explain me the difference between file id and
    object
    id. Also how to get a fileid of a file and open with it from kernel mode
    and user mode???
    Regards,

    Sreejith S R
    IBM Global Services Pvt. Ltd.
    Golden Enclave, Airport Road,
    Bangalore -17

    Phone : 91-80-526 2355/7117 ext: 3024
    Fax : 91-80-527 7374



    ---
    You are currently subscribed to ntfsd as: xxxxx@Exchange.Microsoft.com
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    This definition of file id is peculiar to NTFS. FAT, CDFS and UDFS each
    indivdually mangle up an ID from the unique information they can derive
    for a file like byte offset of their directory relative to byte zero of
    the disk (FAT/CDFS), location of a direct entry (UDFS), etc.

    In particular, you should never expect the fileid to have a particular
    meaning. It is, however, as Neal points out, roughly guaranteed that a
    fileid will not be recycled on NTFS. FAT does not and cannot make a
    similar guarantee: the ID is unique to a given snapshot of the volume
    state, though obviously we don't shuffle dirents and it does tend to
    remain the same.

    -----Original Message-----
    From: Neal Christiansen
    Sent: Friday, April 21, 2000 3:00 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id



    The FileID is a 64bit number composed of two parts, A 48bit index into
    the MFT and a 16bit sequence number. The sequence number is incremented
    when an MFT entry is reused. The sequence number guarantees that
    someone with an old ID will not accidentally access the wrong file
    because the old file was deleted and a new file was created in its
    place.

    A FileId can be obtained by calling ZwQueryInformationFile using the
    FileInternalInformation information class. This is documented in the
    ntifskit in ntifs.h.

    An ObjectID is a GUID (a globally unique 128bit number) that can be
    assigned to a file. NTFS maintains a per-volume database of all
    objectIDs and their associated files.

    The reason ObjectID's were added to Windows 2000 was to support the
    notion of a unique ID that will never change for a given file no matter
    what volume/system it is moved to in the world. The existing fileID
    could not be used because it is related to the internal structure of the
    file system and changes as a file is copied.

    An example of objectID usage is the new link tracking service in Windows
    2000. I am sure you have had the problem where you created a shortcut
    on your desktop to some program or document. You later do something
    that moves the location of that program/document. You now click on your
    shortcut and receive an error because the program/document no longer
    exists at the path defined in the shortcut.

    In Windows 2000 if the shortcut has an objectID associated with it, it
    can query the link tracking service passing the given objectID. Since
    the objectID is globally unique, the link tracking service can locate
    this exact program/document across a group of system.

    The ObjectID FSCTL commands are documented in MSDN.

    I hope this helps,

    Neal Christiansen


    -----Original Message-----
    From: ssreejit@in.ibm.com [ mailto:ssreejit@in.ibm.com
    ]
    Sent: Wednesday, April 19, 2000 5:08 AM
    To: File Systems Developers
    Subject: [ntfsd] file id and object id


    Hi,
    Could some body explain me the difference between file id and
    object
    id. Also how to get a fileid of a file and open with it from kernel mode

    and user mode???
    Regards,

    Sreejith S R
    IBM Global Services Pvt. Ltd.
    Golden Enclave, Airport Road,
    Bangalore -17

    Phone : 91-80-526 2355/7117 ext: 3024
    Fax : 91-80-527 7374



    ---
    You are currently subscribed to ntfsd as: xxxxx@Exchange.Microsoft.com
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Thank you Dan. I should have been clearer that I was talking about
    NTFS.

    It is also important to note that ObjectID's are only supported on NTFS
    volumes.


    -----Original Message-----
    From: Daniel Lovinger
    Sent: Friday, April 21, 2000 3:08 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    This definition of file id is peculiar to NTFS. FAT, CDFS and UDFS each
    indivdually mangle up an ID from the unique information they can derive
    for a file like byte offset of their directory relative to byte zero of
    the disk (FAT/CDFS), location of a direct entry (UDFS), etc.

    In particular, you should never expect the fileid to have a particular
    meaning. It is, however, as Neal points out, roughly guaranteed that a
    fileid will not be recycled on NTFS. FAT does not and cannot make a
    similar guarantee: the ID is unique to a given snapshot of the volume
    state, though obviously we don't shuffle dirents and it does tend to
    remain the same.

    -----Original Message-----
    From: Neal Christiansen
    Sent: Friday, April 21, 2000 3:00 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id



    The FileID is a 64bit number composed of two parts, A 48bit index into
    the MFT and a 16bit sequence number. The sequence number is incremented
    when an MFT entry is reused. The sequence number guarantees that
    someone with an old ID will not accidentally access the wrong file
    because the old file was deleted and a new file was created in its
    place.

    A FileId can be obtained by calling ZwQueryInformationFile using the
    FileInternalInformation information class. This is documented in the
    ntifskit in ntifs.h.

    An ObjectID is a GUID (a globally unique 128bit number) that can be
    assigned to a file. NTFS maintains a per-volume database of all
    objectIDs and their associated files.

    The reason ObjectID's were added to Windows 2000 was to support the
    notion of a unique ID that will never change for a given file no matter
    what volume/system it is moved to in the world. The existing fileID
    could not be used because it is related to the internal structure of the
    file system and changes as a file is copied.

    An example of objectID usage is the new link tracking service in Windows
    2000. I am sure you have had the problem where you created a shortcut
    on your desktop to some program or document. You later do something
    that moves the location of that program/document. You now click on your
    shortcut and receive an error because the program/document no longer
    exists at the path defined in the shortcut.

    In Windows 2000 if the shortcut has an objectID associated with it, it
    can query the link tracking service passing the given objectID. Since
    the objectID is globally unique, the link tracking service can locate
    this exact program/document across a group of system.

    The ObjectID FSCTL commands are documented in MSDN.

    I hope this helps,

    Neal Christiansen


    -----Original Message-----
    From: ssreejit@in.ibm.com [ mailto:ssreejit@in.ibm.com
    ]
    Sent: Wednesday, April 19, 2000 5:08 AM
    To: File Systems Developers
    Subject: [ntfsd] file id and object id


    Hi,
    Could some body explain me the difference between file id and
    object
    id. Also how to get a fileid of a file and open with it from kernel mode

    and user mode???
    Regards,

    Sreejith S R
    IBM Global Services Pvt. Ltd.
    Golden Enclave, Airport Road,
    Bangalore -17

    Phone : 91-80-526 2355/7117 ext: 3024
    Fax : 91-80-527 7374



    ---
    You are currently subscribed to ntfsd as: xxxxx@Exchange.Microsoft.com
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    The ID on FAT is not unique. Start with a freshly formatted FAT volume, then create 2 directories in the root directory (TEST1 and TEST2). Create another directory(Dir0) in the TEST2 directory. In the TEST1 directory, create directories until the IDs of the directory created matches that of Dir0. This was Dir32 on my server.

    Here's the batch file I used to reproduce this.

    mkdir TEST1
    mkdir TEST2
    mkdir TEST2\Dir0
    for /L %%i in (0,1,32) DO mkdir TEST1\Dir%%i

    TEST2\Dir0 and TEST1\Dir32 bot had file IDs of 0x0000000000036a60.

    This can also be done with files instead of directories.

    Having unique file/dir IDs is very useful to a file system filter. Is there any chance of fixing this in a service pack? This problem has been around since NT 3.5 and is still present on Windows 2000 build 2195.


    Nathan Tamblin

    -----Original Message-----
    From: Neal Christiansen [mailto:xxxxx@Exchange.Microsoft.com]
    Sent: 21 April 2000 23:27
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    Thank you Dan. I should have been clearer that I was talking about NTFS.

    It is also important to note that ObjectID's are only supported on NTFS volumes.


    -----Original Message-----
    From: Daniel Lovinger
    Sent: Friday, April 21, 2000 3:08 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    This definition of file id is peculiar to NTFS. FAT, CDFS and UDFS each indivdually mangle up an ID from the unique information they can derive for a file like byte offset of their directory relative to byte zero of the disk (FAT/CDFS), location of a direct entry (UDFS), etc.

    In particular, you should never expect the fileid to have a particular meaning. It is, however, as Neal points out, roughly guaranteed that a fileid will not be recycled on NTFS. FAT does not and cannot make a similar guarantee: the ID is unique to a given snapshot of the volume state, though obviously we don't shuffle dirents and it does tend to remain the same.

    -----Original Message-----
    From: Neal Christiansen
    Sent: Friday, April 21, 2000 3:00 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id



    The FileID is a 64bit number composed of two parts, A 48bit index into the MFT and a 16bit sequence number. The sequence number is incremented when an MFT entry is reused. The sequence number guarantees that someone with an old ID will not accidentally access the wrong file because the old file was deleted and a new file was created in its place.

    A FileId can be obtained by calling ZwQueryInformationFile using the FileInternalInformation information class. This is documented in the ntifskit in ntifs.h.

    An ObjectID is a GUID (a globally unique 128bit number) that can be assigned to a file. NTFS maintains a per-volume database of all objectIDs and their associated files.

    The reason ObjectID's were added to Windows 2000 was to support the notion of a unique ID that will never change for a given file no matter what volume/system it is moved to in the world. The existing fileID could not be used because it is related to the internal structure of the file system and changes as a file is copied.

    An example of objectID usage is the new link tracking service in Windows 2000. I am sure you have had the problem where you created a shortcut on your desktop to some program or document. You later do something that moves the location of that program/document. You now click on your shortcut and receive an error because the program/document no longer exists at the path defined in the shortcut.

    In Windows 2000 if the shortcut has an objectID associated with it, it can query the link tracking service passing the given objectID. Since the objectID is globally unique, the link tracking service can locate this exact program/document across a group of system.

    The ObjectID FSCTL commands are documented in MSDN.

    I hope this helps,

    Neal Christiansen


    -----Original Message-----
    From: ssreejit@in.ibm.com [ mailto:ssreejit@in.ibm.com ]
    Sent: Wednesday, April 19, 2000 5:08 AM
    To: File Systems Developers
    Subject: [ntfsd] file id and object id


    Hi,
    Could some body explain me the difference between file id and object
    id. Also how to get a fileid of a file and open with it from kernel mode
    and user mode???
    Regards,

    Sreejith S R
    IBM Global Services Pvt. Ltd.
    Golden Enclave, Airport Road,
    Bangalore -17

    Phone : 91-80-526 2355/7117 ext: 3024
    Fax : 91-80-527 7374



    ---
    You are currently subscribed to ntfsd as: xxxxx@Exchange.Microsoft.com
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    RE: [ntfsd] file id and object idOnce, I did this:

    Uppercased the canonical name to the file
    (\device\harddiskx\partitiony\path\file.ext:stream) and did a 64 bit CRC on
    the filename. This worked quite well to create a unique ID for a file and it
    was system, not volume, limited.

    I am sure ther are more elegant mechanisms, but I neede a quick and dirty
    way to get a unique ID for a file and it had to work with SFM files; which
    use streams.


    Jamey
    -----Original Message-----
    From: xxxxx@lists.osr.com
    [mailto:xxxxx@lists.osr.com]On Behalf Of Tamblin, Nathan
    Sent: Monday, May 08, 2000 12:56 AM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    The ID on FAT is not unique. Start with a freshly formatted FAT volume,
    then create 2 directories in the root directory (TEST1 and TEST2). Create
    another directory(Dir0) in the TEST2 directory. In the TEST1 directory,
    create directories until the IDs of the directory created matches that of
    Dir0. This was Dir32 on my server.

    Here's the batch file I used to reproduce this.

    mkdir TEST1
    mkdir TEST2
    mkdir TEST2\Dir0
    for /L %%i in (0,1,32) DO mkdir TEST1\Dir%%i

    TEST2\Dir0 and TEST1\Dir32 bot had file IDs of 0x0000000000036a60.

    This can also be done with files instead of directories.

    Having unique file/dir IDs is very useful to a file system filter. Is
    there any chance of fixing this in a service pack? This problem has been
    around since NT 3.5 and is still present on Windows 2000 build 2195.


    Nathan Tamblin
    -----Original Message-----
    From: Neal Christiansen [mailto:xxxxx@Exchange.Microsoft.com]
    Sent: 21 April 2000 23:27
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    Thank you Dan. I should have been clearer that I was talking about
    NTFS.

    It is also important to note that ObjectID's are only supported on NTFS
    volumes.

    -----Original Message-----
    From: Daniel Lovinger
    Sent: Friday, April 21, 2000 3:08 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    This definition of file id is peculiar to NTFS. FAT, CDFS and UDFS
    each indivdually mangle up an ID from the unique information they can derive
    for a file like byte offset of their directory relative to byte zero of the
    disk (FAT/CDFS), location of a direct entry (UDFS), etc.

    In particular, you should never expect the fileid to have a particular
    meaning. It is, however, as Neal points out, roughly guaranteed that a
    fileid will not be recycled on NTFS. FAT does not and cannot make a similar
    guarantee: the ID is unique to a given snapshot of the volume state, though
    obviously we don't shuffle dirents and it does tend to remain the same.
    -----Original Message-----
    From: Neal Christiansen
    Sent: Friday, April 21, 2000 3:00 PM
    To: File Systems Developers
    Subject: [ntfsd] RE: file id and object id


    The FileID is a 64bit number composed of two parts, A 48bit index
    into the MFT and a 16bit sequence number. The sequence number is
    incremented when an MFT entry is reused. The sequence number guarantees
    that someone with an old ID will not accidentally access the wrong file
    because the old file was deleted and a new file was created in its place.

    A FileId can be obtained by calling ZwQueryInformationFile using the
    FileInternalInformation information class. This is documented in the
    ntifskit in ntifs.h.

    An ObjectID is a GUID (a globally unique 128bit number) that can be
    assigned to a file. NTFS maintains a per-volume database of all objectIDs
    and their associated files.

    The reason ObjectID's were added to Windows 2000 was to support the
    notion of a unique ID that will never change for a given file no matter what
    volume/system it is moved to in the world. The existing fileID could not be
    used because it is related to the internal structure of the file system and
    changes as a file is copied.

    An example of objectID usage is the new link tracking service in
    Windows 2000. I am sure you have had the problem where you created a
    shortcut on your desktop to some program or document. You later do
    something that moves the location of that program/document. You now click
    on your shortcut and receive an error because the program/document no longer
    exists at the path defined in the shortcut.

    In Windows 2000 if the shortcut has an objectID associated with it,
    it can query the link tracking service passing the given objectID. Since
    the objectID is globally unique, the link tracking service can locate this
    exact program/document across a group of system.

    The ObjectID FSCTL commands are documented in MSDN.

    I hope this helps,

    Neal Christiansen



    -----Original Message-----
    From: ssreejit@in.ibm.com [mailto:ssreejit@in.ibm.com]
    Sent: Wednesday, April 19, 2000 5:08 AM
    To: File Systems Developers
    Subject: [ntfsd] file id and object id



    Hi,
    Could some body explain me the difference between file id and
    object
    id. Also how to get a fileid of a file and open with it from kernel
    mode
    and user mode???
    Regards,

    Sreejith S R
    IBM Global Services Pvt. Ltd.
    Golden Enclave, Airport Road,
    Bangalore -17

    Phone : 91-80-526 2355/7117 ext: 3024
    Fax : 91-80-527 7374




    ---
    You are currently subscribed to ntfsd as:
    xxxxx@Exchange.Microsoft.com
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    RE: [ntfsd] file id and object id>the filename. This worked quite well to
    create a unique ID for a file and it
    >was system, not volume, limited.

    Extracting the first cluster number of the file by
    FSCTL_GET_RETRIEVAL_POINTERS also seems to be a good approach
    for unique (at least till defragmenting) file ID on FAT.

    Max
  • PopAlexandraPopAlexandra Member Posts: 6

    @OSR_Community_User said:
    RE: [ntfsd] file id and object id>the filename. This worked quite well to
    create a unique ID for a file and it
    >was system, not volume, limited.

    Extracting the first cluster number of the file by
    FSCTL_GET_RETRIEVAL_POINTERS also seems to be a good approach
    for unique (at least till defragmenting) file ID on FAT.

    Max
    

    Indeed. It works quite well. No issue for me, either!


    Alexandra from https://nttdata.ro/

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,378

    Again: See post. Read date.

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA