parent
3e1b7a9165
commit
d789fd8385
|
@ -7,7 +7,7 @@ const char *EXEC_VERSION= "0.0.1";
|
|||
*
|
||||
* Short description here.
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -37,7 +37,7 @@ const char *EXEC_VERSION= "0.0.1";
|
|||
* If anyone using a non-little endian and/or an aligned access only CPU tries
|
||||
* this program please let me know whether it works or not!
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* $Id$
|
||||
*
|
||||
* endians.h - Definitions related to handling of byte ordering. Part of the
|
||||
* Linux-NTFS project.
|
||||
* Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000,2001 Anton Altaparmakov.
|
||||
*
|
||||
|
@ -28,9 +28,9 @@
|
|||
/*
|
||||
* Notes:
|
||||
*
|
||||
* We define the conversion functions including typecasts since the
|
||||
* We define the conversion functions including typecasts since the
|
||||
* defaults don't necessarily perform appropriate typecasts.
|
||||
* Also, using our own functions means that we can change them if it
|
||||
* Also, using our own functions means that we can change them if it
|
||||
* turns out that we do need to use the unaligned access macros on
|
||||
* architectures requirering aligned memory accesses...
|
||||
*/
|
||||
|
|
270
include/layout.h
270
include/layout.h
|
@ -33,13 +33,13 @@
|
|||
|
||||
/*
|
||||
* Location of bootsector 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 bootsector contained number of sectors
|
||||
* 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 bootsector 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.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -111,21 +111,21 @@ typedef enum {
|
|||
* operator! (-8
|
||||
*/
|
||||
#define is_magic(x, m) ( (u32)(x) == (u32)magic_##m )
|
||||
#define is_magicp(p, m) ( *(u32*)(p) == (u32)magic_##m )
|
||||
#define is_magicp(p, m) ( *(u32*)(p) == (u32)magic_##m )
|
||||
|
||||
/*
|
||||
* Specialised magic comparison macros.
|
||||
*/
|
||||
#define is_baad_record(x) ( is_magic (x, BAAD) )
|
||||
#define is_baad_recordp(p) ( is_magicp(p, BAAD) )
|
||||
#define is_chkd_record(x) ( is_magic (x, CHKD) )
|
||||
#define is_chkd_recordp(p) ( is_magicp(p, CHKD) )
|
||||
#define is_chkd_record(x) ( is_magic (x, CHKD) )
|
||||
#define is_chkd_recordp(p) ( is_magicp(p, CHKD) )
|
||||
#define is_file_record(x) ( is_magic (x, FILE) )
|
||||
#define is_file_recordp(p) ( is_magicp(p, FILE) )
|
||||
#define is_hole_record(x) ( is_magic (x, HOLE) )
|
||||
#define is_hole_recordp(p) ( is_magicp(p, HOLE) )
|
||||
#define is_indx_record(x) ( is_magic (x, INDX) )
|
||||
#define is_indx_recordp(p) ( is_magicp(p, INDX) )
|
||||
#define is_hole_record(x) ( is_magic (x, HOLE) )
|
||||
#define is_hole_recordp(p) ( is_magicp(p, HOLE) )
|
||||
#define is_indx_record(x) ( is_magic (x, INDX) )
|
||||
#define is_indx_recordp(p) ( is_magicp(p, INDX) )
|
||||
|
||||
#define is_mft_record(x) ( is_file_record(x) )
|
||||
#define is_mft_recordp(p) ( is_file_recordp(p) )
|
||||
|
@ -134,7 +134,7 @@ typedef enum {
|
|||
* Defines for the NTFS filesystem. Don't want to use BLOCK_SIZE and
|
||||
* BLOCK_SIZE_BITS from the kernel as that is 1024 and hence too high for us.
|
||||
*/
|
||||
#define NTFS_SECTOR_SIZE 512
|
||||
#define NTFS_SECTOR_SIZE 512
|
||||
#define NTFS_SECTOR_SIZE_BITS 9
|
||||
|
||||
/*
|
||||
|
@ -147,7 +147,7 @@ typedef enum {
|
|||
* are set to it (during writing). If they are not, an incomplete multi sector
|
||||
* transfer has occured 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
|
||||
* maximum size = usa_ofs + (usa_count * 2) = 510 bytes
|
||||
* The 510 bytes comes from the fact that the last u16 in the array has to
|
||||
* (obviously) finish before the last u16 of the first 512-byte sector.
|
||||
* This formula can be used as a consistency check in that usa_ofs +
|
||||
|
@ -172,41 +172,41 @@ typedef struct {
|
|||
* never modified.
|
||||
*/
|
||||
typedef enum {
|
||||
FILE_MFT = 0, /* Master file table (mft). Data attribute
|
||||
FILE_MFT = 0, /* Master file table (mft). Data attribute
|
||||
contains the entries and bitmap attribute
|
||||
records which ones are in use (bit==1). */
|
||||
FILE_MFTMirr = 1, /* Mft mirror: copy of first four mft records
|
||||
FILE_MFTMirr = 1, /* Mft mirror: copy of first four mft records
|
||||
in data attribute. If cluster size > 4kiB,
|
||||
copy of first N mft records, with
|
||||
N = cluster_size / mft_record_size. */
|
||||
FILE_LogFile = 2, /* Journalling log in data attribute. */
|
||||
FILE_Volume = 3, /* Volume name attribute and volume information
|
||||
FILE_LogFile = 2, /* Journalling log in data attribute. */
|
||||
FILE_Volume = 3, /* Volume name attribute and volume information
|
||||
attribute (flags and ntfs version). Windows
|
||||
refers to this file as volume DASD (Direct
|
||||
Access Storage Device). */
|
||||
FILE_AttrDef = 4, /* Array of attribute definitions in data
|
||||
FILE_AttrDef = 4, /* Array of attribute definitions in data
|
||||
attribute. */
|
||||
FILE_root = 5, /* Root directory. */
|
||||
FILE_Bitmap = 6, /* Allocation bitmap of all clusters (lcns) in
|
||||
FILE_root = 5, /* Root directory. */
|
||||
FILE_Bitmap = 6, /* Allocation bitmap of all clusters (lcns) in
|
||||
data attribute. */
|
||||
FILE_Boot = 7, /* Boot sector (always at cluster 0) in data
|
||||
FILE_Boot = 7, /* Boot sector (always at cluster 0) in data
|
||||
attribute. */
|
||||
FILE_BadClus = 8, /* Contains all bad clusters in the non-resident
|
||||
FILE_BadClus = 8, /* Contains all bad clusters in the non-resident
|
||||
data attribute. */
|
||||
FILE_Secure = 9, /* Shared security descriptors in data attribute
|
||||
FILE_Secure = 9, /* Shared security descriptors in data attribute
|
||||
and two indexes into the descriptors.
|
||||
Appeared in Windows 2000. Before that, this
|
||||
file was named $Quota but was unused. */
|
||||
FILE_UpCase = 10, /* Uppercase equivalents of all 65536 Unicode
|
||||
FILE_UpCase = 10, /* Uppercase equivalents of all 65536 Unicode
|
||||
characters in data attribute. */
|
||||
FILE_Extend = 11, /* Directory containing other system files (eg.
|
||||
FILE_Extend = 11, /* Directory containing other system files (eg.
|
||||
$ObjId, $Quota, $Reparse and $UsnJrnl). This
|
||||
is new to NTFS3.0. */
|
||||
FILE_reserved12 = 12, /* Reserved for future use (records 12-15). */
|
||||
FILE_reserved13 = 13,
|
||||
FILE_reserved14 = 14,
|
||||
FILE_reserved15 = 15,
|
||||
FILE_first_user = 16, /* First user file, used as test limit for
|
||||
FILE_reserved12 = 12, /* Reserved for future use (records 12-15). */
|
||||
FILE_reserved13 = 13,
|
||||
FILE_reserved14 = 14,
|
||||
FILE_reserved15 = 15,
|
||||
FILE_first_user = 16, /* First user file, used as test limit for
|
||||
whether to allow opening a file or not. */
|
||||
} NTFS_SYSTEM_FILES;
|
||||
|
||||
|
@ -296,11 +296,11 @@ typedef struct {
|
|||
/* 8*/ u64 lsn; /* $LogFile sequence number for this record.
|
||||
Changed every time the record is modified. */
|
||||
/* 16*/ u16 sequence_number; /* Number of times this mft record has been
|
||||
reused. (See description for MFT_REF
|
||||
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. */
|
||||
/* 18*/ u16 link_count; /* Number of hard links, i.e. the number of
|
||||
/* 18*/ u16 link_count; /* Number of hard links, i.e. the number of
|
||||
directory entries referencing this record.
|
||||
NOTE: Only used in mft base records.
|
||||
NOTE: When deleting a directory entry we
|
||||
|
@ -400,13 +400,13 @@ typedef enum {
|
|||
* 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 u32 key
|
||||
* values. E.g. used for $SII index in FILE_Secure, which sorts by
|
||||
* security_id (u32).
|
||||
* values. E.g. used for $SII index in FILE_Secure, which sorts by
|
||||
* security_id (u32).
|
||||
* COLLATION_NTOFS_SID - Sorting is done according to ascending SID values.
|
||||
* E.g. used for $O index in FILE_Extend/$Quota.
|
||||
* 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.
|
||||
* 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
|
||||
* u32 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
|
||||
|
@ -732,9 +732,9 @@ typedef enum {
|
|||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
typedef struct {
|
||||
/*Ofs*/
|
||||
|
@ -766,14 +766,14 @@ typedef struct {
|
|||
* 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.
|
||||
* 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
|
||||
|
@ -828,20 +828,20 @@ typedef struct {
|
|||
* extent. They are ordered by lowest_vcn and have their instace 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.
|
||||
* - 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
|
||||
* - 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.
|
||||
* - The security descriptor is very complex (not applicable to
|
||||
* NTFS 3.0 volumes).
|
||||
* - There are many named streams.
|
||||
*/
|
||||
typedef struct {
|
||||
/*Ofs*/
|
||||
|
@ -915,9 +915,9 @@ typedef enum {
|
|||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
typedef struct {
|
||||
/*hex ofs*/
|
||||
|
@ -961,7 +961,7 @@ typedef struct {
|
|||
* twelve hexadecimal digits. GUIDs are Microsoft's implementation of the
|
||||
* distributed computing environment (DCE) universally unique identifier (UUID).
|
||||
* Example of a GUID:
|
||||
* 1F010768-5A73-BC91-0010A52216A7
|
||||
* 1F010768-5A73-BC91-0010A52216A7
|
||||
*/
|
||||
typedef struct {
|
||||
u32 data1; /* The first eight hexadecimal digits of the GUID. */
|
||||
|
@ -1030,7 +1030,7 @@ typedef struct {
|
|||
//typedef enum { /* SID string prefix. */
|
||||
// SECURITY_NULL_SID_AUTHORITY = {0, 0, 0, 0, 0, 0}, /* S-1-0 */
|
||||
// SECURITY_WORLD_SID_AUTHORITY = {0, 0, 0, 0, 0, 1}, /* S-1-1 */
|
||||
// SECURITY_LOCAL_SID_AUTHORITY = {0, 0, 0, 0, 0, 2}, /* S-1-2 */
|
||||
// SECURITY_LOCAL_SID_AUTHORITY = {0, 0, 0, 0, 0, 2}, /* S-1-2 */
|
||||
// SECURITY_CREATOR_SID_AUTHORITY = {0, 0, 0, 0, 0, 3}, /* S-1-3 */
|
||||
// SECURITY_NON_UNIQUE_AUTHORITY = {0, 0, 0, 0, 0, 4}, /* S-1-4 */
|
||||
// SECURITY_NT_SID_AUTHORITY = {0, 0, 0, 0, 0, 5}, /* S-1-5 */
|
||||
|
@ -1119,38 +1119,38 @@ typedef enum { /* Identifier authority. */
|
|||
/*
|
||||
* 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
|
||||
* 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
|
||||
* (Non-unique IDs) S-1-4
|
||||
*
|
||||
* NT well-known SIDs:
|
||||
*
|
||||
* NT_AUTHORITY_SID S-1-5
|
||||
* DIALUP_SID S-1-5-1
|
||||
* NT_AUTHORITY_SID S-1-5
|
||||
* DIALUP_SID S-1-5-1
|
||||
*
|
||||
* NETWORD_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)
|
||||
* NETWORD_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
|
||||
* (Logon IDs) S-1-5-5-X-Y
|
||||
*
|
||||
* (NT non-unique IDs) S-1-5-0x15-...
|
||||
* (NT non-unique IDs) S-1-5-0x15-...
|
||||
*
|
||||
* (Built-in domain) S-1-5-0x20
|
||||
* (Built-in domain) S-1-5-0x20
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1158,8 +1158,8 @@ typedef enum { /* Identifier authority. */
|
|||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
u32 low_part; /* Low 32-bits. */
|
||||
u16 high_part; /* High 16-bits. */
|
||||
u32 low_part; /* Low 32-bits. */
|
||||
u16 high_part; /* High 16-bits. */
|
||||
} __attribute__ ((__packed__));
|
||||
u8 value[6]; /* Value as individual bytes. */
|
||||
} __attribute__ ((__packed__)) SID_IDENTIFIER_AUTHORITY;
|
||||
|
@ -1169,10 +1169,10 @@ typedef union {
|
|||
* users or groups. SID stands for security identifier.
|
||||
*
|
||||
* The standard textual representation of the SID is of the form:
|
||||
* S-R-I-S-S...
|
||||
* S-R-I-S-S...
|
||||
* Where:
|
||||
* - The first "S" is the literal character 'S' identifying the following
|
||||
* digits as a SID.
|
||||
* digits as a SID.
|
||||
* - R is the revision level of the SID expressed as a sequence of digits
|
||||
* either in decimal or hexadecimal (if the later, prefixed by "0x").
|
||||
* - I is the 48-bit identifier_authority, expressed as digits as R above.
|
||||
|
@ -1180,13 +1180,13 @@ typedef union {
|
|||
*
|
||||
* Example SID; the domain-relative SID of the local Administrators group on
|
||||
* Windows NT/2k:
|
||||
* S-1-5-32-544
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
typedef struct {
|
||||
u8 revision;
|
||||
|
@ -1492,48 +1492,48 @@ typedef enum {
|
|||
* 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 inheritence
|
||||
* of an owner.
|
||||
* 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 inheritence
|
||||
* 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 inheritence of a primary group.
|
||||
* 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 inheritence 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.
|
||||
* 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 inheritence of an ACL.
|
||||
* This flag is ignored if the DaclPresent flag is not set.
|
||||
* 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 inheritence 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.
|
||||
* 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 inheritence of an ACL.
|
||||
* This flag is ignored if the SaclPresent flag is not set.
|
||||
* 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 inheritence 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.
|
||||
* 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.
|
||||
*/
|
||||
typedef enum {
|
||||
SE_OWNER_DEFAULTED = const_cpu_to_le16(0x0001),
|
||||
|
@ -1731,7 +1731,7 @@ typedef struct {
|
|||
typedef enum {
|
||||
VOLUME_IS_DIRTY = const_cpu_to_le16(0x0001),
|
||||
VOLUME_RESIZE_LOG_FILE = const_cpu_to_le16(0x0002),
|
||||
VOLUME_UPGRADE_ON_MOUNT = const_cpu_to_le16(0x0004),
|
||||
VOLUME_UPGRADE_ON_MOUNT = const_cpu_to_le16(0x0004),
|
||||
VOLUME_MOUNTED_ON_NT4 = const_cpu_to_le16(0x0008),
|
||||
VOLUME_DELETE_USN_UNDERWAY = const_cpu_to_le16(0x0010),
|
||||
VOLUME_REPAIR_OBJECT_ID = const_cpu_to_le16(0x0020),
|
||||
|
@ -1745,7 +1745,7 @@ typedef enum {
|
|||
* 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.
|
||||
* NTFS 1.2. I haven't personally seen other values yet.
|
||||
*/
|
||||
typedef struct {
|
||||
u64 reserved; /* Not used (yet?). */
|
||||
|
@ -1781,7 +1781,7 @@ typedef enum {
|
|||
* allocation attribute:
|
||||
*/
|
||||
LEAF_NODE = 0, /* This is a leaf node, i.e. there are no more
|
||||
nodes branching off it. */
|
||||
nodes branching off it. */
|
||||
INDEX_NODE = 1, /* This node indexes other nodes, i.e. is not a
|
||||
leaf node. */
|
||||
NODE_MASK = 1, /* Mask for accessing the *_NODE bits. */
|
||||
|
@ -2002,7 +2002,7 @@ typedef struct {
|
|||
} __attribute__ ((__packed__));
|
||||
/* 8*/ u16 length; /* Byte size of this index entry, multiple of
|
||||
8-bytes. */
|
||||
/* 10*/ u16 key_length; /* Byte size of the key value, which is in the
|
||||
/* 10*/ u16 key_length; /* Byte size of the key value, which is in the
|
||||
index entry. It follows field reserved. Not
|
||||
multiple of 8-bytes. */
|
||||
/* 12*/ INDEX_ENTRY_FLAGS flags; /* Bit field of INDEX_ENTRY_* flags. */
|
||||
|
@ -2080,9 +2080,9 @@ typedef struct {
|
|||
* 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
|
||||
* 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
|
||||
* bit 31: Microsoft bit. If set, the tag is owned by Microsoft. User
|
||||
* defined tags have to use zero here.
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
|
@ -41,9 +41,9 @@ typedef enum {
|
|||
|
||||
/*
|
||||
* Log file organization:
|
||||
* Two restart areas present in the first two pages (restart pages). When
|
||||
* Two restart areas present in the first two pages (restart pages). When
|
||||
* the volume is unmounted they should be identical.
|
||||
* These are followed by log records organized in pages headed by a record
|
||||
* These are followed by log records organized in pages headed by a record
|
||||
* header going up to log file size. Not all pages contain log records when a
|
||||
* volume is first formatted, but as the volume ages, all records will be used.
|
||||
* When the log file fills up, the records at the beginning are purged (by
|
||||
|
|
|
@ -86,7 +86,7 @@ static __inline__ int ntfs_write_mft_record(const ntfs_volume *vol,
|
|||
* or 0 on error (i.e. @m is not a valid mft record). Zero is not a valid size
|
||||
* for an mft record as it at least has to have the MFT_RECORD, thus making the
|
||||
* minimum size:
|
||||
* (sizeof(MFT_RECORD) + 7) & ~7 + sizeof(ATTR_TYPES) = 52 bytes
|
||||
* (sizeof(MFT_RECORD) + 7) & ~7 + sizeof(ATTR_TYPES) = 52 bytes
|
||||
* Aside: The 8-byte alignment and the 4 bytes for the attribute type are needed
|
||||
* as each mft record has to have a list of attributes even if it only contains
|
||||
* the attribute $END which doesn't contain anything else apart from its type.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* $Id$
|
||||
*
|
||||
* mst.h - Exports for multi sector transfer fixup functions. Part of the
|
||||
* Linux-NTFS project.
|
||||
* Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2002 Anton Altaparmakov.
|
||||
*
|
||||
|
|
|
@ -30,18 +30,18 @@
|
|||
* Generic macro to convert pointers to values for comparison purposes.
|
||||
*/
|
||||
#ifndef p2n
|
||||
#define p2n(p) ((ptrdiff_t)((ptrdiff_t*)(p)))
|
||||
#define p2n(p) ((ptrdiff_t)((ptrdiff_t*)(p)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The classical min and max macros.
|
||||
*/
|
||||
#ifndef min
|
||||
#define min(a,b) ((a) <= (b) ? (a) : (b))
|
||||
#define min(a,b) ((a) <= (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) ((a) >= (b) ? (a) : (b))
|
||||
#define max(a,b) ((a) >= (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -83,7 +83,7 @@ s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
|||
return 0;
|
||||
}
|
||||
memcpy(b, (char*)a + le16_to_cpu(a->value_offset),
|
||||
le32_to_cpu(a->value_length));
|
||||
le32_to_cpu(a->value_length));
|
||||
errno = 0;
|
||||
return (s64)le32_to_cpu(a->value_length);
|
||||
} else { /* Attribute is not resident. */
|
||||
|
@ -122,12 +122,12 @@ s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
|||
* going to overflow when executing the
|
||||
* ntfs_pread() which is BAAAAAAAD!
|
||||
* Temporary fix:
|
||||
* Allocate a new buffer with size:
|
||||
* rl[i].length << vol->cluster_size_bits,
|
||||
* do the read into our buffer, then
|
||||
* memcpy the correct amount of data into
|
||||
* the caller supplied buffer, free our
|
||||
* buffer, and continue.
|
||||
* Allocate a new buffer with size:
|
||||
* rl[i].length << vol->cluster_size_bits,
|
||||
* do the read into our buffer, then
|
||||
* memcpy the correct amount of data into
|
||||
* the caller supplied buffer, free our
|
||||
* buffer, and continue.
|
||||
*/
|
||||
intbuf = malloc(rl[i].length <<
|
||||
vol->cluster_size_bits);
|
||||
|
@ -167,7 +167,7 @@ s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
|||
"out of input data.\n");
|
||||
errno = EIO;
|
||||
} else {
|
||||
fprintf(stderr, ESTR ": "
|
||||
fprintf(stderr, ESTR ": "
|
||||
"unknown error\n");
|
||||
errno = EIO;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ s64 get_attribute_value(const ntfs_volume *vol, const MFT_RECORD *m,
|
|||
"out of input data.\n");
|
||||
errno = EIO;
|
||||
} else {
|
||||
fprintf(stderr, ESTR ": "
|
||||
fprintf(stderr, ESTR ": "
|
||||
"unknown error\n");
|
||||
errno = EIO;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
if (NAttrCompressed(na)) {
|
||||
// TODO: Implement reading compressed attributes! (AIA)
|
||||
// return ntfs_attr_pread_compressed(ntfs_attr *na,
|
||||
// const s64 pos, s64 count, void *b);
|
||||
// const s64 pos, s64 count, void *b);
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, void *b)
|
|||
if (NAttrCompressed(na)) {
|
||||
// TODO: Implement writing compressed attributes! (AIA)
|
||||
// return ntfs_attr_pwrite_compressed(ntfs_attr *na,
|
||||
// const s64 pos, s64 count, void *b);
|
||||
// const s64 pos, s64 count, void *b);
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ static int ntfs_find_attr(const ATTR_TYPES type, const uchar_t *name,
|
|||
}
|
||||
/* If the strings are not equal, continue search. */
|
||||
if (rc)
|
||||
continue;
|
||||
continue;
|
||||
rc = ntfs_collate_names(name, name_len,
|
||||
(uchar_t*)((char*)a +
|
||||
le16_to_cpu(a->name_offset)),
|
||||
|
|
|
@ -116,14 +116,14 @@ found_it:
|
|||
goto not_found;
|
||||
/* If the strings are not equal, continue search. */
|
||||
if (rc)
|
||||
goto do_next;
|
||||
goto do_next;
|
||||
}
|
||||
/* If case sensitive collation of names doesn't collate @name before
|
||||
a->name, we continue the search. Otherwise we haven't found it. */
|
||||
if (ntfs_collate_names(vol->upcase, vol->upcase_len, name, name_len,
|
||||
(wchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
|
||||
a->name_length, CASE_SENSITIVE, 1) != -1)
|
||||
goto do_next;
|
||||
goto do_next;
|
||||
not_found:
|
||||
return FALSE;
|
||||
file_corrupt:
|
||||
|
|
|
@ -238,7 +238,7 @@ int parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
|||
* When clusters_per_mft_record is negative, it means that it is to
|
||||
* be taken to be the negative base 2 logarithm of the mft_record_size
|
||||
* min bytes. Then:
|
||||
* mft_record_size = 2^(-clusters_per_mft_record) bytes.
|
||||
* mft_record_size = 2^(-clusters_per_mft_record) bytes.
|
||||
*/
|
||||
if (c < 0)
|
||||
vol->mft_record_size = 1 << -c;
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
/**
|
||||
* ntfs_post_read_mst_fixup - deprotect multi sector transfer protected data
|
||||
* @b: pointer to the data to deprotect
|
||||
* @size: size in bytes of @b
|
||||
* @b: pointer to the data to deprotect
|
||||
* @size: size in bytes of @b
|
||||
*
|
||||
* Perform the necessary post read multi sector transfer fixups and detect the
|
||||
* presence of incomplete multi sector transfers. - In that case, overwrite the
|
||||
|
@ -69,11 +69,11 @@ int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
* Position in protected data of first u16 that needs fixing up.
|
||||
*/
|
||||
data_pos = (u16*)b + NTFS_SECTOR_SIZE/sizeof(u16) - 1;
|
||||
/*
|
||||
/*
|
||||
* Check for incomplete multi sector transfer(s).
|
||||
*/
|
||||
while (usa_count--) {
|
||||
if (*data_pos != usn) {
|
||||
if (*data_pos != usn) {
|
||||
/*
|
||||
* Incomplete multi sector transfer detected! )-:
|
||||
* Set the magic to "BAAD" and return failure.
|
||||
|
@ -81,7 +81,7 @@ int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
*/
|
||||
b->magic = magic_BAAD;
|
||||
errno = EIO;
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
data_pos += NTFS_SECTOR_SIZE/sizeof(u16);
|
||||
}
|
||||
|
@ -95,16 +95,16 @@ int ntfs_post_read_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
* the usa into the data buffer.
|
||||
*/
|
||||
*data_pos = *(++usa_pos);
|
||||
/* Increment position in data as well. */
|
||||
/* Increment position in data as well. */
|
||||
data_pos += NTFS_SECTOR_SIZE/sizeof(u16);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_pre_write_mst_fixup - apply multi sector transfer protection
|
||||
* @b: pointer to the data to protect
|
||||
* @size: size in bytes of @b
|
||||
* @b: pointer to the data to protect
|
||||
* @size: size in bytes of @b
|
||||
*
|
||||
* Perform the necessary pre write multi sector transfer fixup on the data
|
||||
* pointer to by @b of @size.
|
||||
|
@ -155,8 +155,8 @@ int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
*usa_pos = usn;
|
||||
/* Position in data of first u16 that needs fixing up. */
|
||||
data_pos = (u16*)b + NTFS_SECTOR_SIZE/sizeof(u16) - 1;
|
||||
/* Fixup all sectors. */
|
||||
while (usa_count--) {
|
||||
/* Fixup all sectors. */
|
||||
while (usa_count--) {
|
||||
/*
|
||||
* Increment the position in the usa and save the
|
||||
* original data from the data buffer into the usa.
|
||||
|
@ -166,13 +166,13 @@ int ntfs_pre_write_mst_fixup(NTFS_RECORD *b, const u32 size)
|
|||
*data_pos = usn;
|
||||
/* Increment position in data as well. */
|
||||
data_pos += NTFS_SECTOR_SIZE/sizeof(u16);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_post_write_mst_fixup - deprotect multi sector transfer protected data
|
||||
* @b: pointer to the data to deprotect
|
||||
* @b: pointer to the data to deprotect
|
||||
*
|
||||
* Perform the necessary post write multi sector transfer fixup, not checking
|
||||
* for any errors, because we assume we have just used
|
||||
|
@ -192,7 +192,7 @@ void ntfs_post_write_mst_fixup(NTFS_RECORD *b)
|
|||
/* Position in protected data of first u16 that needs fixing up. */
|
||||
data_pos = (u16*)b + NTFS_SECTOR_SIZE/sizeof(u16) - 1;
|
||||
|
||||
/* Fixup all sectors. */
|
||||
/* Fixup all sectors. */
|
||||
while (usa_count--) {
|
||||
/*
|
||||
* Increment position in usa and restore original data from
|
||||
|
@ -200,8 +200,8 @@ void ntfs_post_write_mst_fixup(NTFS_RECORD *b)
|
|||
*/
|
||||
*data_pos = *(++usa_pos);
|
||||
|
||||
/* Increment position in data as well. */
|
||||
/* Increment position in data as well. */
|
||||
data_pos += NTFS_SECTOR_SIZE/sizeof(u16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static __inline__ void ntfs_rl_mc(run_list_element *dstbase, int dst,
|
|||
* of memory.
|
||||
*
|
||||
* N.B. If the new allocation doesn't require a different number of 4kiB
|
||||
* blocks in memory, the function will return the original pointer.
|
||||
* blocks in memory, the function will return the original pointer.
|
||||
*
|
||||
* On success, return a pointer to the newly allocated, or recycled, memory.
|
||||
* On error, return NULL with errno set to the error code.
|
||||
|
@ -97,7 +97,7 @@ static __inline__ run_list_element *ntfs_rl_realloc(run_list_element *rl,
|
|||
* must be adjacent.
|
||||
*
|
||||
* Return: TRUE Success, the run lists can be merged.
|
||||
* FALSE Failure, the run lists cannot be merged.
|
||||
* FALSE Failure, the run lists cannot be merged.
|
||||
*/
|
||||
static __inline__ BOOL ntfs_are_rl_mergeable(run_list_element *dst,
|
||||
run_list_element *src)
|
||||
|
@ -147,7 +147,7 @@ static __inline__ void __ntfs_rl_merge(run_list_element *dst,
|
|||
* the destination run list @dst.
|
||||
*
|
||||
* Return: TRUE Success, the run lists have been merged.
|
||||
* FALSE Failure, the run lists cannot be merged and have not been
|
||||
* FALSE Failure, the run lists cannot be merged and have not been
|
||||
* modified.
|
||||
*/
|
||||
static __inline__ BOOL ntfs_rl_merge(run_list_element *dst,
|
||||
|
@ -264,9 +264,9 @@ static __inline__ run_list_element *ntfs_rl_insert(run_list_element *dst,
|
|||
}
|
||||
|
||||
/* disc => Discontinuity between the end of @dst and the start of @src.
|
||||
* This means we might need to insert a hole.
|
||||
* This means we might need to insert a hole.
|
||||
* hole => @dst ends with a hole or an unmapped region which we can
|
||||
* extend to match the discontinuity. */
|
||||
* extend to match the discontinuity. */
|
||||
if (loc == 0)
|
||||
disc = (src[0].vcn > 0);
|
||||
else {
|
||||
|
@ -447,9 +447,9 @@ static __inline__ run_list_element *ntfs_rl_split(run_list_element *dst,
|
|||
ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
|
||||
|
||||
/* Adjust the size of the holes either size of @src. */
|
||||
dst[loc].length = dst[loc+1].vcn - dst[loc].vcn;
|
||||
dst[loc+ssize+1].vcn = dst[loc+ssize].vcn + dst[loc+ssize].length;
|
||||
dst[loc+ssize+1].length = dst[loc+ssize+2].vcn - dst[loc+ssize+1].vcn;
|
||||
dst[loc].length = dst[loc+1].vcn - dst[loc].vcn;
|
||||
dst[loc+ssize+1].vcn = dst[loc+ssize].vcn + dst[loc+ssize].length;
|
||||
dst[loc+ssize+1].length = dst[loc+ssize+2].vcn - dst[loc+ssize+1].vcn;
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ run_list_element *ntfs_merge_run_lists(run_list_element *drl,
|
|||
Dputs("src:");
|
||||
ntfs_debug_dump_run_list(srl);
|
||||
|
||||
/* Check for silly calling... */
|
||||
/* Check for silly calling... */
|
||||
if (!srl)
|
||||
return drl;
|
||||
|
||||
|
@ -710,10 +710,10 @@ critical_error:
|
|||
* unmodified in that case.
|
||||
*
|
||||
* The following error codes are defined:
|
||||
* ENOMEM Not enough memory to allocate run list array.
|
||||
* EIO Corrupt run list.
|
||||
* EINVAL Invalid parameters were passed in.
|
||||
* ERANGE The two run lists overlap.
|
||||
* ENOMEM Not enough memory to allocate run list array.
|
||||
* EIO Corrupt run list.
|
||||
* EINVAL Invalid parameters were passed in.
|
||||
* ERANGE The two run lists overlap.
|
||||
*
|
||||
* FIXME: For now we take the conceptionally simplest approach of creating the
|
||||
* new run list disregarding the already existing one and then splicing the
|
||||
|
@ -724,7 +724,7 @@ run_list_element *ntfs_decompress_mapping_pairs(const ntfs_volume *vol,
|
|||
const ATTR_RECORD *attr, run_list_element *old_rl)
|
||||
{
|
||||
VCN vcn; /* Current vcn. */
|
||||
LCN lcn; /* Current lcn. */
|
||||
LCN lcn; /* Current lcn. */
|
||||
s64 deltaxcn; /* Change in [vl]cn. */
|
||||
run_list_element *rl; /* The output run list. */
|
||||
u8 *buf; /* Current position in mapping pairs array. */
|
||||
|
|
|
@ -92,7 +92,7 @@ BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
|
|||
* @upcase_len: upcase table size (ignored if @ic is CASE_SENSITIVE)
|
||||
* @name1: first Unicode name to compare
|
||||
* @name2: second Unicode name to compare
|
||||
* @ic: either CASE_SENSITIVE or IGNORE_CASE
|
||||
* @ic: either CASE_SENSITIVE or IGNORE_CASE
|
||||
* @err_val: if @name1 contains an invalid character return this value
|
||||
*
|
||||
* ntfs_collate_names collates two Unicode names and returns:
|
||||
|
|
|
@ -900,16 +900,16 @@ int ntfs_is_version_supported(ntfs_volume *vol)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
major = vol->major_ver;
|
||||
minor = vol->minor_ver;
|
||||
|
||||
if (NTFS_V1_1(major, minor) || NTFS_V1_2(major, minor))
|
||||
return 0;
|
||||
|
||||
|
||||
if (NTFS_V2_X(major, minor))
|
||||
return 0;
|
||||
|
||||
|
||||
if (NTFS_V3_0(major, minor) || NTFS_V3_1(major, minor))
|
||||
return 0;
|
||||
|
||||
|
@ -943,7 +943,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ((ni = ntfs_open_inode(vol, FILE_LogFile)) == NULL) {
|
||||
Dperror("Failed to open inode FILE_LogFile.\n");
|
||||
return -1;
|
||||
|
@ -953,7 +953,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
Dperror("Failed to open $FILE_LogFile/$DATA\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
|
||||
/* The $DATA attribute of the $LogFile has to be non-resident. */
|
||||
if (!NAttrNonResident(na)) {
|
||||
Dprintf("$LogFile $DATA attribute is resident!?!\n");
|
||||
|
@ -967,9 +967,9 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
Dprintf("$LogFile has zero length, no disk write needed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read $LogFile until its end. We do this as a check for correct
|
||||
length thus making sure we are decompressing the mapping pairs
|
||||
|
||||
/* Read $LogFile until its end. We do this as a check for correct
|
||||
length thus making sure we are decompressing the mapping pairs
|
||||
array correctly and hence writing below is safe as well. */
|
||||
pos = 0;
|
||||
while ((count = ntfs_attr_pread(na, pos, NTFS_BUF_SIZE, buf)) > 0)
|
||||
|
@ -991,7 +991,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
while ((count = len - pos) > 0) {
|
||||
if (count > NTFS_BUF_SIZE)
|
||||
count = NTFS_BUF_SIZE;
|
||||
|
||||
|
||||
if ((count = ntfs_attr_pwrite(na, pos, count, buf)) <= 0) {
|
||||
Dprintf("Failed to set the $LogFile attribute value.");
|
||||
if (count != -1)
|
||||
|
@ -1000,7 +1000,7 @@ int ntfs_reset_logfile(ntfs_volume *vol)
|
|||
}
|
||||
pos += count;
|
||||
}
|
||||
|
||||
|
||||
ntfs_attr_close(na);
|
||||
return ntfs_close_inode(ni);
|
||||
|
||||
|
@ -1020,8 +1020,8 @@ error_exit:
|
|||
* @vol: ntfs volume where we set the volume flags
|
||||
* @flags: new flags
|
||||
*
|
||||
* Set the on-disk volume flags in the mft record of $Volume and
|
||||
* on volume @vol to @flags.
|
||||
* Set the on-disk volume flags in the mft record of $Volume and
|
||||
* on volume @vol to @flags.
|
||||
*
|
||||
* Return 0 on successful and -1 if not, with errno set to the error code.
|
||||
*/
|
||||
|
@ -1076,7 +1076,7 @@ int ntfs_set_volume_flags(ntfs_volume *vol, const u16 flags)
|
|||
/* Sanity checks. */
|
||||
if ((char*)c + le32_to_cpu(r->value_length) >
|
||||
le16_to_cpu(m->bytes_in_use) + (char*)m ||
|
||||
le16_to_cpu(r->value_offset) +
|
||||
le16_to_cpu(r->value_offset) +
|
||||
le32_to_cpu(r->value_length) > le32_to_cpu(r->length)) {
|
||||
Dputs("Error: Attribute $VOLUME_INFORMATION in $Volume is "
|
||||
"corrupt!");
|
||||
|
@ -1090,11 +1090,11 @@ int ntfs_set_volume_flags(ntfs_volume *vol, const u16 flags)
|
|||
Dperror("Error writing $Volume");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
|
||||
ret = 0; /* success */
|
||||
err_out:
|
||||
ntfs_put_attr_search_ctx(ctx);
|
||||
err_exit:
|
||||
err_exit:
|
||||
if (m)
|
||||
free(m);
|
||||
return ret;
|
||||
|
|
|
@ -11,7 +11,7 @@ const char *EXEC_VERSION = "1.0";
|
|||
* on the command line and display the results on stdout. Errors will be output
|
||||
* to stderr.
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "Error: incorrect syntax\n");
|
||||
exit(1);
|
||||
}
|
||||
if (stat(argv[1], &sbuf) == -1) {
|
||||
if (stat(argv[1], &sbuf) == -1) {
|
||||
if (errno == ENOENT)
|
||||
fprintf(stderr, "The file doesn't exist; did you "
|
||||
"specify it correctly?\n");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.\" Copyright (c) 2001,2002 Anton Altaparmakov. All Rights Reserved.
|
||||
.\" This file may be copied under the terms of the GNU Public License.
|
||||
.\" Adapted from e2fsprogs-1.19/misc/mke2fs.8.in by Theodore Ts'o.
|
||||
.\"
|
||||
.\"
|
||||
.TH MKNTFS 8 "March 2002" "Linux-NTFS version @VERSION@"
|
||||
.SH NAME
|
||||
mkntfs \- create a NTFS 1.2 (Windows NT/2000/XP) file system
|
||||
|
@ -26,7 +26,7 @@ mkntfs \- create a NTFS 1.2 (Windows NT/2000/XP) file system
|
|||
]
|
||||
[
|
||||
.B \-f
|
||||
|
|
||||
|
|
||||
.B \-Q
|
||||
]
|
||||
[
|
||||
|
@ -62,7 +62,7 @@ mkntfs \- create a NTFS 1.2 (Windows NT/2000/XP) file system
|
|||
is used to create a NTFS 1.2 (Windows NT 4.0) file system on a device (usually
|
||||
a disk partition).
|
||||
.I device
|
||||
is the special file corresponding to the device (e.g
|
||||
is the special file corresponding to the device (e.g
|
||||
.IR /dev/hdXX ).
|
||||
.I number-of-sectors
|
||||
is the number of blocks on the device. If omitted,
|
||||
|
@ -143,7 +143,7 @@ actual writing to the device.
|
|||
.TP
|
||||
.B \-q
|
||||
Quiet execution; only errors are written to stderr, no output to stdout
|
||||
occurs at all. Useful if
|
||||
occurs at all. Useful if
|
||||
.B mkntfs
|
||||
is run in a script.
|
||||
.TP
|
||||
|
@ -160,7 +160,7 @@ option as well as additional output useful for debugging
|
|||
Enable compression on the volume.
|
||||
.TP
|
||||
.B \-F
|
||||
Force
|
||||
Force
|
||||
.B mkntfs
|
||||
to run, even if the specified
|
||||
.I device
|
||||
|
@ -172,7 +172,7 @@ Windows 2000 and later. Windows NT 4.0 and earlier ignore this as they do
|
|||
not implement content indexing at all.)
|
||||
.TP
|
||||
.B \-V
|
||||
Print the version number of
|
||||
Print the version number of
|
||||
.B mkntfs
|
||||
and exit.
|
||||
.SH BUGS
|
||||
|
@ -205,7 +205,7 @@ has been written by Anton Altaparmakov <aia21@cantab.net> (if that fails, use
|
|||
<antona@users.sf.net>).
|
||||
.SH AVAILABILITY
|
||||
.B mkntfs
|
||||
is part of the Linux-NTFS project and is available for download from
|
||||
is part of the Linux-NTFS project and is available for download from
|
||||
http://sf.net/project/showfiles.php?group_id=13956 in source (tar ball and
|
||||
rpm) and pre-compiled binary (i386 rpm and deb) form.
|
||||
.SH SEE ALSO
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* adapted from e2fsprogs-1.19 and lib/ext2fs/ismounted.c and misc/mke2fs.c in
|
||||
* particular.
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -43,7 +43,7 @@
|
|||
* If anyone using a non-little endian and/or an aligned access only CPU tries
|
||||
* this program please let me know whether it works or not!
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -839,11 +839,11 @@ void format_mft_record(MFT_RECORD *m)
|
|||
*
|
||||
* Return 0 on success or -errno on error. Possible error codes are:
|
||||
*
|
||||
* -ENOSPC There is not enough space available to complete
|
||||
* operation. The caller has to make space before calling
|
||||
* this.
|
||||
* -EINVAL Can only occur if mkntfs was compiled with -DEBUG. Means
|
||||
* the input parameters were faulty.
|
||||
* -ENOSPC There is not enough space available to complete
|
||||
* operation. The caller has to make space before calling
|
||||
* this.
|
||||
* -EINVAL Can only occur if mkntfs was compiled with -DEBUG. Means
|
||||
* the input parameters were faulty.
|
||||
*/
|
||||
int make_room_for_attribute(MFT_RECORD *m, char *pos, const u32 size)
|
||||
{
|
||||
|
@ -1116,14 +1116,14 @@ int insert_positioned_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
if (err == -ENOSPC) {
|
||||
// FIXME: Make space! (AIA)
|
||||
// can we make it non-resident? if yes, do that.
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m's $DATA or $BITMAP+$INDEX_ALLOCATION resident?
|
||||
// yes -> make non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// make all attributes non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m is a base record? yes -> allocate extension record
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// split up run_list into extents and place each in an extension
|
||||
// record.
|
||||
// FIXME: the check for needing extension records should be
|
||||
|
@ -1299,14 +1299,14 @@ int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
if (err == -ENOSPC) {
|
||||
// FIXME: Make space! (AIA)
|
||||
// can we make it non-resident? if yes, do that.
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m's $DATA or $BITMAP+$INDEX_ALLOCATION resident?
|
||||
// yes -> make non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// make all attributes non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m is a base record? yes -> allocate extension record
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// split up run_list into extents and place each in an extension
|
||||
// record.
|
||||
// FIXME: the check for needing extension records should be
|
||||
|
@ -1437,14 +1437,14 @@ int insert_resident_attr_in_mft_record(MFT_RECORD *m, const ATTR_TYPES type,
|
|||
if (err == -ENOSPC) {
|
||||
// FIXME: Make space! (AIA)
|
||||
// can we make it non-resident? if yes, do that.
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m's $DATA or $BITMAP+$INDEX_ALLOCATION resident?
|
||||
// yes -> make non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// make all attributes non-resident
|
||||
// does it fit now? yes -> do it.
|
||||
// does it fit now? yes -> do it.
|
||||
// m is a base record? yes -> allocate extension record
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// does the new attribute fit in there? yes -> do it.
|
||||
// split up run_list into extents and place each in an extension
|
||||
// record.
|
||||
// FIXME: the check for needing extension records should be
|
||||
|
@ -2547,14 +2547,14 @@ int main(int argc, char **argv)
|
|||
/* Parse command line options. */
|
||||
parse_options(argc, argv);
|
||||
/* Verify we are dealing with a block device. */
|
||||
if (stat(vol->dev_name, &sbuf) == -1) {
|
||||
if (stat(vol->dev_name, &sbuf) == -1) {
|
||||
if (errno == ENOENT)
|
||||
err_exit("The device doesn't exist; did you specify "
|
||||
"it correctly?\n");
|
||||
err_exit("Error getting information about %s: %s\n",
|
||||
vol->dev_name, strerror(errno));
|
||||
}
|
||||
if (!S_ISBLK(sbuf.st_mode)) {
|
||||
if (!S_ISBLK(sbuf.st_mode)) {
|
||||
Eprintf("%s is not a block device.\n", vol->dev_name);
|
||||
if (!opt.force)
|
||||
err_exit("Refusing to make a filesystem here!\n");
|
||||
|
|
|
@ -11,7 +11,7 @@ const char *EXEC_VERSION = "1.0";
|
|||
* NTFS partition and display the results on stdout. Errors will be output to
|
||||
* stderr.
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,7 +41,7 @@ const char *EXEC_VERSION = "1.0";
|
|||
* If anyone using a non-little endian and/or an aligned access only CPU tries
|
||||
* this program please let me know whether it works or not!
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
@ -116,7 +116,7 @@ int main(int argc, char **argv)
|
|||
/* Fall through on error. */
|
||||
default:
|
||||
version_error:
|
||||
fprintf(stderr, "Error: Unknown NTFS version.\n");
|
||||
fprintf(stderr, "Error: Unknown NTFS version.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
/* Read in $LogFile. */
|
||||
|
@ -137,7 +137,7 @@ version_error:
|
|||
/* Find the $DATA attribute of the $LogFile. */
|
||||
if (ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
|
||||
fprintf(stderr, "Error: Attribute $DATA was not found in" \
|
||||
"$LogFile!\n");
|
||||
"$LogFile!\n");
|
||||
goto log_file_error;
|
||||
}
|
||||
a = ctx->attr;
|
||||
|
|
|
@ -26,7 +26,7 @@ This manual page documents briefly the
|
|||
command.
|
||||
.PP
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||
.\" respectively.
|
||||
\fBntfsfix\fP is a program that fixes NTFS partitions altered in any
|
||||
manner with the Linux NTFS driver. \fBntfsfix\fP is \fBNOT\fP a Linux
|
||||
|
@ -53,7 +53,7 @@ This manual page was written by David Mart
|
|||
system (but may be used by others).
|
||||
.SH AVAILABILITY
|
||||
.B ntfsfix
|
||||
is part of the linux-ntfs package and is available from
|
||||
is part of the linux-ntfs package and is available from
|
||||
http://linux-ntfs.sourceforge.net/.
|
||||
.SH SEE ALSO
|
||||
.BR mkntfs (8),
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* the partition, but it might be too late and irreversible damage to the data
|
||||
* might have been done already.
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,7 +42,7 @@
|
|||
* If anyone using a non-little endian and/or an aligned access only CPU tries
|
||||
* this program please let me know whether it works or not!
|
||||
*
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
* Anton Altaparmakov <aia21@cantab.net>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -258,7 +258,7 @@ mount_ok:
|
|||
printf("NTFS volume version is %i.%i.\n\n", vol->major_ver,
|
||||
vol->minor_ver);
|
||||
if (ntfs_is_version_supported(vol)) {
|
||||
fprintf(stderr, "Error: Unknown NTFS version.\n");
|
||||
fprintf(stderr, "Error: Unknown NTFS version.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" -*- nroff -*-
|
||||
.\" Copyright (c) 2002 Anton Altaparmakov. All Rights Reserved.
|
||||
.\" This file may be copied under the terms of the GNU Public License.
|
||||
.\"
|
||||
.\"
|
||||
.TH NTFSINFO 8 "May 2002" "Linux-NTFS version @VERSION@"
|
||||
.SH NAME
|
||||
ntfsinfo \- dump a file's attributes
|
||||
|
@ -19,7 +19,7 @@ will dump the attributes of inode
|
|||
was written by Matthew J. Fanto (fanto1mj@cmich.edu).
|
||||
.SH AVAILABILITY
|
||||
.B ntfsinfo
|
||||
is part of the linux-ntfs package and is available from
|
||||
is part of the linux-ntfs package and is available from
|
||||
http://linux-ntfs.sourceforge.net/.
|
||||
.SH SEE ALSO
|
||||
.BR ntfsprogs (8)
|
||||
|
|
|
@ -150,10 +150,10 @@ void print_standard_information_attr(ntfs_attr_search_ctx *ctx)
|
|||
standard_information_attr->version_number);
|
||||
printf("Class ID: %d\n",
|
||||
standard_information_attr->class_id);
|
||||
printf("Owner ID: %d\n",
|
||||
standard_information_attr->owner_id);
|
||||
printf("Security ID: %d\n",
|
||||
standard_information_attr->security_id);
|
||||
printf("Owner ID: %d\n",
|
||||
standard_information_attr->owner_id);
|
||||
printf("Security ID: %d\n",
|
||||
standard_information_attr->security_id);
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.\" Copyright (c) 2002 Anton Altaparmakov. All Rights Reserved.
|
||||
.\" This file may be copied under the terms of the GNU Public License.
|
||||
.\" Adapted from e2fsprogs-1.26/misc/e2label.8.in by Theodore Ts'o.
|
||||
.\"
|
||||
.\"
|
||||
.TH NTFSLABEL 8 "April 2002" "Linux-NTFS version @VERSION@"
|
||||
.SH NAME
|
||||
ntfslabel \- display/change the label on an ntfs file system
|
||||
|
@ -42,12 +42,12 @@ option of
|
|||
during creation of the file system.
|
||||
.PP
|
||||
.SH AUTHOR
|
||||
.B ntfslabel
|
||||
.B ntfslabel
|
||||
was written by Matthew J. Fanto (fanto1mj@cmich.edu). This man page was written
|
||||
by Anton Altaparmakov (aia21@cantab.net).
|
||||
.SH AVAILABILITY
|
||||
.B ntfslabel
|
||||
is part of the linux-ntfs package and is available from
|
||||
is part of the linux-ntfs package and is available from
|
||||
http://linux-ntfs.sourceforge.net/.
|
||||
.SH SEE ALSO
|
||||
.BR mkntfs (8),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" Copyright (c) 2002 Richard Russon. All Rights Reserved.
|
||||
.\" Copyright (c) 2002 Anton Altaparmakov. All Rights Reserved.
|
||||
.\" This file may be copied under the terms of the GNU Public License.
|
||||
.\"
|
||||
.\"
|
||||
.TH NTFSPROGS 8 "May 2002" "Linux-NTFS version @VERSION@"
|
||||
|
||||
.SH OVERVIEW
|
||||
|
|
|
@ -26,7 +26,7 @@ parameter may have one of the optional modifiers
|
|||
.I size
|
||||
parameter is given in kilo-, mega- or gigabytes respectively.
|
||||
.B ntfsresize
|
||||
conforms to the SI, ATA, IEEE standards and the disk manufacturers
|
||||
conforms to the SI, ATA, IEEE standards and the disk manufacturers
|
||||
by using k=10^3, M=10^6 and G=10^9.
|
||||
.PP
|
||||
The
|
||||
|
@ -37,13 +37,13 @@ If you wish to shrink an NTFS partition, first use
|
|||
to shrink the size of the filesystem. Then you may use
|
||||
.BR fdisk (8)
|
||||
to shrink the size of the partition by deleting the
|
||||
partition and recreating it with the smaller size.
|
||||
partition and recreating it with the smaller size.
|
||||
.PP
|
||||
.B IMPORTANT!
|
||||
When recreating the partition with
|
||||
.BR fdisk (8)
|
||||
make sure you create it with the same starting
|
||||
disk cylinder and partition type
|
||||
disk cylinder and partition type
|
||||
as before and you do not make it smaller than the new size
|
||||
of the NTFS filesystem! Otherwise you may lose your entire filesystem.
|
||||
Also make sure you set the bootable flag for the partition if it
|
||||
|
@ -54,7 +54,7 @@ Note,
|
|||
.B ntfsresize
|
||||
schedules 'chkdsk' to make an NTFS consistency check
|
||||
when you will boot Windows. If your partition was a
|
||||
system partition than Windows may intentionally reboot after
|
||||
system partition than Windows may intentionally reboot after
|
||||
the successful consistency check.
|
||||
|
||||
.SH OPTIONS
|
||||
|
|
|
@ -50,12 +50,12 @@ static const char *ntfs_report_banner =
|
|||
"\nReport bugs to linux-ntfs-dev@lists.sf.net. "
|
||||
"Homepage: http://linux-ntfs.sf.net\n";
|
||||
|
||||
static const char *resize_warning_msg =
|
||||
static const char *resize_warning_msg =
|
||||
"WARNING: Every sanity check passed and only the DANGEROUS operations left.\n"
|
||||
"Please make sure all your important data had been backed up in case of an\n"
|
||||
"unexpected failure!\n";
|
||||
|
||||
static const char *resize_important_msg =
|
||||
static const char *resize_important_msg =
|
||||
"NTFS had been successfully resized on device '%s'.\n"
|
||||
"You can go on to resize the device e.g. with 'fdisk'.\n"
|
||||
"IMPORTANT: When recreating the partition, make sure you\n"
|
||||
|
@ -65,7 +65,7 @@ static const char *resize_important_msg =
|
|||
" 4) set the bootable flag for the partition if it existed before\n"
|
||||
"Otherwise you may lose your data or can't boot your computer from the disk!\n";
|
||||
|
||||
static const char *fragmented_volume_msg =
|
||||
static const char *fragmented_volume_msg =
|
||||
"The volume end is fragmented, this case is not yet supported. Defragment it\n"
|
||||
"(Windows 2000, XP and .NET have built in defragmentation tool) and try again.\n";
|
||||
|
||||
|
@ -188,11 +188,11 @@ s64 get_new_volume_size(char *s)
|
|||
{
|
||||
s64 size;
|
||||
char *suffix;
|
||||
|
||||
|
||||
size = strtoll(s, &suffix, 10);
|
||||
if (size <= 0 || errno == ERANGE)
|
||||
err_exit("Illegal new volume size\n");
|
||||
|
||||
|
||||
if (!*suffix)
|
||||
return size;
|
||||
|
||||
|
@ -209,7 +209,7 @@ s64 get_new_volume_size(char *s)
|
|||
cfdisk 10^3 10^6 10^9
|
||||
sfdisk 2^10 2^20
|
||||
parted 2^10 2^20 (may change)
|
||||
fdisk (DOS) 2^10 2^20
|
||||
fdisk (DOS) 2^10 2^20
|
||||
*/
|
||||
/* FIXME: check for overflow */
|
||||
switch (*suffix) {
|
||||
|
@ -223,7 +223,7 @@ s64 get_new_volume_size(char *s)
|
|||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ void parse_options(int argc, char **argv)
|
|||
usage();
|
||||
}
|
||||
opt.ro_flag = MS_RDONLY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,7 +335,7 @@ void walk_attributes(MFT_RECORD *mr)
|
|||
ntfs_attr_search_ctx *ctx;
|
||||
|
||||
if (!(ctx = ntfs_get_attr_search_ctx(NULL, mr)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
while (!ntfs_walk_attrs(ctx)) {
|
||||
if (ctx->attr->type == AT_END)
|
||||
|
@ -356,7 +356,7 @@ void get_bitmap_data(ntfs_volume *vol, struct bitmap *bm)
|
|||
perr_exit("ntfs_open_inode");
|
||||
|
||||
if (!(ctx = ntfs_get_attr_search_ctx(ni, NULL)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
if (ntfs_lookup_attr(AT_DATA, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx))
|
||||
perr_exit("ntfs_lookup_attr");
|
||||
|
@ -418,7 +418,7 @@ void walk_inodes()
|
|||
s32 inode = 0;
|
||||
s64 last_mft_rec;
|
||||
MFT_REF mref;
|
||||
MFT_RECORD *mrec = NULL;
|
||||
MFT_RECORD *mrec = NULL;
|
||||
struct progress_bar progress;
|
||||
|
||||
printf("Scanning volume ...\n");
|
||||
|
@ -426,7 +426,7 @@ void walk_inodes()
|
|||
last_mft_rec = vol->nr_mft_records - 1;
|
||||
progress_init(&progress, inode, last_mft_rec, 100);
|
||||
|
||||
for (; inode <= last_mft_rec; inode++) {
|
||||
for (; inode <= last_mft_rec; inode++) {
|
||||
progress_update(&progress, inode);
|
||||
|
||||
mref = (MFT_REF)inode;
|
||||
|
@ -435,7 +435,7 @@ void walk_inodes()
|
|||
MFT record not in use based on $MFT bitmap */
|
||||
if (errno == EIO)
|
||||
continue;
|
||||
perr_exit("Reading inode %ld failed", inode);
|
||||
perr_exit("Reading inode %ld failed", inode);
|
||||
}
|
||||
if (!(mrec->flags & MFT_RECORD_IN_USE))
|
||||
continue;
|
||||
|
@ -455,31 +455,31 @@ void advise_on_resize()
|
|||
for (i = vol->nr_clusters - 1; i > 0; i--)
|
||||
if (ntfs_get_bit(lcn_bitmap.bm, i))
|
||||
break;
|
||||
|
||||
|
||||
i += 2; /* first free + we reserve one for the backup boot sector */
|
||||
fragmanted_end = (i >= vol->nr_clusters) ? 1 : 0;
|
||||
|
||||
|
||||
if (fragmanted_end || !opt.info) {
|
||||
printf(fragmented_volume_msg);
|
||||
if (fragmanted_end)
|
||||
exit(1);
|
||||
printf("Now ");
|
||||
}
|
||||
|
||||
|
||||
old_b = vol->nr_clusters * vol->cluster_size;
|
||||
old_mb = rounded_up_division(old_b, NTFS_MBYTE);
|
||||
new_b = i * vol->cluster_size;
|
||||
new_mb = rounded_up_division(new_b, NTFS_MBYTE);
|
||||
g_b = (vol->nr_clusters - i) * vol->cluster_size;
|
||||
g_mb = g_b / NTFS_MBYTE;
|
||||
|
||||
|
||||
printf("You could resize at %lld bytes ", new_b);
|
||||
|
||||
|
||||
if ((new_mb * NTFS_MBYTE) < old_b)
|
||||
printf("or %lld MB ", new_mb);
|
||||
|
||||
|
||||
printf("(freeing ");
|
||||
|
||||
|
||||
if (g_mb && (old_mb - new_mb))
|
||||
printf("%lld MB", old_mb - new_mb);
|
||||
else
|
||||
|
@ -658,7 +658,7 @@ void lookup_data_attr(MFT_REF mref, char *aname, ntfs_attr_search_ctx **ctx)
|
|||
perr_exit("Attribute list attribute not yet supported");
|
||||
|
||||
if (!(*ctx = ntfs_get_attr_search_ctx(ni, NULL)))
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
perr_exit("ntfs_get_attr_search_ctx");
|
||||
|
||||
if (aname && ((len = ntfs_mbstoucs(aname, &ustr, 0)) == -1))
|
||||
perr_exit("Unable to convert string to Unicode");
|
||||
|
@ -745,7 +745,7 @@ void update_bootsector(s64 nr_clusters)
|
|||
perr_exit("lseek");
|
||||
|
||||
if (read(vol->fd, &bs, sizeof(NTFS_BOOT_SECTOR)) == -1)
|
||||
perr_exit("read() error");
|
||||
perr_exit("read() error");
|
||||
|
||||
bs.number_of_sectors = nr_clusters * bs.bpb.sectors_per_cluster;
|
||||
bs.number_of_sectors = cpu_to_le64(bs.number_of_sectors);
|
||||
|
@ -762,9 +762,9 @@ void update_bootsector(s64 nr_clusters)
|
|||
void print_volume_size(char *str, ntfs_volume *v, s64 nr_clusters)
|
||||
{
|
||||
s64 b; /* volume size in bytes */
|
||||
|
||||
|
||||
b = nr_clusters * v->cluster_size;
|
||||
printf("%s: %lld bytes (%lld MB)\n",
|
||||
printf("%s: %lld bytes (%lld MB)\n",
|
||||
str, b, rounded_up_division(b, NTFS_MBYTE));
|
||||
}
|
||||
|
||||
|
@ -806,7 +806,7 @@ void mount_volume()
|
|||
|
||||
printf("NTFS volume version: %d.%d\n", vol->major_ver, vol->minor_ver);
|
||||
if (ntfs_is_version_supported(vol))
|
||||
perr_exit("Unknown NTFS version");
|
||||
perr_exit("Unknown NTFS version");
|
||||
|
||||
Dprintf("Cluster size : %u\n", vol->cluster_size);
|
||||
print_volume_size("Current volume size", vol, vol->nr_clusters);
|
||||
|
@ -817,11 +817,11 @@ void prepare_volume_fixup()
|
|||
{
|
||||
if (!opt.ro_flag) {
|
||||
u16 flags;
|
||||
|
||||
|
||||
flags = vol->flags | VOLUME_IS_DIRTY;
|
||||
if (vol->major_ver >= 2)
|
||||
flags |= VOLUME_MOUNTED_ON_NT4;
|
||||
|
||||
|
||||
printf("Schedule chkdsk NTFS consistency check at Windows boot time ...\n");
|
||||
if (ntfs_set_volume_flags(vol, flags))
|
||||
perr_exit("Failed to set $Volume dirty");
|
||||
|
@ -841,11 +841,11 @@ int main(int argc, char **argv)
|
|||
int i;
|
||||
|
||||
parse_options(argc, argv);
|
||||
|
||||
|
||||
mount_volume();
|
||||
|
||||
if (opt.bytes) {
|
||||
/* Take the integer part: when shrinking we don't want
|
||||
/* Take the integer part: when shrinking we don't want
|
||||
to make the volume to be bigger than requested.
|
||||
Later on we will also decrease this value to save
|
||||
room for the backup boot sector */
|
||||
|
@ -865,9 +865,9 @@ int main(int argc, char **argv)
|
|||
advise_on_resize();
|
||||
|
||||
/* FIXME: check new_volume_size validity */
|
||||
|
||||
/* Backup boot sector at the end of device isn't counted in NTFS
|
||||
volume size thus we have to reserve space for. We don't trust
|
||||
|
||||
/* Backup boot sector at the end of device isn't counted in NTFS
|
||||
volume size thus we have to reserve space for. We don't trust
|
||||
the user does this for us: better to be on the safe side ;) */
|
||||
if (new_volume_size)
|
||||
--new_volume_size;
|
||||
|
@ -896,7 +896,7 @@ int main(int argc, char **argv)
|
|||
truncate_bitmap_file(new_volume_size);
|
||||
update_bootsector(new_volume_size);
|
||||
|
||||
/* We don't create backup boot sector because we don't know where the
|
||||
/* We don't create backup boot sector because we don't know where the
|
||||
partition will be split. The scheduled chkdsk will fix it anyway */
|
||||
|
||||
if (opt.ro_flag) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.\" Copyright (c) 2002 Richard Russon. All Rights Reserved.
|
||||
.\" This file may be copied under the terms of the GNU Public License.
|
||||
.\"
|
||||
.\"
|
||||
.TH NTFSUNDELETE 8 "June 2002" "Linux\-NTFS version @VERSION@"
|
||||
.SH NAME
|
||||
ntfsundelete \- recover a deleted file from an NTFS volume.
|
||||
|
@ -52,7 +52,7 @@ representing the disk usage is updated. If the power isn't turned off
|
|||
immediately, the free space, where the file used to live, may become
|
||||
overwritten. Worse, the MFT Record may be reused for another file. If this
|
||||
happens it is impossible to tell where the file was on disk.
|
||||
.PP
|
||||
.PP
|
||||
Even if all the clusters of a file are not in use, there is no guarantee that
|
||||
they haven't been overwritten by some short\-lived file.
|
||||
.SS Locale
|
||||
|
@ -128,7 +128,7 @@ This option controls where to put the output file of the
|
|||
.B \-\-undelete
|
||||
and
|
||||
.B \-\-copy
|
||||
options.
|
||||
options.
|
||||
.TP
|
||||
.B \-f
|
||||
.br
|
||||
|
@ -329,7 +329,7 @@ was written by Richard Russon (FlatCap) <ntfs@flatcap.org>
|
|||
If you find this tool useful, make FlatCap happy and send him an email.
|
||||
.SH AVAILABILITY
|
||||
.B ntfsundelete
|
||||
is part of the linux\-ntfs package and is available from
|
||||
is part of the linux\-ntfs package and is available from
|
||||
.br
|
||||
.nh
|
||||
http://linux\-ntfs.sourceforge.net/downloads.html
|
||||
|
|
|
@ -185,7 +185,7 @@ void usage (void)
|
|||
* If transform fails, @regex will not be changed.
|
||||
*
|
||||
* Return: 1, Success, the string was transformed
|
||||
* 0, An error occurred
|
||||
* 0, An error occurred
|
||||
*/
|
||||
int transform (const char *pattern, char **regex)
|
||||
{
|
||||
|
@ -260,7 +260,7 @@ int transform (const char *pattern, char **regex)
|
|||
* If parse_time fails, @since will not be changed
|
||||
*
|
||||
* Return: 1 Success
|
||||
* 0 Error, the string was malformed
|
||||
* 0 Error, the string was malformed
|
||||
*/
|
||||
int parse_time (const char *value, time_t *since)
|
||||
{
|
||||
|
@ -329,7 +329,7 @@ int parse_time (const char *value, time_t *since)
|
|||
* If parse_size fails, @size will not be changed
|
||||
*
|
||||
* Return: 1 Success
|
||||
* 0 Error, the string was malformed
|
||||
* 0 Error, the string was malformed
|
||||
*/
|
||||
int parse_size (const char *value, long long *size)
|
||||
{
|
||||
|
@ -352,7 +352,7 @@ int parse_size (const char *value, long long *size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if (strlen (suffix) > 1) {
|
||||
Eprintf ("Invalid size suffix '%s'. Use T, G, M, or K.\n", suffix);
|
||||
return 0;
|
||||
|
@ -386,7 +386,7 @@ int parse_size (const char *value, long long *size)
|
|||
* string cannot be parsed correctly, @start and @finish will not be changed.
|
||||
*
|
||||
* Return: 1 Success, a valid string was found
|
||||
* 0 Error, the string was not a valid range
|
||||
* 0 Error, the string was not a valid range
|
||||
*/
|
||||
int parse_range (const char *string, long long *start, long long *finish)
|
||||
{
|
||||
|
@ -431,7 +431,7 @@ int parse_range (const char *string, long long *start, long long *finish)
|
|||
* This function is very long, but quite simple.
|
||||
*
|
||||
* Return: 1 Success
|
||||
* 0 Error, one or more problems
|
||||
* 0 Error, one or more problems
|
||||
*/
|
||||
int parse_options (int argc, char *argv[])
|
||||
{
|
||||
|
@ -728,7 +728,7 @@ time_t ntfs2utc (long long time)
|
|||
* has been created without an inode, it won't overflow the buffer.
|
||||
*
|
||||
* Return: Pointer Success, an attribute was found
|
||||
* NULL Error, no matching attributes were found
|
||||
* NULL Error, no matching attributes were found
|
||||
*/
|
||||
ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
|
||||
{
|
||||
|
@ -756,7 +756,7 @@ ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
|
|||
* the buffer, since we created the search context without an inode.
|
||||
*
|
||||
* Return: Pointer Success, an attribute was found
|
||||
* NULL Error, no matching attributes were found
|
||||
* NULL Error, no matching attributes were found
|
||||
*/
|
||||
ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft)
|
||||
{
|
||||
|
@ -798,7 +798,7 @@ ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft)
|
|||
* and its locale friendly name is put in pref_name.
|
||||
*
|
||||
* Return: n The number of $FILENAME attributes found
|
||||
* -1 Error
|
||||
* -1 Error
|
||||
*/
|
||||
int get_filenames (struct ufile *file)
|
||||
{
|
||||
|
@ -879,7 +879,7 @@ int get_filenames (struct ufile *file)
|
|||
* list of data streams in the file object.
|
||||
*
|
||||
* Return: n The number of $FILENAME attributes found
|
||||
* -1 Error
|
||||
* -1 Error
|
||||
*/
|
||||
int get_data (struct ufile *file, ntfs_volume *vol)
|
||||
{
|
||||
|
@ -953,7 +953,7 @@ int get_data (struct ufile *file, ntfs_volume *vol)
|
|||
* possible.
|
||||
*
|
||||
* Return: Pointer A ufile object containing the results
|
||||
* NULL Error
|
||||
* NULL Error
|
||||
*/
|
||||
struct ufile * read_record (ntfs_volume *vol, long long record)
|
||||
{
|
||||
|
@ -998,9 +998,9 @@ struct ufile * read_record (ntfs_volume *vol, long long record)
|
|||
ntfs_attr_close (mft);
|
||||
mft = NULL;
|
||||
|
||||
attr10 = find_first_attribute (AT_STANDARD_INFORMATION, file->mft);
|
||||
attr20 = find_first_attribute (AT_ATTRIBUTE_LIST, file->mft);
|
||||
attr90 = find_first_attribute (AT_INDEX_ROOT, file->mft);
|
||||
attr10 = find_first_attribute (AT_STANDARD_INFORMATION, file->mft);
|
||||
attr20 = find_first_attribute (AT_ATTRIBUTE_LIST, file->mft);
|
||||
attr90 = find_first_attribute (AT_INDEX_ROOT, file->mft);
|
||||
|
||||
Dprintf ("Attributes present: %s %s %s\n", attr10?"0x10":"", attr20?"0x20":"", attr90?"0x90":"");
|
||||
|
||||
|
@ -1041,8 +1041,8 @@ struct ufile * read_record (ntfs_volume *vol, long long record)
|
|||
* refreshed.
|
||||
*
|
||||
* Return: 1 Cluster is in use
|
||||
* 0 Cluster is free space
|
||||
* -1 Error occurred
|
||||
* 0 Cluster is free space
|
||||
* -1 Error occurred
|
||||
*/
|
||||
int cluster_in_use (ntfs_volume *vol, long long lcn)
|
||||
{
|
||||
|
@ -1106,7 +1106,7 @@ int cluster_in_use (ntfs_volume *vol, long long lcn)
|
|||
* will return 0%.
|
||||
*
|
||||
* Return: n The percentage of the file that _could_ be recovered
|
||||
* -1 Error
|
||||
* -1 Error
|
||||
*/
|
||||
int calc_percentage (struct ufile *file, ntfs_volume *vol)
|
||||
{
|
||||
|
@ -1250,12 +1250,12 @@ void dump_record (struct ufile *file)
|
|||
|
||||
Iprintf ("Filename: (%d) %s\n", f->name_space, f->name);
|
||||
Iprintf ("File Flags: ");
|
||||
if (f->flags & FILE_ATTR_SYSTEM) Iprintf ("System ");
|
||||
if (f->flags & FILE_ATTR_DIRECTORY) Iprintf ("Directory ");
|
||||
if (f->flags & FILE_ATTR_SPARSE_FILE) Iprintf ("Sparse ");
|
||||
if (f->flags & FILE_ATTR_REPARSE_POINT) Iprintf ("Reparse ");
|
||||
if (f->flags & FILE_ATTR_COMPRESSED) Iprintf ("Compressed ");
|
||||
if (f->flags & FILE_ATTR_ENCRYPTED) Iprintf ("Encrypted ");
|
||||
if (f->flags & FILE_ATTR_SYSTEM) Iprintf ("System ");
|
||||
if (f->flags & FILE_ATTR_DIRECTORY) Iprintf ("Directory ");
|
||||
if (f->flags & FILE_ATTR_SPARSE_FILE) Iprintf ("Sparse ");
|
||||
if (f->flags & FILE_ATTR_REPARSE_POINT) Iprintf ("Reparse ");
|
||||
if (f->flags & FILE_ATTR_COMPRESSED) Iprintf ("Compressed ");
|
||||
if (f->flags & FILE_ATTR_ENCRYPTED) Iprintf ("Encrypted ");
|
||||
if (!(f->flags & (FILE_ATTR_SYSTEM || FILE_ATTR_DIRECTORY ||
|
||||
FILE_ATTR_SPARSE_FILE || FILE_ATTR_REPARSE_POINT ||
|
||||
FILE_ATTR_COMPRESSED || FILE_ATTR_ENCRYPTED))) {
|
||||
|
@ -1356,7 +1356,7 @@ void list_record (struct ufile *file)
|
|||
|
||||
if (!d->name) {
|
||||
if (d->resident) flagr = 'R';
|
||||
else flagr = 'N';
|
||||
else flagr = 'N';
|
||||
if (d->compressed) flagc = 'C'; /* These two are mutually exclusive */
|
||||
if (d->encrypted) flagc = 'E';
|
||||
|
||||
|
@ -1386,7 +1386,7 @@ void list_record (struct ufile *file)
|
|||
* regular expression, created with regcomp.
|
||||
*
|
||||
* Return: 1 There is a matching filename.
|
||||
* 0 There is no match.
|
||||
* 0 There is no match.
|
||||
*/
|
||||
int name_match (regex_t *re, struct ufile *file)
|
||||
{
|
||||
|
@ -1424,7 +1424,7 @@ int name_match (regex_t *re, struct ufile *file)
|
|||
* Write a block of data to a file descriptor.
|
||||
*
|
||||
* Return: -1 Error, something went wrong
|
||||
* 0 Success, all the data was written
|
||||
* 0 Success, all the data was written
|
||||
*/
|
||||
unsigned int write_data (int fd, const char *buffer, unsigned int bufsize)
|
||||
{
|
||||
|
@ -1462,7 +1462,7 @@ unsigned int write_data (int fd, const char *buffer, unsigned int bufsize)
|
|||
* name is present it will be appended to the filename, delimited by a colon.
|
||||
*
|
||||
* Return: -1 Error, failed to create the file
|
||||
* n Success, this is the file descriptor
|
||||
* n Success, this is the file descriptor
|
||||
*/
|
||||
int open_file (const char *dir, const char *name, const char *stream)
|
||||
{
|
||||
|
@ -1504,7 +1504,7 @@ int open_file (const char *dir, const char *name, const char *stream)
|
|||
* The list can be filtered by name, size and date, using command line options.
|
||||
*
|
||||
* Return: -1 Error, something went wrong
|
||||
* n Success, the number of recoverable files
|
||||
* n Success, the number of recoverable files
|
||||
*/
|
||||
int scan_disk (ntfs_volume *vol)
|
||||
{
|
||||
|
@ -1627,7 +1627,7 @@ out:
|
|||
* file was deleted.
|
||||
*
|
||||
* Return: 0 Error, something went wrong
|
||||
* 1 Success, the data was recovered
|
||||
* 1 Success, the data was recovered
|
||||
*/
|
||||
int undelete_file (ntfs_volume *vol, long long inode)
|
||||
{
|
||||
|
@ -1808,14 +1808,14 @@ free:
|
|||
|
||||
/**
|
||||
* copy_mft - Write a range of MFT Records to a file
|
||||
* @vol: An ntfs volume obtained from ntfs_mount
|
||||
* @mft_begin: First MFT Record to save
|
||||
* @mft_end: Last MFT Record to save
|
||||
* @vol: An ntfs volume obtained from ntfs_mount
|
||||
* @mft_begin: First MFT Record to save
|
||||
* @mft_end: Last MFT Record to save
|
||||
*
|
||||
* Read a number of MFT Records and write them to a file.
|
||||
*
|
||||
* Return: 0 Success, all the records were written
|
||||
* 1 Error, something went wrong
|
||||
* 1 Error, something went wrong
|
||||
*/
|
||||
int copy_mft (ntfs_volume *vol, long long mft_begin, long long mft_end)
|
||||
{
|
||||
|
@ -1897,14 +1897,14 @@ free:
|
|||
* These checks can be overridden by using the force option.
|
||||
*
|
||||
* Return: 1 Success, we can continue
|
||||
* 0 Error, we cannot use this device
|
||||
* 0 Error, we cannot use this device
|
||||
*/
|
||||
int valid_device (const char *name, int force)
|
||||
{
|
||||
unsigned long mnt_flags = 0;
|
||||
struct stat st;
|
||||
|
||||
if (stat (name, &st) == -1) {
|
||||
if (stat (name, &st) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
Eprintf ("The device %s doesn't exist\n", name);
|
||||
} else {
|
||||
|
@ -1913,7 +1913,7 @@ int valid_device (const char *name, int force)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!S_ISBLK (st.st_mode)) {
|
||||
if (!S_ISBLK (st.st_mode)) {
|
||||
Vprintf ("%s is not a block device.\n", name);
|
||||
if (!force) {
|
||||
Eprintf ("Use the force option to work with files.\n");
|
||||
|
@ -1949,7 +1949,7 @@ int valid_device (const char *name, int force)
|
|||
* Start from here.
|
||||
*
|
||||
* Return: 0 Success, the program worked
|
||||
* 1 Error, something went wrong
|
||||
* 1 Error, something went wrong
|
||||
*/
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ void Dprintf (const char *format, ...)
|
|||
* Read $Bitmap and wipe any clusters that are marked as not in use.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_unused (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ int wipe_unused (ntfs_volume *vol, int byte)
|
|||
* the cluster size, there is some slack space at the end. Wipe this space.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_tails (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ int wipe_tails (ntfs_volume *vol, int byte)
|
|||
* unused space at the end of the record and wipe any unused records.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_mft (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ int wipe_mft (ntfs_volume *vol, int byte)
|
|||
* the unused space at the ends of these blocks.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_directory (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ int wipe_directory (ntfs_volume *vol, int byte)
|
|||
* volume is in a consistant state, then this information can be erased.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_logfile (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ int wipe_logfile (ntfs_volume *vol, int byte)
|
|||
* Windows recreates the file at bootup, so it can be wiped without harm.
|
||||
*
|
||||
* Return: 1 Success, the clusters were wiped
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int wipe_pagefile (ntfs_volume *vol, int byte)
|
||||
{
|
||||
|
@ -224,9 +224,9 @@ int wipe_pagefile (ntfs_volume *vol, int byte)
|
|||
*
|
||||
* Tell the user how much could be cleaned up. List the number of free
|
||||
* clusters, MFT records, etc.
|
||||
*
|
||||
*
|
||||
* Return: 1 Success, displayed some info
|
||||
* 0 Error, something went wrong
|
||||
* 0 Error, something went wrong
|
||||
*/
|
||||
int ntfs_info (ntfs_volume *vol)
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ void usage (void)
|
|||
* N.B. If the function fails, @result is not changed.
|
||||
*
|
||||
* Return: 0 Error, invalid string
|
||||
* n Success, the count of numbers parsed
|
||||
* n Success, the count of numbers parsed
|
||||
*/
|
||||
int parse_list (const char *list, int **result)
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ int parse_list (const char *list, int **result)
|
|||
* This function is very long, but quite simple.
|
||||
*
|
||||
* Return: 1 Success
|
||||
* 0 Error, one or more problems
|
||||
* 0 Error, one or more problems
|
||||
*/
|
||||
int parse_options (int argc, char *argv[])
|
||||
{
|
||||
|
@ -545,14 +545,14 @@ int parse_options (int argc, char *argv[])
|
|||
* These checks can be overridden by using the force option.
|
||||
*
|
||||
* Return: 1 Success, we can continue
|
||||
* 0 Error, we cannot use this device
|
||||
* 0 Error, we cannot use this device
|
||||
*/
|
||||
int valid_device (const char *name, int force)
|
||||
{
|
||||
unsigned long mnt_flags = 0;
|
||||
struct stat st;
|
||||
|
||||
if (stat (name, &st) == -1) {
|
||||
if (stat (name, &st) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
Eprintf ("The device %s doesn't exist\n", name);
|
||||
} else {
|
||||
|
@ -561,7 +561,7 @@ int valid_device (const char *name, int force)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!S_ISBLK (st.st_mode)) {
|
||||
if (!S_ISBLK (st.st_mode)) {
|
||||
Vprintf ("%s is not a block device.\n", name);
|
||||
if (!force) {
|
||||
Eprintf ("Use the force option to work with files.\n");
|
||||
|
@ -640,7 +640,7 @@ void print_summary (void)
|
|||
* Start from here.
|
||||
*
|
||||
* Return: 0 Success, the program worked
|
||||
* 1 Error, something went wrong
|
||||
* 1 Error, something went wrong
|
||||
*/
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue