Bewerken

Delen via


The FCB Structure

The file control block (FCB) structure is pointed to by the FsContext field in the file object. All of the operations that share an FCB refer to the same file. Unfortunately, SMB servers are implemented today in such a way that a name can be an alias, so that two different names could be the same file. The FCB is the focal point of file operations. Since operations on the same FCB are actually on the same file, synchronization is based on the FCB rather than some higher level object.

Whenever an FCB structure is created, a corresponding SRV_OPEN and FOBX structure is also created. More than one SRV_OPEN structure can be associated with a given FCB structure, and more than one FOBX structure is associated with a given SRV_OPEN structure. In most cases, the one SRV_OPEN structure is associated with an FCB, and the number of FOBX structures associated with a given SRV_OPEN structure is 1. To improve the spatial locality and the paging behavior in such cases, the allocation for an FCB structure also involves an allocation for one associated SRV_OPEN and FOBX structure.

RDBSS tries to allocate the associated FCB, SRV_OPEN, and FOBX structures together in memory to improve paging behavior. RDBSS does not allocate the FCB and NET_ROOT structures together because the NET_ROOT structures are not paged, but FCB structures usually are paged (unless they are paging files).

The FCB structure corresponds to every open file and directory. The FCB structure is split up into the following two portions:

  • A non-paged part allocated in non-paged pool

  • A paged part

The former is the NON_PAGED_FCB and the later is referred to as FCB.

The FCB contains a pointer to the corresponding NON_PAGED_FCB part. A backpointer is maintained from the NON_PAGED_FCB to the FCB for debugging purposes in checked builds.

The NON_PAGED_FCB contains a structure of special pointers used by Memory Manager and Cache Manager to manipulate section objects. Note that the values for these pointers are normally set outside of the file system.

An FCB structure contains the following:

  • An FSRTL_COMMON_HEADER structure

  • A signature and reference count

  • A name and associated table information

  • A backpointer to the associated NET_ROOT structure

  • A list of associated SRV_OPEN structures

  • The device object

  • Any additional storage requested by the network mini-redirector or the creator of the FCB structure