Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/include
In directory usw-pr-cvs1:/tmp/cvs-serv8494/include
Modified Files:
attrib.h
Log Message:
More work on attrib.h.
Index: attrib.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/attrib.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** attrib.h 2001/01/24 02:13:24 1.1
--- attrib.h 2001/01/26 02:36:10 1.2
***************
*** 92,117 ****
/*
- * The collation rules for sorting views/indexes/etc (32-bit).
- */
- typedef enum {
- COLLATION_BINARY = cpu_to_le32(0), /* Collate by binary compare
- where the first byte is
- most significant. */
- COLLATION_FILENAME = cpu_to_le32(1), /* Collate file names as
- Unicode strings. */
- COLLATION_UNICODE_STRING = cpu_to_le32(2), /* 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_NTOFS_ULONG = cpu_to_le32(16), /* ??? */
- COLLATION_NTOFS_SID = cpu_to_le32(17), /* ??? */
- COLLATION_NTOFS_SECURITY_HASH = cpu_to_le32(18), /* ??? */
- COLLATION_NTOFS_ULONGS = cpu_to_le32(19), /* ??? */
- } COLLATION_RULES;
-
- /*
* Attribute record header.
*/
--- 92,95 ----
***************
*** 256,260 ****
/*
! * Attribute: Standard information.
*
* NOTE: Always resident.
--- 234,238 ----
/*
! * Attribute: Standard information (0x10).
*
* NOTE: Always resident.
***************
*** 330,334 ****
/*
! * Attribute: Attribute list.
*
* The value of the attribute list attribute consists of a sequence of
--- 308,312 ----
/*
! * Attribute: Attribute list (0x20).
*
* The value of the attribute list attribute consists of a sequence of
***************
*** 418,424 ****
/*
! * Attribute: Filename.
*
! * NOTE: Always resident. (?)
*/
typedef struct {
--- 396,402 ----
/*
! * Attribute: Filename (0x30).
*
! * NOTE: Always resident.
*/
typedef struct {
***************
*** 481,485 ****
/*
! * Attribute: Object id.
*
* NOTE: Always resident.
--- 459,463 ----
/*
! * Attribute: Object id (0x40).
*
* NOTE: Always resident.
***************
*** 507,511 ****
/*
! * Attribute: Security descriptor.
*
* NOTE: Always resident.
--- 485,489 ----
/*
! * Attribute: Security descriptor (0x50).
*
* NOTE: Always resident.
***************
*** 517,521 ****
/*
! * Attribute: Volume name.
*
* NOTE: Always resident.
--- 495,499 ----
/*
! * Attribute: Volume name (0x60).
*
* NOTE: Always resident.
***************
*** 540,547 ****
/*
! * Attribute: Volume information.
*
* NOTE: Always resident.
* NOTE: Present only in FILE_$Volume.
*/
typedef struct {
--- 518,527 ----
/*
! * 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.
*/
typedef struct {
***************
*** 553,559 ****
/*
! * Attribute: Data attribute.
*
! * Data contents of a file (unnamed stream) or of a named stream.
*/
typedef struct {
--- 533,539 ----
/*
! * Attribute: Data attribute (0x80).
*
! * Data contents of a file (i.e. the unnamed stream) or of a named stream.
*/
typedef struct {
***************
*** 562,594 ****
/*
! * Index header flags.
*/
typedef enum {
! NO_INDEX_NODE = cpu_to_le32(0), /* Small directory, i.e. the whole
! directory fits inside the index
! root attribute and hence there is
! no index allocation attribute. */
! INDEX_NODE = cpu_to_le32(1), /* Large directory, i.e. it doesn't
! fit in the index root attribute
! and hence an index allocation
attribute is present. */
} INDEX_HEADER_FLAGS;
typedef enum {
! INDEX_ENTRY_NODE = cpu_to_le32(1), /* This entry references an index
! allocation attribute value. */
INDEX_ENTRY_END = cpu_to_le32(2), /* This signifies the last entry in
! an index buffer. */
! } INDEX_ROOT_INDEX_ENTRY_FLAGS;
/*
! * Attribute: Bitmap.
*/
typedef struct {
__u8 bitmap[0]; /* Array of bits. */
} __attribute__ ((__packed__)) BITMAP_ATTRIBUTE;
/*
! * Attribute: Reparse point.
*
* FIXME: Describe more about reparse points here including the flags in the
--- 542,687 ----
/*
! * Index header flags (32-bit).
*/
typedef enum {
! NO_INDEX_NODE = cpu_to_le32(0), /* Small index, i.e. the whole index
! fits inside the index root
! attribute and hence there is no
! index allocation attribute. */
! HAS_INDEX_NODE = cpu_to_le32(1), /* Large index, i.e. it doesn't fit
! in the index root attribute and
! hence an index allocation
attribute is present. */
} INDEX_HEADER_FLAGS;
+ /*
+ * 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.
+ */
+ typedef struct {
+ __u32 entries_offset; /* Byte offset to first INDEX_ENTRY. */
+ __u32 index_block_length; /* Data size of index block in bytes.
+ I.e. the number of bytes used from
+ the allocated_size. */
+ __u32 allocated_size; /* Byte size of the index block. */
+ INDEX_HEADER_FLAGS flags; /* Bit field of INDEX_HEADER_FLAGS. */
+ } __attribute__ ((__packed__)) INDEX_HEADER;
+
+ /*
+ * The collation rules for sorting views/indexes/etc (32-bit).
+ */
typedef enum {
! COLLATION_BINARY = cpu_to_le32(0), /* Collate by binary compare
! where the first byte is
! most significant. */
! COLLATION_FILENAME = cpu_to_le32(1), /* Collate file names as
! Unicode strings. */
! COLLATION_UNICODE_STRING = cpu_to_le32(2), /* 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_NTOFS_ULONG = cpu_to_le32(16), /* ??? */
! COLLATION_NTOFS_SID = cpu_to_le32(17), /* ??? */
! COLLATION_NTOFS_SECURITY_HASH = cpu_to_le32(18), /* ??? */
! COLLATION_NTOFS_ULONGS = cpu_to_le32(19), /* ??? */
! } COLLATION_RULE;
!
! /*
! * Attribute: Index root (0x90).
! *
! * This is followed by a sequence of index entries (INDEX_ENTRY structures)
! * as described by the index header.
! */
! typedef struct {
! ATTRIBUTE_TYPE type; /* Type of the indexed attribute. */
! COLLATION_RULE collation_rule; /* Collation rule used to sort the
! index entries. */
! __u32 bytes_per_index_block; /* Byte size of each index block (in
! the index allocation attribute). */
! __u32 clusters_per_index_block; /* Cluster size of each index block (in
! the index allocation attribute). */
! INDEX_HEADER index; /* Index header describing the
! following index entries. */
! } __attribute__ ((__packed__)) INDEX_ROOT;
!
! /*
! * Attribute: Index allocation (0xa0).
! *
! * This is an array of index blocks. Each index block starts with an
! * INDEX_BLOCK_HEADER structure containing an index header, followed by a
! * sequence of index entries (INDEX_ENTRY structures), as described by the
! * index header.
! */
! typedef struct {
! NTFS_RECORD_HEADER ntfs; /* Magic is "INDX". */
! __u64 index_block_vcn; /* Virtual cluster number of this
! index block. */
! INDEX_HEADER index; /* Index header describing the
! following index entries. */
! } __attribute__ ((__packed__)) INDEX_BLOCK_HEADER;
!
! /*
! * Index entry flags (32-bit).
! */
! typedef enum {
! INDEX_ENTRY_NODE = cpu_to_le32(1), /* This entry contains a reference
! to an index block in form of a
! virtual cluster number (see
! below). */
INDEX_ENTRY_END = cpu_to_le32(2), /* This signifies the last entry in
! an index block. */
! } INDEX_ENTRY_FLAGS;
/*
! * 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.
*/
typedef struct {
+ MFT_REFERENCE indexed_file; /* The mft reference of the file
+ described by this index entry. */
+ __u16 length; /* Byte size of this index entry. */
+ __u16 attribute_length; /* Byte size of indexed attribute. */
+ INDEX_ENTRY_FLAGS flags; /* Bit field of INDEX_ENTRY_* flags. */
+ // FILENAME_ATTRIBUTE name; /* The indexed attribute. On NTFS
+ // versions before 3.0 this is always
+ // a FILENAME_ATTRIBUTE. */
+ // __u64 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 is found in the index block
+ // header in the index allocation
+ // attribute). */
+ } __attribute__ ((__packed__)) INDEX_ENTRY;
+
+ /*
+ * Attribute: Bitmap (0xb0).
+ *
+ * Contains an array of bits (aka a bitfield).
+ */
+ typedef struct {
__u8 bitmap[0]; /* Array of bits. */
} __attribute__ ((__packed__)) BITMAP_ATTRIBUTE;
+ /*
+ * Reparse point tag:
+ *
+ * Most significant three bits mean:
+ * tag owned by Microsoft
+ * high latency on accessing file data
+ * filename is an alias for another object
+ */
+
/*
! * Attribute: Reparse point (0xc0).
*
* FIXME: Describe more about reparse points here including the flags in the
***************
*** 603,615 ****
/*
! * Attribute: Extended attribute (EA) information.
*/
typedef struct {
! __u16 packed_ea_length; /* Byte size of the buffer needed to
! pack the extended attributes. */
! __u16 need_ea_count; /* The number of extended attributes
! which have the NEED_EA bit set. */
! __u32 unpacked_ea_length; /* Byte size of the buffer required to
! query the extended attributes. */
} __attribute__ ((__packed__)) EA_INFORMATION;
--- 696,711 ----
/*
! * Attribute: Extended attribute (EA) information (0xd0).
*/
typedef struct {
! __u16 ea_length; /* Byte size of the packed extended
! attributes. */
! __u16 need_ea_count; /* The number of extended attributes which have
! the NEED_EA bit set. */
! __u32 ea_query_length; /* Byte size of the buffer required to query
! the extended attributes when calling
! ZwQueryEaFile() in Windows NT/2k. I.e. the
! byte size of the unpacked extended
! attributes. */
} __attribute__ ((__packed__)) EA_INFORMATION;
***************
*** 619,626 ****
/*
! * Attribute: Extended attribute (EA).
*
* Like the attribute list and the index buffer list, the EA attribute value is
* a sequence of EA_ATTRIBUTE variable length records.
*/
typedef struct {
--- 715,724 ----
/*
! * Attribute: Extended attribute (EA) (0xe0).
*
* Like the attribute list and the index buffer list, the EA attribute value is
* a sequence of EA_ATTRIBUTE variable length records.
+ *
+ * FIXME: It appears weird that the EA name is not unicode. Is it true?
*/
typedef struct {
***************
*** 628,665 ****
__u8 flags; /* Bit array of EA_FLAGS. */
__u8 ea_name_length; /* Length of the name of the extended
! attribute in characters.
! FIXME: Unicode? */
__u16 ea_value_length; /* Byte size of the EA's value. */
! __u8 ea_name[ea_name_length]; /* Name of the EA.
! FIXME: In Unicode? */
__u8 ea_data[ea_value_length]; /* The value of the EA. Immediately
follows the name. */
} __attribute__ ((__packed__)) EA_ATTRIBUTE;
- /*
- * Attribute: .
- */
- typedef struct {
- } __attribute__ ((__packed__)) INDEX_HEADER;
-
- /*
- * Attribute: .
- */
- typedef struct {
- } __attribute__ ((__packed__)) INDEX_ROOT;
-
/*
! * Attribute: .
*/
typedef struct {
! } __attribute__ ((__packed__)) INDEX_ALLOCATION;
/*
! * Attribute: .
*/
typedef struct {
! } __attribute__ ((__packed__)) INDEX_ENTRY;
! /* min macro used in attrib.c. */
#ifndef min
#define min(a,b) ((a) <= (b) ? (a) : (b))
--- 726,757 ----
__u8 flags; /* Bit array of EA_FLAGS. */
__u8 ea_name_length; /* Length of the name of the extended
! attribute in bytes. */
__u16 ea_value_length; /* Byte size of the EA's value. */
! __u8 ea_name[ea_name_length]; /* Name of the EA. */
__u8 ea_data[ea_value_length]; /* The value of the EA. Immediately
follows the name. */
} __attribute__ ((__packed__)) EA_ATTRIBUTE;
/*
! * Attribute: Property set (0xf0).
! *
! * Intended to support Native Structure Storage (NSS) - a feature removed from
! * NTFS 3.0 during beta testing.
*/
typedef struct {
! /* ??? */
! } __attribute__ ((__packed__)) PROPERTY_SET;
/*
! * Attribute: Logged utility stream (0x100).
! *
! * Operations on this attribute are logged to the journal ($LogFile) like
! * normal metadata changes. Used by the Encrypting File System (EFS).
*/
typedef struct {
! /* Can be anything the creator chooses. */
! } __attribute__ ((__packed__)) LOGGED_UTILITY_STREAM;
! /* min macro used in attrib.c */
#ifndef min
#define min(a,b) ((a) <= (b) ? (a) : (b))
***************
*** 676,702 ****
* - The last VCN is recognised by the fact that length == 0.
* - LCN == 0 at any point means that the count VCNs starting at VCN are not
! * physically allocated (ie. this is a hole). */
/* FIXME: Should this be a linked list so it is easier/quicker to edit? */
! /* Allocate a run_list array and decompress the run-list of the non-resident
* attribute attr into the run_list array.
* Return a pointer to the run_list array or NULL on error.
! * Notes: caller has to free the run_list array when finished. */
run_list decompress_run_list(NONRESIDENT_ATTRIBUTE_RECORD_HEADER *attr);
! /* Determine the logical cluster number given the virtual cluster number and
* the run list describing the mapping between the LCNs and VCNs.
* Return -ERRNO on error (ERRNO being the error number) and notably -NOENT
! * if vcn is outside the boundaries covered by the run list. */
__s64 vcn_to_lcn(run_list rl, __s64 vcn);
! /* Set the volume flags in the Mft record b to flags.
! * Return 1 on success or 0 on error. */
int set_ntfs_volume_flags(MFT_RECORD_HEADER *b, __u16 flags);
! /* Get the location of the desired attribute of type t and name n (n can be
* NULL for unnamed attributes; note that n is a Unicode string). Return a
* pointer to the attribute or NULL if the attribute is not present or an
! * error situation exists. */
ATTRIBUTE_RECORD_HEADER *find_attribute(MFT_RECORD_HEADER *b, ATTRIBUTE_TYPE t,
wchar_t *n);
--- 768,802 ----
* - The last VCN is recognised by the fact that length == 0.
* - LCN == 0 at any point means that the count VCNs starting at VCN are not
! * physically allocated (i.e. this is a hole / data is sparse). */
/* FIXME: Should this be a linked list so it is easier/quicker to edit? */
! /*
! * Allocate a run_list array and decompress the run-list of the non-resident
* attribute attr into the run_list array.
* Return a pointer to the run_list array or NULL on error.
! * Notes: caller has to free the run_list array when finished.
! */
run_list decompress_run_list(NONRESIDENT_ATTRIBUTE_RECORD_HEADER *attr);
! /*
! * Determine the logical cluster number given the virtual cluster number and
* the run list describing the mapping between the LCNs and VCNs.
* Return -ERRNO on error (ERRNO being the error number) and notably -NOENT
! * if vcn is outside the boundaries covered by the run list.
! */
__s64 vcn_to_lcn(run_list rl, __s64 vcn);
! /*
! * Set the volume flags in the Mft record b to flags.
! * Return 1 on success or 0 on error.
! */
int set_ntfs_volume_flags(MFT_RECORD_HEADER *b, __u16 flags);
! /*
! * Get the location of the desired attribute of type t and name n (n can be
* NULL for unnamed attributes; note that n is a Unicode string). Return a
* pointer to the attribute or NULL if the attribute is not present or an
! * error situation exists.
! */
ATTRIBUTE_RECORD_HEADER *find_attribute(MFT_RECORD_HEADER *b, ATTRIBUTE_TYPE t,
wchar_t *n);
***************
*** 704,717 ****
#include "volume.h"
__u64 get_attribute_value_length(ATTRIBUTE_RECORD_HEADER *a);
! /* Make a copy of the attribute value of the attribute a into the destination
* buffer b. Note that the size of b has to be at least equal to the value
* returned by get_attribute_value_length(a).
* Return number of bytes copied. If this is zero check errno. If errno is 0
* then nothing was read due to a zero-length attribute value, otherwise
! * errno describes the error. */
__u64 get_attribute_value(ntfs_volume *vol, ATTRIBUTE_RECORD_HEADER *a, __u8 *b);
int set_attribute_value(ntfs_volume *vol, ATTRIBUTE_RECORD_HEADER *a,
unsigned char *b, __u64 l);
--- 804,835 ----
#include "volume.h"
+ /*
+ * Return the byte size of the attribute value (as it would be after eventual
+ * decompression and filling in of holes if sparse.
+ * If we return 0, check errno. If errno is 0 the actual length was 0,
+ * otherwise errno describes the error.
+ */
__u64 get_attribute_value_length(ATTRIBUTE_RECORD_HEADER *a);
! /*
! * Make a copy of the attribute value of the attribute a into the destination
* buffer b. Note that the size of b has to be at least equal to the value
* returned by get_attribute_value_length(a).
* Return number of bytes copied. If this is zero check errno. If errno is 0
* then nothing was read due to a zero-length attribute value, otherwise
! * errno describes the error.
! */
__u64 get_attribute_value(ntfs_volume *vol, ATTRIBUTE_RECORD_HEADER *a, __u8 *b);
+ /*
+ * Set the value of the attribute a to the contents of the buffer b which has
+ * a byte-size of l and write it to the NTFS volume vol.
+ * Return 1 on success and 0 on error, errno will be set in the latter case.
+ *
+ * FIXME: This is only a temporary implementation which doesn't cope with
+ * changes in the length of the resident part of the attribute which in turn
+ * means it doesn't cope with changes in length or on disk location of the
+ * non-resident part of the attribute either! See ntfsfix.c for details.
+ */
int set_attribute_value(ntfs_volume *vol, ATTRIBUTE_RECORD_HEADER *a,
unsigned char *b, __u64 l);
|