layout.h revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
* layout.h - Ntfs on-disk layout structures. Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2005 Anton Altaparmakov
* Copyright (c) 2005-2007 Yura Pakhuchiy
*
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _NTFS_LAYOUT_H
#define _NTFS_LAYOUT_H
#include "types.h"
#include "endians.h"
#include "support.h"
/* The NTFS oem_id "NTFS " */
/*
* Location of boot sector on partition:
* The standard NTFS_BOOT_SECTOR is on sector 0 of the partition.
* On NT4 and above there is one backup copy of the boot sector to
* be found on the last sector of the partition (not normally accessible
* from within Windows as the boot sector contained number of sectors
* value is one less than the actual value!).
* On versions of NT 3.51 and earlier, the backup copy was located at
* number of sectors/2 (integer divide), i.e. in the middle of the volume.
*/
/**
* struct BIOS_PARAMETER_BLOCK - BIOS parameter block (BPB) structure.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
relative to the disk in sectors.
Required to boot Windows. */
/* sizeof() = 25 (0x19) bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* struct NTFS_BOOT_SECTOR - NTFS boot sector structure.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
maximum volume size of 2^63 sectors.
Assuming standard sector size of 512
bytes, the maximum byte size is
approx. 4.7x10^21 bytes. (-; */
0xaa55 in little endian. */
/* sizeof() = 512 (0x200) bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* enum NTFS_RECORD_TYPES -
*
* Magic identifiers present at the beginning of all ntfs record containing
* records (like mft records for example).
*/
typedef enum {
/* Found in $MFT/$DATA. */
/* Found in $LogFile/$DATA. */
/* Found in $LogFile/$DATA. (May be found in $MFT/$DATA, also?) */
/* Found in all ntfs record containing records. */
transfer was detected. */
/*
* Found in $LogFile/$DATA when a page is full or 0xff bytes and is
* thus not initialized. User has to initialize the page before using
* it.
*/
to be initialized before
it can be used. */
/*
* Generic magic comparison macros. Finally found a use for the ## preprocessor
* operator! (-8
*/
{
}
{
}
/*
* Specialised magic comparison macros for the NTFS_RECORD_TYPES defined above.
*/
#define ntfs_is_mft_record(x) ( ntfs_is_file_record(x) )
#define ntfs_is_mft_recordp(p) ( ntfs_is_file_recordp(p) )
#define NTFS_BLOCK_SIZE 512
#define NTFS_BLOCK_SIZE_BITS 9
/**
* struct NTFS_RECORD -
*
* The Update Sequence Array (USA) is an array of the le16 values which belong
* to the end of each sector protected by the update sequence record in which
* this array is contained. Note that the first entry is the Update Sequence
* Number (USN), a cyclic counter of how many times the protected record has
* been written to disk. The values 0 and -1 (ie. 0xffff) are not used. All
* last le16's of each sector have to be equal to the USN (during reading) or
* are set to it (during writing). If they are not, an incomplete multi sector
* transfer has occurred when the data was written.
* The maximum size for the update sequence array is fixed to:
* maximum size = usa_ofs + (usa_count * 2) = 510 bytes
* The 510 bytes comes from the fact that the last le16 in the array has to
* (obviously) finish before the last le16 of the first 512-byte sector.
* This formula can be used as a consistency check in that usa_ofs +
* (usa_count * 2) has to be less than or equal to 510.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
from the start of the ntfs record. */
including the Update Sequence Number (USN),
thus the number of fixups is the usa_count
minus 1. */
#ifdef __sun
#pragma pack()
#endif
/**
* enum NTFS_SYSTEM_FILES - System files mft record numbers.
*
* All these files are always marked as used in the bitmap attribute of the
* mft; presumably in order to avoid accidental allocation for random other
* mft records. Also, the sequence number for each of the system files is
* always equal to their mft record number and it is never modified.
*/
typedef enum {
FILE_MFT = 0, /* Master file table (mft). Data attribute
contains the entries and bitmap attribute
records which ones are in use (bit==1). */
in data attribute. If cluster size > 4kiB,
copy of first N mft records, with
N = cluster_size / mft_record_size. */
attribute (flags and ntfs version). Windows
refers to this file as volume DASD (Direct
Access Storage Device). */
attribute. */
data attribute. */
attribute. */
data attribute. */
and two indexes into the descriptors.
Appeared in Windows 2000. Before that, this
file was named $Quota but was unused. */
characters in data attribute. */
$ObjId, $Quota, $Reparse and $UsnJrnl). This
is new to NTFS 3.0. */
FILE_reserved13 = 13,
FILE_reserved14 = 14,
FILE_reserved15 = 15,
whether to allow opening a file or not. */
/**
* enum MFT_RECORD_FLAGS -
*
* These are the so far known MFT_RECORD_* flags (16-bit) which contain
* information about the mft record in which they are present.
*
* MFT_RECORD_IS_4 exists on all $Extend sub-files.
* It seems that it marks it is a metadata file with MFT record >24, however,
* it is unknown if it is limited to metadata files only.
*
* MFT_RECORD_IS_VIEW_INDEX exists on every metafile with a non directory
* index, that means an INDEX_ROOT and an INDEX_ALLOCATION with a name other
* than "$I30". It is unknown if it is limited to metadata files only.
*/
#ifdef __sun
typedef uint16_t MFT_RECORD_FLAGS;
#else /* not __sun */
typedef enum {
/* Just to make flags 16-bit. */
#endif /* __sun */
/*
* mft references (aka file references or file record segment references) are
* used whenever a structure needs to refer to a record in the mft.
*
* A reference consists of a 48-bit index into the mft and a 16-bit sequence
* number used to detect stale references.
*
* For error reporting purposes we treat the 48-bit index as a signed quantity.
*
* The sequence number is a circular counter (skipping 0) describing how many
* times the referenced mft record has been (re)used. This has to match the
* sequence number of the mft record being referenced, otherwise the reference
* is considered stale and removed (FIXME: only ntfsck or the driver itself?).
*
* If the sequence number is zero it is assumed that no sequence number
* consistency checking should be performed.
*
* FIXME: Since inodes are 32-bit as of now, the driver needs to always check
* for high_part being 0 and if not either BUG(), cause a panic() or handle
* the situation in some other way. This shouldn't be a problem as a volume has
* to become HUGE in order to need more than 32-bits worth of mft records.
* Assuming the standard mft record size of 1kb only the records (never mind
* the non-resident attributes, etc.) would require 4Tb of space on their own
* for the first 32 bits worth of records. This is only if some strange person
* doesn't decide to foul play and make the mft sparse which would be a really
* horrible thing to do as it would trash our current driver implementation. )-:
* Do I hear screams "we want 64-bit inodes!" ?!? (-;
*
* FIXME: The mft zone is defined as the first 12% of the volume. This space is
* reserved so that the mft can grow contiguously and hence doesn't become
* fragmented. Volume free space includes the empty part of the mft zone and
* when the volume's free 88% are used up, the mft zone is shrunk by a factor
* repeated every time there is no more free space except for the mft zone until
* there really is no more free space.
*/
/*
* Typedef the MFT_REF as a 64-bit value for easier handling.
* Also define two unpacking macros to get to the reference (MREF) and
* sequence number (MSEQNO) respectively.
* The _LE versions are to be applied on little endian MFT_REFs.
* Note: The _LE versions will return a CPU endian formatted value!
*/
#define MFT_REF_MASK_CPU 0x0000ffffffffffffULL
((MFT_REF)(m) & MFT_REF_MASK_CPU)))
((MFT_REF)(m) & MFT_REF_MASK_CPU))))
/**
* struct MFT_RECORD - An MFT record layout (NTFS 3.1+)
*
* The mft record header present at the beginning of every record in the mft.
* This is followed by a sequence of variable length attribute records which
* is terminated by an attribute of type AT_END which is a truncated attribute
* in that it only consists of the attribute type code AT_END and none of the
* other members of the attribute structure are present.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*Ofs*/
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
Changed every time the record is modified. */
reused. (See description for MFT_REF
above.) NOTE: The increment (skipping zero)
is done when the file is deleted. NOTE: If
this is zero it is left zero. */
directory entries referencing this record.
NOTE: Only used in mft base records.
NOTE: When deleting a directory entry we
check the link_count and if it is 1 we
delete the file. Otherwise we delete the
FILE_NAME_ATTR being referenced by the
directory entry from the mft record and
decrement the link_count.
FIXME: Careful with Win32 + DOS names! */
mft record from the start of the mft record.
NOTE: Must be aligned to 8-byte boundary. */
is deleted, the MFT_RECORD_IN_USE flag is
set to zero. */
NOTE: Must be aligned to 8-byte boundary. */
record. This should be equal to the mft
record size. */
When it is not zero it is a mft reference
pointing to the base mft record to which
this record belongs (this is then used to
locate the attribute list attribute present
in the base record which describes this
extension record and hence might need
modification when the extension record
itself is modified, also locating the
attribute list also means finding the other
potential extents, belonging to the non-base
mft record). */
assigned to the next attribute added to this
mft record. NOTE: Incremented each time
after it is used. NOTE: Every time the mft
record is reused this number is set to zero.
NOTE: The first instance number is always 0.
*/
/* The below fields are specific to NTFS 3.1+ (Windows XP and above): */
/* sizeof() = 48 bytes */
/*
* When (re)using the mft record, we place the update sequence array at this
* offset, i.e. before we start with the attributes. This also makes sense,
* otherwise we could run into problems with the update sequence array
* containing in itself the last two bytes of a sector which would mean that
* multi sector transfer protection wouldn't work. As you can't protect data
* by overwriting it since you then can't get it back...
* When reading we obviously use the data from the ntfs record header.
*/
#ifdef __sun
#pragma pack()
#endif
/**
* struct MFT_RECORD_OLD - An MFT record layout (NTFS <=3.0)
*
* This is the version without the NTFS 3.1+ specific fields.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*Ofs*/
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
Changed every time the record is modified. */
reused. (See description for MFT_REF
above.) NOTE: The increment (skipping zero)
is done when the file is deleted. NOTE: If
this is zero it is left zero. */
directory entries referencing this record.
NOTE: Only used in mft base records.
NOTE: When deleting a directory entry we
check the link_count and if it is 1 we
delete the file. Otherwise we delete the
FILE_NAME_ATTR being referenced by the
directory entry from the mft record and
decrement the link_count.
FIXME: Careful with Win32 + DOS names! */
mft record from the start of the mft record.
NOTE: Must be aligned to 8-byte boundary. */
is deleted, the MFT_RECORD_IN_USE flag is
set to zero. */
NOTE: Must be aligned to 8-byte boundary. */
record. This should be equal to the mft
record size. */
When it is not zero it is a mft reference
pointing to the base mft record to which
this record belongs (this is then used to
locate the attribute list attribute present
in the base record which describes this
extension record and hence might need
modification when the extension record
itself is modified, also locating the
attribute list also means finding the other
potential extents, belonging to the non-base
mft record). */
assigned to the next attribute added to this
mft record. NOTE: Incremented each time
after it is used. NOTE: Every time the mft
record is reused this number is set to zero.
NOTE: The first instance number is always 0.
*/
/* sizeof() = 42 bytes */
/*
* When (re)using the mft record, we place the update sequence array at this
* offset, i.e. before we start with the attributes. This also makes sense,
* otherwise we could run into problems with the update sequence array
* containing in itself the last two bytes of a sector which would mean that
* multi sector transfer protection wouldn't work. As you can't protect data
* by overwriting it since you then can't get it back...
* When reading we obviously use the data from the ntfs record header.
*/
#ifdef __sun
#pragma pack()
#endif
/**
* enum ATTR_TYPES - System defined attributes (32-bit).
*
* Each attribute type has a corresponding attribute name (Unicode string of
* maximum 64 character length) as described by the attribute definitions
* present in the data attribute of the $AttrDef system file.
*
* On NTFS 3.0 volumes the names are just as the types are named in the below
* enum exchanging AT_ for the dollar sign ($). If that isn't a revealing
* choice of symbol... (-;
*/
typedef enum {
AT_UNUSED = const_cpu_to_le32( 0),
} ATTR_TYPES;
/**
* (32-bit).
*
* COLLATION_UNICODE_STRING - Collate Unicode strings by comparing their binary
* Unicode values, except that when a character can be uppercased, the
* upper case value collates before the lower case one.
* COLLATION_FILE_NAME - Collate file names as Unicode strings. The collation
* is done very much like COLLATION_UNICODE_STRING. In fact I have no idea
* what the difference is. Perhaps the difference is that file names
* would treat some special characters in an odd way (see
* for what I mean but COLLATION_UNICODE_STRING would not give any special
* treatment to any characters at all, but this is speculation.
* COLLATION_NTOFS_ULONG - Sorting is done according to ascending le32 key
* values. E.g. used for $SII index in FILE_Secure, which sorts by
* security_id (le32).
* COLLATION_NTOFS_SID - Sorting is done according to ascending SID values.
* E.g. used for $O index in FILE_Extend/$Quota.
* COLLATION_NTOFS_SECURITY_HASH - Sorting is done first by ascending hash
* values and second by ascending security_id values. E.g. used for $SDH
* index in FILE_Secure.
* COLLATION_NTOFS_ULONGS - Sorting is done according to a sequence of ascending
* le32 key values. E.g. used for $O index in FILE_Extend/$ObjId, which
* sorts by object_id (16-byte), by splitting up the object_id in four
* le32 values and using them as individual keys. E.g. take the following
* two security_ids, stored as follows on disk:
* 1st: a1 61 65 b7 65 7b d4 11 9e 3d 00 e0 81 10 42 59
* 2nd: 38 14 37 d2 d2 f3 d4 11 a5 21 c8 6b 79 b1 97 45
* To compare them, they are split into four le32 values each, like so:
* 1st: 0xb76561a1 0x11d47b65 0xe0003d9e 0x59421081
* 2nd: 0xd2371438 0x11d4f3d2 0x6bc821a5 0x4597b179
* Now, it is apparent why the 2nd object_id collates after the 1st: the
* first le32 value of the 1st object_id is less than the first le32 of
* the 2nd object_id. If the first le32 values of both object_ids were
* equal then the second le32 values would be compared, etc.
*/
typedef enum {
compare where the first byte is most
significant. */
as Unicode strings. */
strings by comparing their binary
Unicode values, except that when a
character can be uppercased, the upper
case value collates before the lower
case one. */
/**
* enum ATTR_DEF_FLAGS -
*
* The flags (32-bit) describing attribute properties in the attribute
* definition structure. FIXME: This information is based on Regis's
* information and, according to him, it is not certain and probably
* incomplete. The INDEXABLE flag is fairly certainly correct as only the file
* name attribute has this flag set and this is the only attribute indexed in
* NT4.
*/
typedef enum {
indexed. */
can be present multiple times in the
mft records of an inode. */
must contain at least one non-zero
byte. */
indexed and the attribute value must be
unique for the attribute type in all of
the mft records of an inode. */
named and the name must be unique for
the attribute type in all of the mft
records of an inode. */
resident. */
modifications to this attribute,
regardless of whether it is resident or
non-resident. Without this, only log
modifications if the attribute is
resident. */
/**
* struct ATTR_DEF -
*
* The data attribute of FILE_AttrDef contains a sequence of attribute
* definitions for the NTFS volume. With this, it is supposed to be safe for an
* older NTFS driver to mount a volume containing a newer NTFS version without
* damaging it (that's the theory. In practice it's: not damaging it too much).
* Entries are sorted by attribute type. The flags describe whether the
* attribute can be resident/non-resident and possibly other things, but the
* actual bits are unknown.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*hex ofs*/
terminated. */
FIXME: What does it mean? (AIA) */
/* sizeof() = 0xa0 or 160 bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* enum ATTR_FLAGS - Attribute flags (16-bit).
*/
#ifdef __sun
typedef uint16_t ATTR_FLAGS;
#else /* not __sun */
typedef enum {
method mask. Also, first
illegal value. */
#endif /* __sun */
/*
* Attribute compression.
*
* Only the data attribute is ever compressed in the current ntfs driver in
* Windows. Further, compression is only applied when the data attribute is
* non-resident. Finally, to use compression, the maximum allowed cluster size
* on a volume is 4kib.
*
* The compression method is based on independently compressing blocks of X
* clusters, where X is determined from the compression_unit value found in the
* non-resident attribute record header (more precisely: X = 2^compression_unit
* clusters). On Windows NT/2k, X always is 16 clusters (compression_unit = 4).
*
* There are three different cases of how a compression block of X clusters
* can be stored:
*
* 1) The data in the block is all zero (a sparse block):
* This is stored as a sparse block in the runlist, i.e. the runlist
* entry has length = X and lcn = -1. The mapping pairs array actually
* uses a delta_lcn value length of 0, i.e. delta_lcn is not present at
* all, which is then interpreted by the driver as lcn = -1.
* NOTE: Even uncompressed files can be sparse on NTFS 3.0 volumes, then
* the same principles apply as above, except that the length is not
* restricted to being any particular value.
*
* 2) The data in the block is not compressed:
* This happens when compression doesn't reduce the size of the block
* in clusters. I.e. if compression has a small effect so that the
* compressed data still occupies X clusters, then the uncompressed data
* is stored in the block.
* This case is recognised by the fact that the runlist entry has
* length = X and lcn >= 0. The mapping pairs array stores this as
* normal with a run length of X and some specific delta_lcn, i.e.
* delta_lcn has to be present.
*
* 3) The data in the block is compressed:
* The common case. This case is recognised by the fact that the run
* list entry has length L < X and lcn >= 0. The mapping pairs array
* stores this as normal with a run length of X and some specific
* delta_lcn, i.e. delta_lcn has to be present. This runlist entry is
* immediately followed by a sparse entry with length = X - L and
* lcn = -1. The latter entry is to make up the vcn counting to the
* full compression block size X.
*
* In fact, life is more complicated because adjacent entries of the same type
* can be coalesced. This means that one has to keep track of the number of
* clusters handled and work on a basis of X clusters at a time being one
* block. An example: if length L > X this means that this particular runlist
* entry contains a block of length X and part of one or more blocks of length
* L - X. Another example: if length L < X, this does not necessarily mean that
* the block is compressed as it might be that the lcn changes inside the block
* and hence the following runlist entry describes the continuation of the
* potentially compressed block. The block would be compressed if the
* following runlist entry describes at least X - L sparse clusters, thus
* making up the compression block length as described in point 3 above. (Of
* course, there can be several runlist entries with small lengths so that the
* sparse entry does not follow the first data containing entry with
* length < X.)
*
* NOTE: At the end of the compressed attribute value, there most likely is not
* just the right amount of data to make up a compression block, thus this data
* is not even attempted to be compressed. It is just stored as is, unless
* the number of clusters it occupies is reduced when compressed in which case
* it is stored as a compressed compression block, complete with sparse
* clusters at the end.
*/
/**
* enum RESIDENT_ATTR_FLAGS - Flags of resident attributes (8-bit).
*/
#ifdef __sun
typedef uint8_t RESIDENT_ATTR_FLAGS;
#define RESIDENT_ATTR_IS_INDEXED (0x01)
#else /* not __sun */
typedef enum {
(has implications for deleting and
modifying the attribute). */
#endif /* __sun */
/**
* struct ATTR_RECORD - Attribute record header.
*
* Always aligned to 8-byte boundary.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*Ofs*/
attribute (aligned to 8-byte boundary).
Used to get to the next attribute. */
If 1, attribute is non-resident. */
0 if unnamed. */
beginning of the name from the attribute
record. Note that the name is stored as a
Unicode string. When creating, place offset
just at the end of the record header. Then,
follow with attribute value or mapping pairs
array, resident and non-resident attributes
respectively, aligning to an 8-byte
boundary. */
number is unique within this mft record (see
above for more details). */
/* 16*/ union {
/* Resident attributes. */
struct {
value from the start of the
attribute record. When creating,
align to 8-byte boundary if we
have a name present as this might
not have a length of a multiple
of 8-bytes. */
boundary. */
resident_end) to get size of
a resident attribute. */
/* Non-resident attributes. */
struct {
for this portion of the attribute value or
0 if this is the only extent (usually the
case). - Only when an attribute list is used
does lowest_vcn != 0 ever occur. */
the attribute value. - Usually there is only one
portion, so this usually equals the attribute
value size in clusters minus 1. Can be -1 for
zero length files. Can be 0 for "single extent"
attributes. */
beginning of the structure to the mapping pairs
array which contains the mappings between the
VCNs and the logical cluster numbers (LCNs).
When creating, place this at the end of this
record header aligned to 8-byte boundary. */
as the log to the base 2 of the number of
clusters in a compression unit. 0 means not
compressed. (This effectively limits the
compression unit size to be a power of two
clusters.) WinNT4 only uses a value of 4. */
/* The sizes below are only used when lowest_vcn is zero, as otherwise it would
be difficult to keep them up-to-date.*/
allocated to hold the attribute value. Always
is a multiple of the cluster size. When a file
is compressed, this field is a multiple of the
compression block size (2^compression_unit) and
it represents the logically allocated space
rather than the actual on disk usage. For this
use the compressed_size (see below). */
value. Can be larger than allocated_size if
attribute value is compressed or sparse. */
portion of the attribute value. Usually equals
data_size. */
#ifdef __sun
/* 64 */
#define non_resident_end compressed_size
#else /* not __sun */
non_resident_end) to get
size of a non resident
attribute. */
#endif /* __sun */
/* sizeof(uncompressed attr) = 64*/
value after compression. Only present when
compressed. Always is a multiple of the
cluster size. Represents the actual amount of
disk space being used on the disk. */
/* 72 */ void *compressed_end[];
/* Use offsetof(ATTR_RECORD, compressed_end) to
get size of a compressed attribute. */
/* sizeof(compressed attr) = 72*/
} __attribute__((__packed__)) u;
#ifdef __sun
#pragma pack()
#endif
typedef ATTR_RECORD ATTR_REC;
/**
* enum FILE_ATTR_FLAGS - File attribute flags (32-bit).
*/
typedef enum {
/*
* These flags are only present in the STANDARD_INFORMATION attribute
* (in the field file_attributes).
*/
/* Old DOS valid. Unused in NT. = cpu_to_le32(0x00000008), */
/* FILE_ATTR_DIRECTORY is not considered valid in NT. It is reserved
for the DOS SUBDIRECTORY flag. */
/* FILE_ATTR_VALID_FLAGS masks out the old DOS VolId and the
FILE_ATTR_DEVICE and preserves everything else. This mask
is used to obtain all flags that are valid for reading. */
/* FILE_ATTR_VALID_SET_FLAGS masks out the old DOS VolId, the
FILE_ATTR_DEVICE, FILE_ATTR_DIRECTORY, FILE_ATTR_SPARSE_FILE,
FILE_ATTR_REPARSE_POINT, FILE_ATRE_COMPRESSED and FILE_ATTR_ENCRYPTED
and preserves the rest. This mask is used to to obtain all flags that
are valid for setting. */
/**
* FILE_ATTR_I30_INDEX_PRESENT - Is it a directory?
*
* This is a copy of the MFT_RECORD_IS_DIRECTORY bit from the mft
* record, telling us whether this is a directory or not, i.e. whether
* it has an index root attribute named "$I30" or not.
*
* This flag is only present in the FILE_NAME attribute (in the
* file_attributes field).
*/
/**
* FILE_ATTR_VIEW_INDEX_PRESENT - Does have a non-directory index?
*
* This is a copy of the MFT_RECORD_IS_VIEW_INDEX bit from the mft
* record, telling us whether this file has a view index present (eg.
* object id index, quota index, one of the security indexes and the
* reparse points index).
*
* This flag is only present in the $STANDARD_INFORMATION and
* $FILE_NAME attributes.
*/
/*
* NOTE on times in NTFS: All times are in MS standard time format, i.e. they
* are the number of 100-nanosecond intervals since 1st January 1601, 00:00:00
* universal coordinated time (UTC). (In Linux time starts 1st January 1970,
* 00:00:00 UTC and is stored as the number of 1-second intervals since then.)
*/
/**
* struct STANDARD_INFORMATION - Attribute: Standard information (0x10).
*
* NOTE: Always resident.
* NOTE: Present in all base file records on a volume.
* NOTE: There is conflicting information about the meaning of each of the time
* fields but the meaning as defined below has been verified to be
* correct by practical experimentation on Windows NT4 SP6a and is hence
* assumed to be the one and only correct interpretation.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*Ofs*/
a filename is changed(?). */
modified. */
modified. */
last accessed (obviously this is not
updated on read-only volumes). In
Windows this is only updated when
accessed if some time delta has
passed since the last update. Also,
last access times updates can be
disabled altogether for speed. */
/* 36*/ union {
/* NTFS 1.2 (and previous, presumably) */
struct {
boundary. */
/* sizeof() = 48 bytes */
/* NTFS 3.0 */
struct {
/*
* If a volume has been upgraded from a previous NTFS version, then these
* fields are present only if the file has been accessed since the upgrade.
* Recognize the difference by comparing the length of the resident attribute
* value. If it is 48, then the following fields are missing. If it is 72 then
* the fields are present. Maybe just check like this:
* if (resident.ValueLength < sizeof(STANDARD_INFORMATION)) {
* Assume NTFS 1.2- format.
* If (volume version is 3.0+)
* Upgrade attribute to NTFS 3.0 format.
* else
* Use NTFS 1.2- format for access.
* } else
* Use NTFS 3.0 format for access.
* Only problem is that it might be legal to set the length of the value to
* arbitrarily large values thus spoiling this check. - But chkdsk probably
* views that as a corruption, assuming that it behaves like this for all
* attributes.
*/
file. Zero if version numbering is disabled. */
Set to zero if maximum_versions is zero. */
class id index (?). */
the file. Translate via $Q index in FILE_Extend
/$Quota to the quota control entry for the user
owning the file. Zero if quotas are disabled. */
Translate via $SII index and $SDS data stream
in FILE_Secure to the security descriptor. */
the quota for all streams of the file. Note: Is
zero if quotas are disabled. */
of the file. This is a direct index into the
change (aka USN) journal file. It is zero if
the USN journal is disabled.
NOTE: To disable the journal need to delete
the journal file itself and to then walk the
whole mft and set all USN entries in all mft
records to zero! (This can take a while!)
The journal is FILE_Extend/$UsnJrnl. Win2k
will recreate the journal and initiate
logging if necessary when mounting the
partition. This, in contrast to disabling the
journal is a very fast process, so the user
won't even notice it. */
} __attribute__((__packed__)) u;
/* sizeof() = 72 bytes (NTFS 3.0) */
#ifdef __sun
#pragma pack()
#endif
/**
* struct ATTR_LIST_ENTRY - Attribute: Attribute list (0x20).
*
* - Can be either resident or non-resident.
* - Value consists of a sequence of variable length, 8-byte aligned,
* ATTR_LIST_ENTRY records.
* - The attribute list attribute contains one entry for each attribute of
* the file in which the list is located, except for the list attribute
* itself. The list is sorted: first by attribute type, second by attribute
* name (if present), third by instance number. The extents of one
* non-resident attribute (if present) immediately follow after the initial
* extent. They are ordered by lowest_vcn and have their instance set to zero.
* It is not allowed to have two attributes with all sorting keys equal.
* - Further restrictions:
* - If not resident, the vcn to lcn mapping array has to fit inside the
* base mft record.
* - The attribute list attribute value has a maximum size of 256kb. This
* is imposed by the Windows cache manager.
* - Attribute lists are only used when the attributes of mft record do not
* fit inside the mft record despite all attributes (that can be made
* non-resident) having been made non-resident. This can happen e.g. when:
* - File has a large number of hard links (lots of file name
* attributes present).
* - The mapping pairs array of some non-resident attribute becomes so
* large due to fragmentation that it overflows the mft record.
* - The security descriptor is very complex (not applicable to
* NTFS 3.0 volumes).
* - There are many named streams.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*Ofs*/
attribute or 0 if unnamed. */
(always set this to where the name would
start even if unnamed). */
of the attribute value. This is usually 0. It
is non-zero for the case where one attribute
does not fit into one mft record and thus
several mft records are allocated to hold
this attribute. In the latter case, each mft
record holds one extent of the attribute and
there is one attribute list entry for each
extent. NOTE: This is DEFINITELY a signed
value! The windows driver uses cmp, followed
by jg when comparing this, thus it treats it
as signed. */
the ATTR_RECORD for this portion of the
attribute value. */
attribute being referenced; otherwise 0. */
name_offset to determine the location of the
name. */
/* sizeof() = 26 + (attribute_name_length * 2) bytes */
#ifdef __sun
#pragma pack()
#endif
/*
* The maximum allowed length for a file name.
*/
#define NTFS_MAX_NAME_LEN 255
/**
* enum FILE_NAME_TYPE_FLAGS - Possible namespaces for filenames in ntfs.
* (8-bit).
*/
#ifdef __sun
typedef uint8_t FILE_NAME_TYPE_FLAGS;
#define FILE_NAME_POSIX (0x00)
#define FILE_NAME_WIN32 (0x01)
#define FILE_NAME_DOS (0x02)
#define FILE_NAME_WIN32_AND_DOS (0x03)
#else /* not __sun */
typedef enum {
FILE_NAME_POSIX = 0x00,
/* This is the largest namespace. It is case sensitive and
allows all Unicode characters except for: '\0' and '/'.
Beware that in WinNT/2k files which eg have the same name
except for their case will not be distinguished by the
standard utilities and thus a "del filename" will delete
both "filename" and "fileName" without warning. */
FILE_NAME_WIN32 = 0x01,
/* The standard WinNT/2k NTFS long filenames. Case insensitive.
All Unicode chars except: '\0', '"', '*', '/', ':', '<',
'>', '?', '\' and '|'. Further, names cannot end with a '.'
or a space. */
FILE_NAME_DOS = 0x02,
/* The standard DOS filenames (8.3 format). Uppercase only.
All 8-bit characters greater space, except: '"', '*', '+',
',', '/', ':', ';', '<', '=', '>', '?' and '\'. */
FILE_NAME_WIN32_AND_DOS = 0x03,
/* 3 means that both the Win32 and the DOS filenames are
identical and hence have been saved in this single filename
record. */
#endif /* __sun */
/**
* struct FILE_NAME_ATTR - Attribute: Filename (0x30).
*
* NOTE: Always resident.
* NOTE: All fields, except the parent_directory, are only updated when the
* filename is changed. Until then, they just become out of sync with
* reality and the more up to date values are present in the standard
* information attribute.
* NOTE: There is conflicting information about the meaning of each of the time
* fields but the meaning as defined below has been verified to be
* correct by practical experimentation on Windows NT4 SP6a and is hence
* assumed to be the one and only correct interpretation.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/*hex ofs*/
referenced from. */
modified. */
modified. */
accessed. */
for the data attribute. So for
normal $DATA, this is the
allocated_size from the unnamed
$DATA attribute and for compressed
compressed_size from the unnamed
$DATA attribute. NOTE: This is a
multiple of the cluster size. */
attribute. */
/* 3c*/ union {
/* 3c*/ struct {
pack the extended attributes
(EAs), if such are present.*/
} __attribute__((__packed__)) s;
present only in reparse
points and only if there are
no EAs. */
} __attribute__((__packed__)) u;
(Unicode) characters. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct GUID - GUID structures store globally unique identifiers (GUID).
*
* A GUID is a 128-bit value consisting of one group of eight hexadecimal
* digits, followed by three groups of four hexadecimal digits each, followed
* by one group of twelve hexadecimal digits. GUIDs are Microsoft's
* implementation of the distributed computing environment (DCE) universally
* unique identifier (UUID).
*
* Example of a GUID in string format:
* 1F010768-5A73-BC91-0010-A52216A7227B
* And the same in binary:
* 1F0107685A73BC910010A52216A7227B
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef union {
struct {
GUID. */
digits. */
digits. */
four hexadecimal digits. The remaining six
bytes are the final 12 hexadecimal digits. */
} __attribute__((__packed__)) s;
#ifdef __sun
#pragma pack()
#endif
/**
* struct OBJ_ID_INDEX_DATA - FILE_Extend/$ObjId contains an index named $O.
*
* This index contains all object_ids present on the volume as the index keys
* and the corresponding mft_record numbers as the index entry data parts.
*
* The data part (defined below) also contains three other object_ids:
* birth_volume_id - object_id of FILE_Volume on which the file was first
* created. Optional (i.e. can be zero).
* birth_object_id - object_id of file when it was first created. Usually
* equals the object_id. Optional (i.e. can be zero).
* domain_id - Reserved (always zero).
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
the index entry key. */
union {
struct {
} __attribute__((__packed__)) s;
} __attribute__((__packed__)) u;
#ifdef __sun
#pragma pack()
#endif
/**
* struct OBJECT_ID_ATTR - Attribute: Object id (NTFS 3.0+) (0x40).
*
* NOTE: Always resident.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
file.*/
/* The following fields are optional. The attribute value size is 16
bytes, i.e. sizeof(GUID), if these are not present at all. Note,
the entries can be present but one or more (or all) can be zero
meaning that that particular value(s) is(are) not defined. Note,
when the fields are missing here, it is well possible that they are
to be found within the $Extend/$ObjId system file indexed under the
above object_id. */
union {
struct {
the file was first created.*/
first created. */
} __attribute__((__packed__)) s;
} __attribute__((__packed__)) u;
#ifdef __sun
#pragma pack()
#endif
#if 0
/**
* enum IDENTIFIER_AUTHORITIES -
*
* The pre-defined IDENTIFIER_AUTHORITIES used as SID_IDENTIFIER_AUTHORITY in
* the SID structure (see below).
*/
typedef enum { /* SID string prefix. */
SECURITY_NULL_SID_AUTHORITY = {0, 0, 0, 0, 0, 0}, /* S-1-0 */
#endif
/**
* enum RELATIVE_IDENTIFIERS -
*
* These relative identifiers (RIDs) are used with the above identifier
* authorities to make up universal well-known SIDs.
*
* Note: The relative identifier (RID) refers to the portion of a SID, which
* identifies a user or group in relation to the authority that issued the SID.
* For example, the universal well-known SID Creator Owner ID (S-1-3-0) is
* made up of the identifier authority SECURITY_CREATOR_SID_AUTHORITY (3) and
* the relative identifier SECURITY_CREATOR_OWNER_RID (0).
*/
typedef enum { /* Identifier authority. */
SECURITY_NULL_RID = 0, /* S-1-0 */
SECURITY_WORLD_RID = 0, /* S-1-1 */
SECURITY_LOCAL_RID = 0, /* S-1-2 */
SECURITY_CREATOR_OWNER_RID = 0, /* S-1-3 */
SECURITY_DIALUP_RID = 1,
SECURITY_NETWORK_RID = 2,
SECURITY_BATCH_RID = 3,
SECURITY_SERVICE_RID = 6,
SECURITY_PROXY_RID = 8,
SECURITY_PRINCIPAL_SELF_RID = 0xa,
SECURITY_RESTRICTED_CODE_RID = 0xc,
SECURITY_TERMINAL_SERVER_RID = 0xd,
SECURITY_LOCAL_SYSTEM_RID = 0x12,
SECURITY_NT_NON_UNIQUE = 0x15,
SECURITY_BUILTIN_DOMAIN_RID = 0x20,
/*
* Well-known domain relative sub-authority values (RIDs).
*/
/* Users. */
DOMAIN_USER_RID_ADMIN = 0x1f4,
DOMAIN_USER_RID_GUEST = 0x1f5,
DOMAIN_USER_RID_KRBTGT = 0x1f6,
/* Groups. */
DOMAIN_GROUP_RID_ADMINS = 0x200,
DOMAIN_GROUP_RID_USERS = 0x201,
DOMAIN_GROUP_RID_GUESTS = 0x202,
DOMAIN_GROUP_RID_COMPUTERS = 0x203,
DOMAIN_GROUP_RID_CONTROLLERS = 0x204,
DOMAIN_GROUP_RID_CERT_ADMINS = 0x205,
DOMAIN_GROUP_RID_SCHEMA_ADMINS = 0x206,
DOMAIN_GROUP_RID_POLICY_ADMINS = 0x208,
/* Aliases. */
DOMAIN_ALIAS_RID_ADMINS = 0x220,
DOMAIN_ALIAS_RID_USERS = 0x221,
DOMAIN_ALIAS_RID_GUESTS = 0x222,
DOMAIN_ALIAS_RID_POWER_USERS = 0x223,
DOMAIN_ALIAS_RID_ACCOUNT_OPS = 0x224,
DOMAIN_ALIAS_RID_SYSTEM_OPS = 0x225,
DOMAIN_ALIAS_RID_PRINT_OPS = 0x226,
DOMAIN_ALIAS_RID_BACKUP_OPS = 0x227,
DOMAIN_ALIAS_RID_REPLICATOR = 0x228,
DOMAIN_ALIAS_RID_RAS_SERVERS = 0x229,
DOMAIN_ALIAS_RID_PREW2KCOMPACCESS = 0x22a,
/*
* The universal well-known SIDs:
*
* NULL_SID S-1-0-0
* WORLD_SID S-1-1-0
* LOCAL_SID S-1-2-0
* CREATOR_OWNER_SID S-1-3-0
* CREATOR_GROUP_SID S-1-3-1
* CREATOR_OWNER_SERVER_SID S-1-3-2
* CREATOR_GROUP_SERVER_SID S-1-3-3
*
* (Non-unique IDs) S-1-4
*
* NT well-known SIDs:
*
* NT_AUTHORITY_SID S-1-5
* DIALUP_SID S-1-5-1
*
* NETWORK_SID S-1-5-2
* BATCH_SID S-1-5-3
* INTERACTIVE_SID S-1-5-4
* SERVICE_SID S-1-5-6
* ANONYMOUS_LOGON_SID S-1-5-7 (aka null logon session)
* PROXY_SID S-1-5-8
* SERVER_LOGON_SID S-1-5-9 (aka domain controller account)
* SELF_SID S-1-5-10 (self RID)
* AUTHENTICATED_USER_SID S-1-5-11
* RESTRICTED_CODE_SID S-1-5-12 (running restricted code)
* TERMINAL_SERVER_SID S-1-5-13 (running on terminal server)
*
* (Logon IDs) S-1-5-5-X-Y
*
* (NT non-unique IDs) S-1-5-0x15-...
*
* (Built-in domain) S-1-5-0x20
*/
/**
* union SID_IDENTIFIER_AUTHORITY - A 48-bit value used in the SID structure
*
* NOTE: This is stored as a big endian number.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef union {
struct {
} __attribute__((__packed__)) s;
#ifdef __sun
#pragma pack()
#endif
/**
* struct SID -
*
* The SID structure is a variable-length structure used to uniquely identify
* users or groups. SID stands for security identifier.
*
* The standard textual representation of the SID is of the form:
* S-R-I-S-S...
* Where:
* - The first "S" is the literal character 'S' identifying the following
* digits as a SID.
* - R is the revision level of the SID expressed as a sequence of digits
* in decimal.
* - I is the 48-bit identifier_authority, expressed as digits in decimal,
* if I < 2^32, or hexadecimal prefixed by "0x", if I >= 2^32.
* - S... is one or more sub_authority values, expressed as digits in
* decimal.
*
* Example SID; the domain-relative SID of the local Administrators group on
* Windows NT/2k:
* S-1-5-32-544
* This translates to a SID with:
* revision = 1,
* sub_authority_count = 2,
* identifier_authority = {0,0,0,0,0,5}, // SECURITY_NT_AUTHORITY
* sub_authority[0] = 32, // SECURITY_BUILTIN_DOMAIN_RID
* sub_authority[1] = 544 // DOMAIN_ALIAS_RID_ADMINS
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/**
* enum SID_CONSTANTS - Current constants for SIDs.
*/
typedef enum {
a future revision. */
/**
* enum ACE_TYPES - The predefined ACE types (8-bit, see below).
*/
#ifdef __sun
#define ACCESS_ALLOWED_ACE_TYPE (0)
#define ACCESS_DENIED_ACE_TYPE (1)
#define SYSTEM_AUDIT_ACE_TYPE (2)
#else /* not __sun */
typedef enum {
/* The following are Win2k only. */
/* This one is for WinNT&2k. */
#endif /* __sun */
/**
* enum ACE_FLAGS - The ACE flags (8-bit) for audit and inheritance.
*
* SUCCESSFUL_ACCESS_ACE_FLAG is only used with system audit and alarm ACE
* types to indicate that a message is generated (in Windows!) for successful
* accesses.
*
* FAILED_ACCESS_ACE_FLAG is only used with system audit and alarm ACE types
* to indicate that a message is generated (in Windows!) for failed accesses.
*/
#ifdef __sun
#define OBJECT_INHERIT_ACE (0x01)
#define CONTAINER_INHERIT_ACE (0x02)
#define INHERIT_ONLY_ACE (0x08)
#else /* not __sun */
typedef enum {
/* The inheritance flags. */
OBJECT_INHERIT_ACE = 0x01,
CONTAINER_INHERIT_ACE = 0x02,
NO_PROPAGATE_INHERIT_ACE = 0x04,
INHERIT_ONLY_ACE = 0x08,
VALID_INHERIT_FLAGS = 0x1f,
/* The audit flags. */
SUCCESSFUL_ACCESS_ACE_FLAG = 0x40,
FAILED_ACCESS_ACE_FLAG = 0x80,
#endif /* __sun */
/**
* struct ACE_HEADER -
*
* An ACE is an access-control entry in an access-control list (ACL).
* An ACE defines access to an object for a specific user or group or defines
* the types of access that generate system-administration messages or alarms
* for a specific user or group. The user or group is identified by a security
* identifier (SID).
*
* Each ACE starts with an ACE_HEADER structure (aligned on 4-byte boundary),
* which specifies the type and size of the ACE. The format of the subsequent
* data depends on the ACE type.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/**
* enum ACCESS_MASK - The access mask (32-bit).
*
* Defines the access rights.
*/
typedef enum {
/*
* The specific rights (bits 0 to 15). Depend on the type of the
* object being secured by the ACE.
*/
/* Specific rights for files and directories are as follows: */
/* Right to read data from the file. (FILE) */
/* Right to list contents of a directory. (DIRECTORY) */
/* Right to write data to the file. (FILE) */
/* Right to create a file in the directory. (DIRECTORY) */
/* Right to append data to the file. (FILE) */
/* Right to create a subdirectory. (DIRECTORY) */
/* Right to execute a file. (FILE) */
/* Right to traverse the directory. (DIRECTORY) */
/*
* Right to delete a directory and all the files it contains (its
* children), even if the files are read-only. (DIRECTORY)
*/
/*
* The standard rights (bits 16 to 23). Are independent of the type of
* object being secured.
*/
/* Right to delete the object. */
/*
* Right to read the information in the object's security descriptor,
* not including the information in the SACL. I.e. right to read the
* security descriptor and owner.
*/
/* Right to modify the DACL in the object's security descriptor. */
/* Right to change the owner in the object's security descriptor. */
/*
* Right to use the object for synchronization. Enables a process to
* wait until the object is in the signalled state. Some object types
* do not support this access right.
*/
/*
* The following STANDARD_RIGHTS_* are combinations of the above for
* convenience and are defined by the Win32 API.
*/
/* These are currently defined to READ_CONTROL. */
/* Combines DELETE, READ_CONTROL, WRITE_DAC, and WRITE_OWNER access. */
/*
* Combines DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, and
* SYNCHRONIZE access.
*/
/*
* The access system ACL and maximum allowed access types (bits 24 to
* 25, bits 26 to 27 are reserved).
*/
/*
* The generic rights (bits 28 to 31). These map onto the standard and
* specific rights.
*/
/* Read, write, and execute access. */
/* Execute access. */
/*
* Write access. For files, this maps onto:
* FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA |
* FILE_WRITE_EA | STANDARD_RIGHTS_WRITE | SYNCHRONIZE
* For directories, the mapping has the same numerical value. See
* above for the descriptions of the rights granted.
*/
/*
* Read access. For files, this maps onto:
* FILE_READ_ATTRIBUTES | FILE_READ_DATA | FILE_READ_EA |
* STANDARD_RIGHTS_READ | SYNCHRONIZE
* For directories, the mapping has the same numerical value. See
* above for the descriptions of the rights granted.
*/
} ACCESS_MASK;
/**
* struct GENERIC_MAPPING -
*
* The generic mapping array. Used to denote the mapping of each generic
* access right to a specific access mask.
*
* FIXME: What exactly is this and what is it for? (AIA)
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/*
* The predefined ACE type structures are as defined below.
*/
/**
* struct ACCESS_DENIED_ACE -
*
* ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE, SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */
#ifdef __sun
#pragma pack()
#endif
/**
* enum OBJECT_ACE_FLAGS - The object ACE flags (32-bit).
*/
typedef enum {
/**
* struct ACCESS_ALLOWED_OBJECT_ACE -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0 ACE_HEADER; -- Unfolded here as gcc doesn't like unnamed structs. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct ACL - An ACL is an access-control list (ACL).
*
* An ACL starts with an ACL header structure, which specifies the size of
* the ACL and the number of ACEs it contains. The ACL header is followed by
* zero or more access control entries (ACEs). The ACL as well as each ACE
* are aligned on 4-byte boundaries.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
header, the ACEs and the remaining free space. */
/* sizeof() = 8 bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* enum ACL_CONSTANTS - Current constants for ACLs.
*/
typedef enum {
/* Current revision. */
ACL_REVISION = 2,
ACL_REVISION_DS = 4,
/* History of revisions. */
ACL_REVISION1 = 1,
MIN_ACL_REVISION = 2,
ACL_REVISION2 = 2,
ACL_REVISION3 = 3,
ACL_REVISION4 = 4,
MAX_ACL_REVISION = 4,
/**
* enum SECURITY_DESCRIPTOR_CONTROL -
*
* The security descriptor control flags (16-bit).
*
* SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
* SID pointed to by the Owner field was provided by a
* defaulting mechanism rather than explicitly provided by the
* original provider of the security descriptor. This may
* affect the treatment of the SID with respect to inheritance
* of an owner.
*
* SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
* SID in the Group field was provided by a defaulting mechanism
* rather than explicitly provided by the original provider of
* the security descriptor. This may affect the treatment of
* the SID with respect to inheritance of a primary group.
*
* SE_DACL_PRESENT - This boolean flag, when set, indicates that the
* security descriptor contains a discretionary ACL. If this
* flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
* null, then a null ACL is explicitly being specified.
*
* SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
* ACL pointed to by the Dacl field was provided by a defaulting
* mechanism rather than explicitly provided by the original
* provider of the security descriptor. This may affect the
* treatment of the ACL with respect to inheritance of an ACL.
* This flag is ignored if the DaclPresent flag is not set.
*
* SE_SACL_PRESENT - This boolean flag, when set, indicates that the
* security descriptor contains a system ACL pointed to by the
* Sacl field. If this flag is set and the Sacl field of the
* SECURITY_DESCRIPTOR is null, then an empty (but present)
* ACL is being specified.
*
* SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
* ACL pointed to by the Sacl field was provided by a defaulting
* mechanism rather than explicitly provided by the original
* provider of the security descriptor. This may affect the
* treatment of the ACL with respect to inheritance of an ACL.
* This flag is ignored if the SaclPresent flag is not set.
*
* SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
* security descriptor is in self-relative form. In this form,
* all fields of the security descriptor are contiguous in memory
* and all pointer fields are expressed as offsets from the
* beginning of the security descriptor.
*/
#ifdef __sun
typedef uint16_t SECURITY_DESCRIPTOR_CONTROL;
#else /* not __sun */
typedef enum {
#endif /* __sun */
/**
* struct SECURITY_DESCRIPTOR_RELATIVE -
*
* Self-relative security descriptor. Contains the owner and group SIDs as well
* as the sacl and dacl ACLs inside the security descriptor itself.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
the descriptor as well as the following fields. */
owner. If this is NULL, no owner SID is present in
the descriptor. */
primary group. If this is NULL, no primary group
SID is present in the descriptor. */
SE_SACL_PRESENT is set in the control field. If
SE_SACL_PRESENT is set but sacl is NULL, a NULL ACL
is specified. */
SE_DACL_PRESENT is set in the control field. If
SE_DACL_PRESENT is set but dacl is NULL, a NULL ACL
(unconditionally granting access) is specified. */
/* sizeof() = 0x14 bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* struct SECURITY_DESCRIPTOR - Absolute security descriptor.
*
* Does not contain the owner and group SIDs, nor the sacl and dacl ACLs inside
* the security descriptor. Instead, it contains pointers to these structures
* in memory. Obviously, absolute security descriptors are only useful for in
* memory representations of security descriptors.
*
* On disk, a self-relative security descriptor is used.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
the descriptor as well as the following fields. */
this is NULL, no owner SID is present in the
descriptor. */
group. If this is NULL, no primary group SID is
present in the descriptor. */
SE_SACL_PRESENT is set in the control field. If
SE_SACL_PRESENT is set but sacl is NULL, a NULL ACL
is specified. */
SE_DACL_PRESENT is set in the control field. If
SE_DACL_PRESENT is set but dacl is NULL, a NULL ACL
(unconditionally granting access) is specified. */
#ifdef __sun
#pragma pack()
#endif
/**
* enum SECURITY_DESCRIPTOR_CONSTANTS -
*
* Current constants for security descriptors.
*/
typedef enum {
/* Current revision. */
/* The sizes of both the absolute and relative security descriptors is
the same as pointers, at least on ia32 architecture are 32-bit. */
/*
* Attribute: Security descriptor (0x50).
*
* A standard self-relative security descriptor.
*
* NOTE: Can be resident or non-resident.
* NOTE: Not used in NTFS 3.0+, as security descriptors are stored centrally
* in FILE_Secure and the correct descriptor is found using the security_id
* from the standard information attribute.
*/
/*
* On NTFS 3.0+, all security descriptors are stored in FILE_Secure. Only one
* referenced instance of each unique security descriptor is stored.
*
* FILE_Secure contains no unnamed data attribute, i.e. it has zero length. It
* does, however, contain two indexes ($SDH and $SII) as well as a named data
* stream ($SDS).
*
* Every unique security descriptor is assigned a unique security identifier
* (security_id, not to be confused with a SID). The security_id is unique for
* the NTFS volume and is used as an index into the $SII index, which maps
* security_ids to the security descriptor's storage location within the $SDS
* data attribute. The $SII index is sorted by ascending security_id.
*
* A simple hash is computed from each security descriptor. This hash is used
* as an index into the $SDH index, which maps security descriptor hashes to
* the security descriptor's storage location within the $SDS data attribute.
* The $SDH index is sorted by security descriptor hash and is stored in a B+
* tree. When searching $SDH (with the intent of determining whether or not a
* new security descriptor is already present in the $SDS data stream), if a
* matching hash is found, but the security descriptors do not match, the
* search in the $SDH index is continued, searching for a next matching hash.
*
* When a precise match is found, the security_id corresponding to the security
* descriptor in the $SDS attribute is read from the found $SDH index entry and
* which the security descriptor is being applied. The $STANDARD_INFORMATION
* attribute is present in all base mft records (i.e. in all files and
* directories).
*
* If a match is not found, the security descriptor is assigned a new unique
* security_id and is added to the $SDS data attribute. Then, entries
* referencing the this security descriptor in the $SDS data attribute are
* added to the $SDH and $SII indexes.
*
* Note: Entries are never deleted from FILE_Secure, even if nothing
* references an entry any more.
*/
/**
* struct SECURITY_DESCRIPTOR_HEADER -
*
* This header precedes each security descriptor in the $SDS data stream.
* This is also the index entry data part of both the $SII and $SDH indexes.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/**
* struct SDH_INDEX_DATA -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
isn't counted in INDEX_ENTRY's data_length. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct SII_INDEX_DATA -
*/
typedef SECURITY_DESCRIPTOR_HEADER SII_INDEX_DATA;
/**
* struct SDS_ENTRY -
*
* The $SDS data stream contains the security descriptors, aligned on 16-byte
* boundaries, sorted by security_id in a B+ tree. Security descriptors cannot
* cross 256kib boundaries (this restriction is imposed by the Windows cache
* manager). Each security descriptor is contained in a SDS_ENTRY structure.
* Also, each security descriptor is stored twice in the $SDS stream with a
* fixed offset of 0x40000 bytes (256kib, the Windows cache manager's max size)
* between them; i.e. if a SDS_ENTRY specifies an offset of 0x51d0, then the
* the first copy of the security descriptor will be at offset 0x51d0 in the
* $SDS data stream and the second copy will be at offset 0x451d0.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0 SECURITY_DESCRIPTOR_HEADER; -- Unfolded here as gcc doesn't like
unnamed structs. */
descriptor. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct SII_INDEX_KEY - The index entry key used in the $SII index.
*
* The collation type is COLLATION_NTOFS_ULONG.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/**
* struct SDH_INDEX_KEY - The index entry key used in the $SDH index.
*
* The keys are sorted first by hash and then by security_id.
* The collation rule is COLLATION_NTOFS_SECURITY_HASH.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
#ifndef __sun
/**
* struct VOLUME_NAME - Attribute: Volume name (0x60).
*
* NOTE: Always resident.
* NOTE: Present only in FILE_Volume.
*/
typedef struct {
#endif
/**
* enum VOLUME_FLAGS - Possible flags for the volume (16-bit).
*
* WARNING: Setting VOLUME_MOUNTED_ON_NT4 on a Volume causes Windows Vista to
* fail to boot (it hangs on a black screen).
*/
#ifdef __sun
typedef uint16_t VOLUME_FLAGS;
#else /* not __sun */
typedef enum {
#endif /* __sun */
/**
* struct VOLUME_INFORMATION - Attribute: Volume information (0x70).
*
* NOTE: Always resident.
* NOTE: Present only in FILE_Volume.
* NOTE: Windows 2000 uses NTFS 3.0 while Windows NT4 service pack 6a uses
* NTFS 1.2. I haven't personally seen other values yet.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
#ifndef __sun
/**
* struct DATA_ATTR - Attribute: Data attribute (0x80).
*
* NOTE: Can be resident or non-resident.
*
* Data contents of a file (i.e. the unnamed stream) or of a named stream.
*/
typedef struct {
#endif
/**
* enum INDEX_HEADER_FLAGS - Index header flags (8-bit).
*/
#ifdef __sun
typedef uint8_t INDEX_HEADER_FLAGS;
#define SMALL_INDEX (0)
#define LARGE_INDEX (1)
#define LEAF_NODE (0)
#define INDEX_NODE (1)
#define NODE_MASK (1)
#else /* not __sun */
typedef enum {
/* When index header is in an index root attribute: */
SMALL_INDEX = 0, /* The index is small enough to fit inside the
index root attribute and there is no index
allocation attribute present. */
attribute is present. */
/*
* When index header is in an index block, i.e. is part of index
* allocation attribute:
*/
LEAF_NODE = 0, /* This is a leaf node, i.e. there are no more
nodes branching off it. */
leaf node. */
#endif /* __sun */
/**
* struct INDEX_HEADER -
*
* This is the header for indexes, describing the INDEX_ENTRY records, which
* follow the INDEX_HEADER. Together the index header and the index entries
* make up a complete index.
*
* IMPORTANT NOTE: The offset, length and size structure members are counted
* relative to the start of the index header structure and not relative to the
* start of the index root or index allocation structures themselves.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
aligned to 8-byte boundary. */
i.e. bytes used from allocated
size, aligned to 8-byte boundary. */
multiple of 8 bytes. */
/* NOTE: For the index root attribute, the above two numbers are always
equal, as the attribute is resident and it is resized as needed. In
the case of the index allocation attribute the attribute is not
resident and hence the allocated_size is a fixed value and must
equal the index_block_size specified by the INDEX_ROOT attribute
corresponding to the INDEX_ALLOCATION attribute this INDEX_BLOCK
belongs to. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct INDEX_ROOT - Attribute: Index root (0x90).
*
* NOTE: Always resident.
*
* This is followed by a sequence of index entries (INDEX_ENTRY structures)
* as described by the index header.
*
* When a directory is small enough to fit inside the index root then this
* is the only attribute describing the directory. When the directory is too
* large to fit in the index root, on the other hand, two additional attributes
* are present: an index allocation attribute, containing sub-nodes of the B+
* directory tree (see below), and a bitmap attribute, describing which virtual
* cluster numbers (VCNs) in the index allocation attribute are in use by an
* index block.
*
* NOTE: The root directory (FILE_root) contains an entry for itself. Other
* directories do not contain entries for themselves, though.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
$FILE_NAME for directories, zero
for view indexes. No other values
allowed. */
index entries. If type is $FILE_NAME,
this must be COLLATION_FILE_NAME. */
the index allocation attribute). */
the index allocation attribute), when
an index block is >= than a cluster,
otherwise sectors per index block. */
following index entries. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct INDEX_BLOCK - Attribute: Index allocation (0xa0).
*
* NOTE: Always non-resident (doesn't make sense to be resident anyway!).
*
* This is an array of index blocks. Each index block starts with an
* INDEX_BLOCK structure containing an index header, followed by a sequence of
* index entries (INDEX_ENTRY structures), as described by the INDEX_HEADER.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0 NTFS_RECORD; -- Unfolded here as gcc doesn't like unnamed structs. */
modification of this index block. */
/* sizeof()= 40 (0x28) bytes */
/*
* When creating the index block, we place the update sequence array at this
* offset, i.e. before we start with the index entries. This also makes sense,
* otherwise we could run into problems with the update sequence array
* containing in itself the last two bytes of a sector which would mean that
* multi sector transfer protection wouldn't work. As you can't protect data
* by overwriting it since you then can't get it back...
* When reading use the data from the ntfs record header.
*/
#ifdef __sun
#pragma pack()
#endif
typedef INDEX_BLOCK INDEX_ALLOCATION;
/**
* struct REPARSE_INDEX_KEY -
*
* The system file FILE_Extend/$Reparse contains an index named $R listing
* all reparse points on the volume. The index entry keys are as defined
* below. Note, that there is no index data associated with the index entries.
*
* The index entries are sorted by the index key file_id. The collation rule is
* COLLATION_NTOFS_ULONGS. FIXME: Verify whether the reparse_tag is not the
* primary key / is not a key at all. (AIA)
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
reparse point attribute. */
#ifdef __sun
#pragma pack()
#endif
/**
* enum QUOTA_FLAGS - Quota flags (32-bit).
*/
typedef enum {
/* The user quota flags. Names explain meaning. */
/* Bit mask for user quota flags. */
/* These flags are only present in the quota defaults index entry,
i.e. in the entry where owner_id = QUOTA_DEFAULTS_ID. */
} QUOTA_FLAGS;
/**
* struct QUOTA_CONTROL_ENTRY -
*
* The system file FILE_Extend/$Quota contains two indexes $O and $Q. Quotas
* are on a per volume and per user basis.
*
* The $Q index contains one entry for each existing user_id on the volume. The
* i.e. the key is the owner_id. The user_id of the owner of a file, i.e. the
* owner_id, is found in the standard information attribute. The collation rule
* for $Q is COLLATION_NTOFS_ULONG.
*
* a quota on that volume. The index key holds the SID of the user_id the
* entry belongs to, i.e. the owner_id. The collation rule for $O is
* COLLATION_NTOFS_SID.
*
* The $O index entry data is the user_id of the user corresponding to the SID.
* This user_id is used as an index into $Q to find the quota control entry
* associated with the SID.
*
* The $Q index entry data is the quota control entry and is defined below.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* The below field is NOT present for the quota defaults entry. */
this quota entry. If this field is missing
then the INDEX_ENTRY is padded with zeros
to multiply of 8 which are not counted in
the data_length field. If the SID is present
then this structure is padded with zeros to
multiply of 8 and the padding is counted in
the INDEX_ENTRY's data_length. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct QUOTA_O_INDEX_DATA -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
counted in the INDEX_ENTRY's data_length.
This field shouldn't be really here. */
#ifdef __sun
#pragma pack()
#endif
/**
* enum PREDEFINED_OWNER_IDS - Predefined owner_id values (32-bit).
*/
typedef enum {
/**
* enum INDEX_ENTRY_FLAGS - Index entry flags (16-bit).
*/
#ifdef __sun
typedef uint16_t INDEX_ENTRY_FLAGS;
#else /* not __sun */
typedef enum {
sub-node, i.e. a reference to an index
block in form of a virtual cluster
number (see below). */
entry in an index block. The index
entry does not represent a file but it
can point to a sub-node. */
/* Just to force 16-bit width. */
#endif /* __sun */
/**
* struct INDEX_ENTRY_HEADER - This the index entry header (see below).
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0*/ union { /* Only valid when INDEX_ENTRY_END is not set. */
described by this index
entry. Used for directory
indexes. */
INDEX_ENTRY. Follows the
index key. */
} __attribute__((__packed__)) s;
} __attribute__((__packed__)) u;
8-bytes. */
index entry. It follows field reserved. Not
multiple of 8-bytes. */
/* sizeof() = 16 bytes */
#ifdef __sun
#pragma pack()
#endif
/**
* struct INDEX_ENTRY - This is an index entry.
*
* A sequence of such entries follows each INDEX_HEADER structure. Together
* they make up a complete index. The index follows either an index root
* attribute or an index allocation attribute.
*
* NOTE: Before NTFS 3.0 only filename attributes were indexed.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
/* 0 INDEX_ENTRY_HEADER; -- Unfolded here as gcc dislikes unnamed structs. */
union { /* Only valid when INDEX_ENTRY_END is not set. */
described by this index
entry. Used for directory
indexes. */
INDEX_ENTRY. Follows the
index key. */
} __attribute__((__packed__)) s;
} __attribute__((__packed__)) u;
8-bytes. */
index entry. It follows field reserved. Not
multiple of 8-bytes. */
/* 16*/ union { /* The key of the indexed attribute. NOTE: Only present
if INDEX_ENTRY_END bit in flags is not set. NOTE: On
NTFS versions before 3.0 the only valid key is the
FILE_NAME_ATTR. On NTFS 3.0+ the following
additional index keys are defined: */
object_id of the mft record found in
the data part of the index. */
FILE_Extend/$Reparse. */
SID of the owner of the user_id. */
user_id of the owner of the quota
control entry in the data part of
the index. */
/* The (optional) index data is inserted here when creating. */
/* VCN vcn; */ /* If INDEX_ENTRY_NODE bit in flags is set, the last
eight bytes of this index entry contain the virtual
cluster number of the index block that holds the
entries immediately preceding the current entry (the
vcn references the corresponding cluster in the data
of the non-resident index allocation attribute). If
the key_length is zero, then the vcn immediately
follows the INDEX_ENTRY_HEADER. Regardless of
key_length, the address of the 8-byte boundary
aligned vcn of INDEX_ENTRY{_HEADER} *ie is given by
(char*)ie + le16_to_cpu(ie->length) - sizeof(VCN),
where sizeof(VCN) can be hardcoded as 8 if wanted. */
#ifdef __sun
#pragma pack()
#endif
#ifndef __sun
/**
* struct BITMAP_ATTR - Attribute: Bitmap (0xb0).
*
* Contains an array of bits (aka a bitfield).
*
* When used in conjunction with the index allocation attribute, each bit
* corresponds to one index block within the index allocation attribute. Thus
* the number of bits in the bitmap * index block size / cluster size is the
* number of clusters in the index allocation attribute.
*/
typedef struct {
#endif
/**
* enum PREDEFINED_REPARSE_TAGS -
*
* The reparse point tag defines the type of the reparse point. It also
* includes several flags, which further describe the reparse point.
*
* The reparse point tag is an unsigned 32-bit value divided in three parts:
*
* 1. The least significant 16 bits (i.e. bits 0 to 15) specify the type of
* the reparse point.
* 2. The 13 bits after this (i.e. bits 16 to 28) are reserved for future use.
* 3. The most significant three bits are flags describing the reparse point.
* They are defined as follows:
* bit 29: Name surrogate bit. If set, the filename is an alias for
* another object in the system.
* bit 30: High-latency bit. If set, accessing the first byte of data will
* be slow. (E.g. the data is stored on a tape drive.)
* bit 31: Microsoft bit. If set, the tag is owned by Microsoft. User
* defined tags have to use zero here.
*/
typedef enum {
/**
* struct REPARSE_POINT - Attribute: Reparse point (0xc0).
*
* NOTE: Can be resident or non-resident.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
#ifdef __sun
#pragma pack()
#endif
/**
* struct EA_INFORMATION - Attribute: Extended attribute information (0xd0).
*
* NOTE: Always resident.
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
attributes. */
the NEED_EA bit set. */
the extended attributes when calling
ZwQueryEaFile() in Windows NT/2k. I.e. the
byte size of the unpacked extended
attributes. */
#ifdef __sun
#pragma pack()
#endif
#ifdef __sun
#define NEED_EA (0x80)
#else /* not __sun */
/**
* enum EA_FLAGS - Extended attribute flags (8-bit).
*/
typedef enum {
belongs cannot be interpreted without
understanding the associated extended
attributes. */
#endif /* __sun */
/**
* struct EA_ATTR - Attribute: Extended attribute (EA) (0xe0).
*
* Like the attribute list and the index buffer list, the EA attribute value is
* a sequence of EA_ATTR variable length records.
*
* FIXME: It appears weird that the EA name is not Unicode. Is it true?
* FIXME: It seems that name is always uppercased. Is it true?
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
attribute in bytes. */
#ifndef __sun
follows the name. */
#endif
#ifdef __sun
#pragma pack()
#endif
#ifndef __sun
/**
* struct PROPERTY_SET - Attribute: Property set (0xf0).
*
* Intended to support Native Structure Storage (NSS) - a feature removed from
* NTFS 3.0 during beta testing.
*/
typedef struct {
/* Irrelevant as feature unused. */
#endif
#ifndef __sun
/**
* struct LOGGED_UTILITY_STREAM - Attribute: Logged utility stream (0x100).
*
* NOTE: Can be resident or non-resident.
*
* Operations on this attribute are logged to the journal ($LogFile) like
* normal metadata changes.
*
* Used by the Encrypting File System (EFS). All encrypted files have this
* attribute with the name $EFS. See below for the relevant structures.
*/
typedef struct {
/* Can be anything the creator chooses. */
#endif
/*
* $EFS Data Structure:
*
* The following information is about the data structures that are contained
* inside a logged utility stream (0x100) with a name of "$EFS".
*
* The stream starts with an instance of EFS_ATTR_HEADER.
*
* Next, at offsets offset_to_ddf_array and offset_to_drf_array (unless any of
* them is 0) there is a EFS_DF_ARRAY_HEADER immediately followed by a sequence
* of multiple data decryption/recovery fields.
*
* Each data decryption/recovery field starts with a EFS_DF_HEADER and the next
* one (if it exists) can be found by adding EFS_DF_HEADER->df_length bytes to
* the offset of the beginning of the current EFS_DF_HEADER.
*
* The data decryption/recovery field contains an EFS_DF_CERTIFICATE_HEADER, a
* SID, an optional GUID, an optional container name, a non-optional user name,
* and the encrypted FEK.
*
* Note all the below are best guesses so may have mistakes/inaccuracies.
* Corrections/clarifications/additions are always welcome!
*
* Ntfs.sys takes an EFS value length of <= 0x54 or > 0x40000 to BSOD, i.e. it
* is invalid.
*/
/**
* struct EFS_ATTR_HEADER - "$EFS" header.
*
* The header of the Logged utility stream (0x100) attribute named "$EFS".
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
created with a call to UuidCreate() so is
unlikely to be an MD5 hash and is more
likely to be GUID of this encrytped file
or something like that. */
decryption fields (DDF), see below. Zero if
no DDFs are present. */
recovery fields (DRF), see below. Zero if
no DRFs are present. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct EFS_DF_ARRAY_HEADER -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
the array. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct EFS_DF_HEADER -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
field in bytes. */
encryption key (FEK). */
the data decryption/recovery field. */
#ifdef __sun
#pragma pack()
#endif
/**
* struct EFS_DF_CREDENTIAL_HEADER -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
of this structure. Zero if no sid is
present. */
1 = CryptoAPI container.
2 = Unexpected type.
3 = Certificate thumbprint.
other = Unknown type. */
union {
/* CryptoAPI container. */
struct {
the name of the container from start of this
structure (may not be zero). */
the name of the provider from start of this
structure (may not be zero). */
the public key blob from start of this
structure. */
public key blob. */
/* Certificate thumbprint. */
struct {
bytes of the header of the certificate
thumbprint. */
bytes to the header of the certificate
thumbprint from start of this structure. */
} __attribute__((__packed__)) u;
#ifdef __sun
#pragma pack()
#endif
/**
* struct EFS_DF_CERTIFICATE_THUMBPRINT_HEADER -
*/
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
container from start of this
structure or 0 if no name present. */
cryptographic provider from start of
this structure or 0 if no name
present. */
from start of this structure or 0 if
no user name present. (This is also
known as lpDisplayInformation.) */
#ifdef __sun
#pragma pack()
#endif
#ifdef __sun
typedef uint64_t INTX_FILE_TYPES;
#else /* not __sun */
typedef enum {
#endif /* __sun */
#ifdef __sun
#pragma pack(1)
#endif
typedef struct {
union {
/* For character and block devices. */
struct {
char device_end; /* Marker for offsetof(). */
} __attribute__((__packed__)) s;
/* For symbolic links. */
} __attribute__((__packed__)) u;
#ifdef __sun
#pragma pack()
#endif
#endif /* defined _NTFS_LAYOUT_H */