Win32 Windows Volume Program and Code Example 27

 

 

 

 

 

Volume Management Reference

 

Volume Management Functions

 

The following functions are used in volume management.

 

Function

Description

DefineDosDevice()

Defines, redefines, or deletes MS-DOS device names.

GetDriveType()

Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.

GetLogicalDrives()

Retrieves a bitmask representing the currently available disk drives.

GetLogicalDriveStrings()

Fills a buffer with strings that specify valid drives in the system.

GetVolumeInformation()

Retrieves information about the file system and volume associated with the specified root directory.

GetVolumeInformationByHandleW()

Retrieves information about the file system and volume associated with the specified file.

QueryDosDevice()

Retrieves information about MS-DOS device names.

SetVolumeLabel()

Sets the label of a file system volume.

 

The following functions are used with volume mount points (drive letters, volume GUID paths, and mounted folders).

 

Function

Description

DeleteVolumeMountPoint()

Deletes a drive letter or mounted folder.

FindFirstVolume()

Retrieves the name of a volume on a computer.

FindFirstVolumeMountPoint()

Retrieves the name of a mounted folder on the specified volume.

FindNextVolume()

Continues a volume search started by a call to FindFirstVolume.

FindNextVolumeMountPoint()

Continues a mounted folder search started by a call to FindFirstVolumeMountPoint.

FindVolumeClose()

Closes the specified volume search handle.

FindVolumeMountPointClose()

Closes the specified mounted folder search handle.

GetVolumeNameForVolumeMountPoint()

Retrieves a volume GUID path for the volume that is associated with the specified volume mount point (drive letter, volume GUID path, or mounted folder).

GetVolumePathName()

Retrieves the mounted folder that is associated with the specified volume.

GetVolumePathNamesForVolumeName()

Retrieves a list of drive letters and volume GUID paths for the specified volume.

SetVolumeMountPoint()

Associates a volume with a drive letter or a directory on another volume.

 

Volume Management Control Codes

 

The following control codes are used in volume management.

 

Control code

Operation

FSCTL_DISMOUNT_VOLUME

Dismounts a volume.

FSCTL_EXTEND_VOLUME

Increases the size of a mounted volume.

FSCTL_GET_BOOT_AREA_INFO

Retrieves the locations of boot sectors for a volume.

FSCTL_GET_NTFS_VOLUME_DATA

Retrieves information about the specified NTFS file system volume.

FSCTL_IS_VOLUME_MOUNTED

Determines whether the specified volume is mounted, or if the specified file or directory is on a mounted volume.

FSCTL_LOCK_VOLUME

Locks a volume.

FSCTL_QUERY_FILE_SYSTEM_RECOGNITION

Queries for file system recognition information on a volume.

FSCTL_READ_FROM_PLEX

Reads from the specified plex.

FSCTL_SHRINK_VOLUME

Signals that the volume is to be prepared to perform the shrink operation, the shrink operation is to be committed, or the shrink operation is to be terminated.

FSCTL_UNLOCK_VOLUME

Unlocks a volume.

IOCTL_VOLUME_GET_GPT_ATTRIBUTES

Retrieves attributes associated with a storage volume.

IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS

Retrieves the physical location of the specified volume on one or more disks.

IOCTL_VOLUME_IS_CLUSTERED

Determines whether a volume is clustered.

IOCTL_VOLUME_OFFLINE

Takes a volume offline.

IOCTL_VOLUME_ONLINE

Brings a volume online.

 

The following control codes are used with change journals.

 

Value

Meaning

FSCTL_CREATE_USN_JOURNAL

Creates a change journal stream on a target volume or modifies an existing change journal stream.

FSCTL_DELETE_USN_JOURNAL

Deletes a change journal on a volume or awaits notification of deletion of a change journal.

FSCTL_ENUM_USN_DATA

Creates an enumeration that lists the change journal entries between two specified boundaries.

FSCTL_MARK_HANDLE

Marks a specified file or directory and its change journal record with information about changes to that file or directory.

FSCTL_QUERY_USN_JOURNAL

Queries for information on the current change journal, its records, and its capacity.

FSCTL_READ_FILE_USN_DATA

Retrieves the change-journal information for the specified file or directory.

FSCTL_READ_USN_JOURNAL

