CBFS Class
Properties Methods Events Configuration Settings Errors
The CBFS class gives applications the ability to create a virtual filesystem.
Syntax
cbfsconnect.Cbfs
Remarks
The CBFS class is used to create a virtual filesystem whose contents are stored and exposed in an application-defined manner. The CBFS class's unique and powerful event-based design gives applications the flexibility needed to support a wide range of use-cases, ranging from something as simple as translating filesystem calls to files and directories on another storage medium, to something as complex as generating the entire contents of the virtual filesystem on-the-fly based on some application-specific data source.
Getting Started
Each CBFS class instance controls a single virtual filesystem, and therefore a single virtual drive. Applications can use multiple instances of the CBFS class if their use-case requires the creation of multiple virtual drives; the class's Tag property can be used to distinguish between instances during event handlers.
Here's how to get up and running:
- If the system driver hasn't been installed yet, call the Install method to do so. This only needs to be done once.
- In production, the system driver can be installed (or updated) ahead-of-time by the application's installation script using the Installer DLL. Please refer to the Driver Installation topic for more information.
- Call the Initialize method to initialize the CBFS class. This must be done each time the application starts (if the application is using multiple CBFS class instances, only the first instance created should be used to call Initialize).
- Ensure that all of the necessary event handlers have been implemented. Some event handlers, such as OpenFile, ReadFile, GetFileInfo, EnumerateDirectory, etc; are mandatory and must be implemented by all applications (note that this is not an exhaustive list). Others are optional, and only need to be implemented when certain features are enabled. Please refer to the events' documentation for more information.
- Create a virtual drive by calling the CreateStorage method.
- Call the MountMedia method to "insert storage media" into the virtual drive. (This "media" can be changed at any time later using the UnmountMedia and MountMedia methods.)
- Create one or more Mounting Points for the virtual drive using the AddMountingPoint method. A mounting point can be a drive letter, a UNC path, or a directory on an existing NTFS-formatted drive.
- Later, the application can unmount the "media" from the virtual drive using the UnmountMedia method. At this point, the application could call the MountMedia method again to "insert different storage media".
- To delete the virtual drive entirely, call the DeleteStorage method.
- To uninstall the system driver, call the Uninstall method. This should not be done as part of the driver upgrade process.
- In production, the system driver can be uninstalled by the application's uninstallation script using the Installer DLL. Please refer to the Driver Installation topic for more information.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
AccessDeniedProcesses | Collection of access rules that define which processes may not access the virtual drive. |
AccessGrantedProcesses | Collection of access rules that define which processes may access the virtual drive. |
Active | Whether the class is active and handling OS requests. |
FileCache | Which file data cache implementation to use. |
FileSystemName | The name of the virtual filesystem. |
FireAllOpenCloseEvents | Whether to fire events for all file open/close operations, or just the first and last. |
HandleAllFsctls | Whether to fire the Fsctl event for all FSCTL_* requests. |
MaxFileNameLength | The maximum filename length supported by the virtual filesystem. |
MaxFilePathLength | The maximum file path length supported by the virtual filesystem. |
MaxFileSize | The maximum file size supported by the virtual filesystem. |
MetadataCacheEnabled | Whether the metadata cache should be used. |
MetadataCacheSize | The size of the metadata cache. |
MountingPoints | Collection of mounting points for the virtual drive. |
NonExistentFilesCacheEnabled | Whether the nonexistent files cache should be used. |
NonExistentFilesCacheSize | The size of the nonexistent files cache. |
OpenFiles | Collection of information about the objects in the virtual drive that are currently open. |
OpenHandlesCount | The number of handles to filesystem objects in the virtual drive that are currently open. |
OpenObjectsCount | The number of filesystem objects in the virtual drive that are currently open. |
ProcessRestrictionsEnabled | Whether process access restrictions are enabled. |
SerializeAccess | Whether non-intersecting operations against the same file should execute serially or in parallel. |
SerializeEvents | Whether events should be fired on a single worker thread, or many. |
StorageCharacteristics | The characteristic flags to create the virtual drive with. |
StorageGUID | The GUID to create the virtual drive with. |
StoragePresent | Whether a virtual drive has been created. |
StorageType | The type of virtual drive to create. |
SupportChangeTimeAttribute | Whether the virtual filesystem supports the ChangeTime file attribute. |
SupportLastAccessTimeAttribute | Whether the virtual filesystem supports the LastAccessTime file attribute. |
SupportODXReadWrite | Whether the virtual filesystem supports ODX (Offloaded Data Transfer) operations. |
Tag | Stores application-defined data specific to this instance of the class. |
UseAlternateDataStreams | Whether the virtual filesystem supports alternate data streams. |
UseCaseSensitiveFileNames | Whether the virtual filesystem is case-sensitive, or just case-preserving. |
UseDirectoryEmptyCheck | Whether the IsDirectoryEmpty event should be used. |
UseDiskQuotas | Whether the virtual filesystem supports disk quotas. |
UseHardLinks | Whether the virtual filesystem supports hard links. |
UseReparsePoints | Whether the virtual filesystem supports reparse points. |
UseShortFileNames | Whether the virtual filesystem supports short (8.3) filenames. |
UseWindowsSecurity | Whether the virtual filesystem supports Windows' ACL-based security mechanisms. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
AddDeniedProcess | Adds a rule that prevents a process from accessing the virtual drive. |
AddGrantedProcess | Adds a rule that allows a process to access the virtual drive. |
AddMountingPoint | Adds a mounting point for the virtual drive. |
CloseOpenedFilesSnapshot | Closes the previously-created opened files snapshot. |
Config | Sets or retrieves a configuration setting. |
CreateOpenedFilesSnapshot | Creates a snapshot of information about files that are currently open. |
CreateStorage | Creates the virtual drive. |
DeleteStorage | Deletes the virtual drive. |
DisableRouteCache | Disable the automatic routing of requests to local files. |
EnableRouteCache | Enable the automatic routing of requests to local files. |
FileMatchesMask | Checks whether a particular file or directory name matches the specified mask. |
GetDriverStatus | Retrieves the status of the system driver. |
GetHandleCreatorProcessId | Retrieves the Id of the process (PID) that opened the specified file handle. |
GetHandleCreatorProcessName | Retrieves the name of the process that opened the specified file handle. |
GetHandleCreatorThreadId | Retrieves the Id of the thread that opened the specified file handle. |
GetHandleCreatorToken | Retrieves the security token associated with the process that opened the specified file handle. |
GetModuleVersion | Retrieves the version of a given product module. |
GetOriginatorProcessId | Retrieves the Id of the process (PID) that initiated the operation. |
GetOriginatorProcessName | Retrieves the name of the process that initiated the operation. |
GetOriginatorThreadId | Retrieves the Id of the thread that initiated the operation. |
GetOriginatorToken | Retrieves the security token associated with the process that initiated the operation. |
Initialize | Initializes the class. |
Install | Installs (or upgrades) the product's system drivers and/or helper DLL. |
IsCBFSVolume | Checks whether the specified volume is powered by CBFS. |
IsIconRegistered | Checks whether the specified icon is registered. |
MountMedia | Mounts media in the virtual drive, making it accessible for reading and writing. |
NotifyDirectoryChange | Notifies the OS that a file or directory has changed. |
RegisterIcon | Registers an icon that can be displayed as an overlay on the virtual drive in Windows Explorer. |
ReleaseUnusedFiles | Instructs the OS to release any files kept open by the cache manager. |
RemoveDeniedProcess | Removes a rule that prevents a process from accessing the virtual drive. |
RemoveGrantedProcess | Removes a rule that allows a process to access the virtual drive. |
RemoveMountingPoint | Removes a mounting point for the virtual drive. |
ResetIcon | Resets the virtual drive's icon back to default by deselecting the active overlay icon. |
ResetTimeout | Resets the timeout duration for the current event handler. |
RouteToFile | Instructs the class to route future requests directly to a given file. |
SetIcon | Selects a registered overlay icon for display on the virtual drive in Windows Explorer. |
ShutdownSystem | Shuts down or reboots the operating system. |
Uninstall | Uninstalls the product's system drivers and/or helper DLL. |
UnmountMedia | Unmounts media from the virtual drive. |
UnregisterIcon | Unregisters an existing overlay icon. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
CanFileBeDeleted | Fires when the driver needs to know whether a file or directory can be deleted. |
CleanupFile | Fires when the OS needs to clean up a file. |
CloseDirectoryEnumeration | Fires when the OS is finished enumerating a directory's contents. |
CloseFile | Fires when the OS needs to close a file. |
CloseHardLinksEnumeration | Fires when the OS is finished enumerating a file's hard links. |
CloseNamedStreamsEnumeration | Fires when the OS is finished enumerating a file's named streams. |
CloseQuotasEnumeration | Fires when the OS is finished reading or updating quota information. |
CreateFile | Fires when the OS wants to create a file or directory. |
CreateHardLink | Fires when the OS wants to create a new hard link to an existing file. |
DeleteFile | Fires when the OS needs to delete a file or directory. |
DeleteReparsePoint | Fires when the OS wants to delete a reparse point from a file or directory. |
Ejected | Fires when the media and virtual drive have been ejected. |
EnumerateDirectory | Fires when the OS wants to enumerate a directory's contents. |
EnumerateHardLinks | Fires when the OS needs to enumerate a file's hard links. |
EnumerateNamedStreams | Fires when the OS needs to enumerate a file's named streams. |
Error | Fires if an unhandled error occurs during an event. |
FlushFile | Fires when the OS needs to flush an open file's data out to storage. |
Fsctl | Fires when the virtual filesystem receives a non-standard request (filesystem control code). |
GetDefaultQuotaInfo | Fires when the OS needs the virtual drive's default quota information. |
GetFileInfo | Fires when the OS needs information about a file or directory. |
GetFileNameByFileId | Fires when the class needs to translate a file Id to a file or directory path. |
GetFileSecurity | Fires when the OS needs to read the Windows security attributes of a file or directory. |
GetReparsePoint | Fires when the OS wants to read a reparse point for a file or directory. |
GetVolumeId | Fire when the class needs the volume Id. |
GetVolumeLabel | Fires when the OS needs the volume label. |
GetVolumeObjectId | Fires when the OS needs the volume object Id and extended information. |
GetVolumeSize | Fires when the OS needs information about the virtual drive's capacity and free space. |
Ioctl | Fires when the disk behind the virtual filesystem receives a non-standard request (I/O control code). |
IsDirectoryEmpty | Fires when the OS needs to know whether a directory is empty. |
LockFile | Fires when the OS needs to lock a range of bytes in a file. |
Mount | Fires after the class mounts media into the virtual drive, making it available. |
OffloadReadFile | Fires when the OS wants the virtual filesystem to perform an offloaded data transfer (ODX) read operation. |
OffloadWriteFile | Fires when the OS wants the virtual filesystem to perform an offloaded data transfer (ODX) write operation. |
OpenFile | Fires when the OS wants to open a file or directory. |
QueryQuotas | Fires when the OS needs to read quota information. |
ReadFile | Fires when the OS needs to read data from an open file. |
RenameOrMoveFile | Fires when the OS wants to rename or move a file or directory within the virtual filesystem. |
SetAllocationSize | Fires when the OS needs to set a file's allocation size. |
SetDefaultQuotaInfo | Fires when the OS needs to set the virtual drive's default quota information. |
SetFileAttributes | Fires when the OS needs to change the attributes of an open file or directory. |
SetFileSecurity | Fires when the OS wants to change the Windows security attributes of a file or directory. |
SetFileSize | Fires when the OS needs to change the size of an open file. |
SetQuotas | Fires when the OS needs to update quota information. |
SetReparsePoint | Fires when the OS wants to create or update a reparse point on a file or directory. |
SetValidDataLength | Fires when the OS needs to set a file's valid data length. |
SetVolumeLabel | Fires when the OS wants to change the volume label. |
SetVolumeObjectId | Fires when the OS needs to set the volume object Id and extended information. |
UnlockFile | Fires when the OS needs to unlock a range of bytes in a file. |
Unmount | Fires after the class unmounts media from the virtual drive, making it unavailable. |
WorkerThreadCreation | Fires just after a new worker thread is created. |
WorkerThreadTermination | Fires just before a worker thread is terminated. |
WriteFile | Fires when the OS needs to write data to an open file. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
AllowOriginatorBufferMapping | Whether read file, write file, and enumerate directory requests may pass original buffers to event handlers. |
AllowReadOutsideEof | Whether read requests beyond the end of a file are surfaced, or automatically denied. |
AsyncDeleteStorageNotifications | Whether system broadcasts for virtual drive deletion are sent asynchronously. |
ClusterSize | The cluster size to create the virtual drive with. |
CorrectAllocationSizes | Whether to perform automatic allocation size correction. |
FastRenameMove | Whether open files are closed and re-opened during a rename or move operation. |
FileCachePolicyPurgeOnClose | Whether file data should be purged from the cache when the file is closed. |
FileCachePolicyWriteThrough | Whether file data should be written to storage as it is written to the cache. |
FireSetFileSizeOnWrite | Whether to fire SetFileSize before WriteFile if writing would expand the file. |
FlushFileBeforeUnlock | Whether file buffers are flushed before completion of UnlockFile operation. |
ForceFileClose | Whether the driver should force files to close after the last handle to them is closed. |
LoggingEnabled | Whether extended logging is enabled. |
MaxReadBlockSize | The maximum buffer size allowed for the ReadFile event. |
MaxWorkerThreadCount | The maximum number of worker threads to use to fire events. |
MaxWriteBlockSize | The maximum buffer size allowed for the WriteFile event. |
MinWorkerThreadCount | The minimum number of worker threads to use to fire events. |
NrDeviceQueryInfoHandling | Whether the network redirector module should respond to file-specific requests sent to non-file entries. |
SectorSize | The sector size to create the virtual drive with. |
SupportPosixStyleDeletion | Whether the driver should close all open handles to a file being deleted. |
SupportSearchIndexer | Specifies whether the driver must take additional measures to support indexing by Windows Search. |
SupportUnlockAllRequests | Whether the driver should fire the UnlockFile event for IRP_MN_UNLOCK_ALL requests or process them internally. |
SynchronousCleanupFile | Whether the driver should perform cleanup operations synchronously. |
TranslateDOSCharsInEnumMasks | Whether the DOS wildcard characters should be translated during search. |
UnusedMetadataLifetime | The time after which unused metadata cache entries are removed from the metadata cache. |
UpdateFileMetadataOnOpen | Whether the class should request file info and update internal records during file open. |
UpdateLastWriteTimeOnContentsChange | Whether to fire SetFileAttributes when changes in file contents are made. |
UseFileIds | Whether the virtual filesystem supports file IDs. |
UseObjectIds | Whether the virtual filesystem supports volume object ID. |
UseProtectiveFSFilter | Whether the driver should use a filesystem filter to try and prevent deadlocks. |
UserModeFileCacheSize | The size of the user mode file data cache. |
USNJournalPolicy | How USN Journal requests should be handled. |
VolumeGuidName | The GUID of the mounted volume. |
WorkerInitialStackSize | The initial stack size to create worker threads with. |
ZeroOriginatorBufferBeforeMapping | Whether the allocated buffer should be zeroed before it's passed to the event handler. |
BuildInfo | Information about the product's build. |
LicenseInfo | Information about the current license. |