Returns to the calling process the set of change journal records between two specified USN values.

FSCTL_WRITE_USN_CLOSE_RECORD

Generates a record in the change journal stream for the input file. This record will have the USN_REASON_CLOSE flag.

 

The following are defragmentation control codes.

 

Value

Meaning

FSCTL_GET_RETRIEVAL_POINTER_BASE

Returns the sector offset to the first logical cluster number of the file system relative to the start of the volume.

FSCTL_GET_RETRIEVAL_POINTERS

Gets information about the cluster use of a file.

FSCTL_GET_VOLUME_BITMAP

Gets a bitmap of cluster allocation.

FSCTL_MOVE_FILE

Moves all or part of a file from one set of clusters to another within a volume.

 

Volume Management Structures

 

The following structures are used in volume management.

 

Structure

Meaning

BOOT_AREA_INFO

Contains the output for the FSCTL_GET_BOOT_AREA_INFO control code.

CREATE_USN_JOURNAL_DATA

Contains information that describes a change journal.

DELETE_USN_JOURNAL_DATA

Contains information on the deletion of an NTFS file system change journal using the FSCTL_DELETE_USN_JOURNAL control code.

FILE_SYSTEM_RECOGNITION_INFORMATION

Contains file system recognition information retrieved by the FSCTL_QUERY_FILE_SYSTEM_RECOGNITION control code.

FILE_SYSTEM_RECOGNITION_STRUCTURE

Contains the on-disk file system recognition information stored in the volume's boot sector (logical disk sector zero).

This is an internally-defined data structure not available in a public header and is provided here for file system developers who want to take advantage of file system recognition.

MARK_HANDLE_INFO

Contains information that is used to mark a specified file or directory, and its change journal record with data about changes. It is used by the FSCTL_MARK_HANDLE control code.

MOVE_FILE_DATA

Contains input data for the FSCTL_MOVE_FILE control code.

MFT_ENUM_DATA

Contains information defining the boundaries for and starting place of an enumeration of change journal records. It is used by the FSCTL_ENUM_USN_DATA control code.

NTFS_VOLUME_DATA_BUFFER

Represents volume data. This structure is passed to the FSCTL_GET_NTFS_VOLUME_DATA control code.

PLEX_READ_DATA_REQUEST

Indicates the range of the read operation to perform and the plex from which to read.

READ_USN_JOURNAL_DATA

Contains information defining a set of change journal records to return to the calling process. It is used by the FSCTL_QUERY_USN_JOURNAL and FSCTL_READ_USN_JOURNAL control codes.

RETRIEVAL_POINTER_BASE

Contains the output for the FSCTL_GET_RETRIEVAL_POINTER_BASE control code.

RETRIEVAL_POINTERS_BUFFER

Contains the output for the FSCTL_GET_RETRIEVAL_POINTERS control code.

SHRINK_VOLUME_INFORMATION

Specifies the volume shrink operation to perform.

STARTING_LCN_INPUT_BUFFER

Contains the starting LCN to the FSCTL_GET_VOLUME_BITMAP control code.

STARTING_VCN_INPUT_BUFFER

Contains the starting VCN to the FSCTL_GET_RETRIEVAL_POINTERS control code.

USN_JOURNAL_DATA

Represents a change journal, its records, and its capacity. This structure is the output buffer for the FSCTL_QUERY_USN_JOURNAL control code.

USN_RECORD

Contains the information for a change journal version 2.0 record. Applications should not attempt to work with change journal versions earlier than 2.0.

VOLUME_BITMAP_BUFFER

Represents the occupied and available clusters on a disk. This structure is the output buffer for the FSCTL_GET_VOLUME_BITMAP control code.

VOLUME_DISK_EXTENTS

Represents a physical location on a disk. It is the output buffer for the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS control code.

VOLUME_GET_GPT_ATTRIBUTES_INFORMATION

Contains volume attributes retrieved with the IOCTL_VOLUME_GET_GPT_ATTRIBUTES control code.

 

More related references:

 

  1. Basic Disks and Volumes Technical Reference

  2. Dynamic Disks and Volumes Technical Reference

  3. NTFS Technical Reference

 

 

 

  < Windows Volume 26 | Win32 Programming Index | Windows Volume Index | Windows Disk APIs Programming >