Fixes for making strict endians branch compile after merge.
parent
34bb449324
commit
3e3ef8901c
|
@ -463,7 +463,7 @@ void showname(const char *prefix, const char *name, int cnt)
|
|||
|
||||
printf("%s",prefix);
|
||||
n = (const le16*)name;
|
||||
for (i=0; (i<cnt) && n[i]; i++) {
|
||||
for (i=0; (i<cnt) && !le16_cmpz(n[i]); i++) {
|
||||
c = le16_to_cpu(n[i]);
|
||||
if (c < 0x20)
|
||||
printf(".");
|
||||
|
@ -678,62 +678,62 @@ const char *mftattrname(ATTR_TYPES attr)
|
|||
static char badattr[24];
|
||||
const char *p;
|
||||
|
||||
switch (attr) {
|
||||
case AT_STANDARD_INFORMATION :
|
||||
/* switch (attr) { */
|
||||
if (le32_eq(attr, AT_STANDARD_INFORMATION)) {
|
||||
p = "Standard-Information";
|
||||
break;
|
||||
case AT_ATTRIBUTE_LIST :
|
||||
}
|
||||
else if (le32_eq(attr, AT_ATTRIBUTE_LIST)) {
|
||||
p = "Attribute-List";
|
||||
break;
|
||||
case AT_FILE_NAME :
|
||||
}
|
||||
else if (le32_eq(attr, AT_FILE_NAME)) {
|
||||
p = "Name";
|
||||
break;
|
||||
case AT_OBJECT_ID :
|
||||
}
|
||||
else if (le32_eq(attr, AT_OBJECT_ID)) {
|
||||
p = "Volume-Version";
|
||||
break;
|
||||
case AT_SECURITY_DESCRIPTOR :
|
||||
}
|
||||
else if (le32_eq(attr, AT_SECURITY_DESCRIPTOR)) {
|
||||
p = "Security-Descriptor";
|
||||
break;
|
||||
case AT_VOLUME_NAME :
|
||||
}
|
||||
else if (le32_eq(attr, AT_VOLUME_NAME)) {
|
||||
p = "Volume-Name";
|
||||
break;
|
||||
case AT_VOLUME_INFORMATION :
|
||||
}
|
||||
else if (le32_eq(attr, AT_VOLUME_INFORMATION)) {
|
||||
p = "Volume-Information";
|
||||
break;
|
||||
case AT_DATA :
|
||||
}
|
||||
else if (le32_eq(attr, AT_DATA)) {
|
||||
p = "Data";
|
||||
break;
|
||||
case AT_INDEX_ROOT :
|
||||
}
|
||||
else if (le32_eq(attr, AT_INDEX_ROOT)) {
|
||||
p = "Index-Root";
|
||||
break;
|
||||
case AT_INDEX_ALLOCATION :
|
||||
}
|
||||
else if (le32_eq(attr, AT_INDEX_ALLOCATION)) {
|
||||
p = "Index-Allocation";
|
||||
break;
|
||||
case AT_BITMAP :
|
||||
}
|
||||
else if (le32_eq(attr, AT_BITMAP)) {
|
||||
p = "Bitmap";
|
||||
break;
|
||||
case AT_REPARSE_POINT :
|
||||
}
|
||||
else if (le32_eq(attr, AT_REPARSE_POINT)) {
|
||||
p = "Reparse-Point";
|
||||
break;
|
||||
case AT_EA_INFORMATION :
|
||||
}
|
||||
else if (le32_eq(attr, AT_EA_INFORMATION)) {
|
||||
p = "EA-Information";
|
||||
break;
|
||||
case AT_EA :
|
||||
}
|
||||
else if (le32_eq(attr, AT_EA)) {
|
||||
p = "EA";
|
||||
break;
|
||||
case AT_PROPERTY_SET :
|
||||
}
|
||||
else if (le32_eq(attr, AT_PROPERTY_SET)) {
|
||||
p = "Property-Set";
|
||||
break;
|
||||
case AT_LOGGED_UTILITY_STREAM :
|
||||
}
|
||||
else if (le32_eq(attr, AT_LOGGED_UTILITY_STREAM)) {
|
||||
p = "Logged-Utility-Stream";
|
||||
break;
|
||||
case AT_END :
|
||||
}
|
||||
else if (le32_eq(attr, AT_END)) {
|
||||
p = "End";
|
||||
break;
|
||||
default :
|
||||
sprintf(badattr,"*0x%x-Unknown*",attr);
|
||||
}
|
||||
else {
|
||||
sprintf(badattr, "*0x%x-Unknown*", le32_to_cpu(attr));
|
||||
p = badattr;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
return (p);
|
||||
}
|
||||
|
@ -741,7 +741,7 @@ const char *mftattrname(ATTR_TYPES attr)
|
|||
static void showattribute(const char *prefix, const struct ATTR *pa)
|
||||
{
|
||||
if (pa) {
|
||||
if (pa->type) {
|
||||
if (!le32_cmpz(pa->type)) {
|
||||
printf("%sattr 0x%x : inode %lld type %s",
|
||||
prefix, pa->key, (long long)pa->inode,
|
||||
mftattrname(pa->type));
|
||||
|
@ -798,7 +798,7 @@ u32 get_undo_offset(const struct LOG_RECORD *logr)
|
|||
{
|
||||
u32 offset;
|
||||
|
||||
if (logr->lcns_to_follow)
|
||||
if (!le16_cmpz(logr->lcns_to_follow))
|
||||
offset = 0x30 + le16_to_cpu(logr->undo_offset);
|
||||
else
|
||||
offset = 0x28 + le16_to_cpu(logr->undo_offset);
|
||||
|
@ -809,7 +809,7 @@ u32 get_redo_offset(const struct LOG_RECORD *logr)
|
|||
{
|
||||
u32 offset;
|
||||
|
||||
if (logr->lcns_to_follow)
|
||||
if (!le16_cmpz(logr->lcns_to_follow))
|
||||
offset = 0x30 + le16_to_cpu(logr->redo_offset);
|
||||
else
|
||||
offset = 0x28 + le16_to_cpu(logr->redo_offset);
|
||||
|
@ -843,7 +843,7 @@ static BOOL likelyop(const struct LOG_RECORD *logr)
|
|||
&& !(le16_to_cpu(logr->redo_offset) & 7)
|
||||
&& !(le16_to_cpu(logr->undo_offset) & 7)
|
||||
/* transaction id must not be null */
|
||||
&& logr->transaction_id
|
||||
&& !le32_cmpz(logr->transaction_id)
|
||||
/* client data length aligned to 8 bytes */
|
||||
&& !(le32_to_cpu(logr->client_data_length) & 7)
|
||||
/* client data length less than 64K (131K ?) */
|
||||
|
@ -855,10 +855,10 @@ static BOOL likelyop(const struct LOG_RECORD *logr)
|
|||
&& (!le16_to_cpu(logr->undo_length)
|
||||
|| ((unsigned int)le16_to_cpu(logr->undo_offset) >= 0x28));
|
||||
/* undo data and redo data should be contiguous when both present */
|
||||
if (likely && logr->redo_length && logr->undo_length) {
|
||||
if (likely && !le16_cmpz(logr->redo_length) && !le16_cmpz(logr->undo_length)) {
|
||||
/* undo and redo data may be the same when both present and same size */
|
||||
if (logr->undo_offset == logr->redo_offset) {
|
||||
if (logr->redo_length != logr->undo_length)
|
||||
if (le16_eq(logr->undo_offset, logr->redo_offset)) {
|
||||
if (!le16_eq(logr->redo_length, logr->undo_length))
|
||||
likely = FALSE;
|
||||
} else {
|
||||
if (le16_to_cpu(logr->redo_offset)
|
||||
|
@ -885,14 +885,14 @@ static BOOL likelyop(const struct LOG_RECORD *logr)
|
|||
* undo and redo operations are null
|
||||
* or CompensationlogRecord with no data
|
||||
*/
|
||||
likely = (!logr->redo_operation
|
||||
|| ((logr->redo_operation == const_cpu_to_le16(1))
|
||||
&& !logr->redo_length))
|
||||
&& (!logr->undo_operation
|
||||
|| ((logr->undo_operation == const_cpu_to_le16(1))
|
||||
&& !logr->undo_length))
|
||||
likely = (le16_cmpz(logr->redo_operation)
|
||||
|| (le16_eq(logr->redo_operation, const_cpu_to_le16(1))
|
||||
&& le16_cmpz(logr->redo_length)))
|
||||
&& (le16_cmpz(logr->undo_operation)
|
||||
|| (le16_eq(logr->undo_operation, const_cpu_to_le16(1))
|
||||
&& le16_cmpz(logr->undo_length)))
|
||||
/* transaction id must be null */
|
||||
&& !logr->transaction_id
|
||||
&& le32_cmpz(logr->transaction_id)
|
||||
/* client_data_length is 0x68 or 0x70 (Vista and subsequent) */
|
||||
&& ((le32_to_cpu(logr->client_data_length) == 0x68)
|
||||
|| (le32_to_cpu(logr->client_data_length) == 0x70));
|
||||
|
@ -979,7 +979,7 @@ static u16 firstrecord(int skipped, const struct BUFFER *buf,
|
|||
/* Minimal size is apparently 48 : offset of redo_operation */
|
||||
if (k && ((blocksz - k) >= LOG_RECORD_HEAD_SZ)) {
|
||||
logr = (const struct LOG_RECORD*)&prevdata[k];
|
||||
if (!logr->client_data_length) {
|
||||
if (le32_cmpz(logr->client_data_length)) {
|
||||
/*
|
||||
* Sometimes the end of record is free space.
|
||||
* This apparently means reaching the end of
|
||||
|
@ -1119,9 +1119,9 @@ static const struct BUFFER *findprevious(CONTEXT *ctx, const struct BUFFER *buf)
|
|||
prevbuf = read_buffer(ctx, prevblk);
|
||||
if (prevbuf) {
|
||||
rph = &prevbuf->block.record;
|
||||
prevmiddle = !(rph->flags
|
||||
& const_cpu_to_le32(1))
|
||||
|| !rph->next_record_offset;
|
||||
prevmiddle = le32_andz(rph->flags,
|
||||
const_cpu_to_le32(1))
|
||||
|| le16_cmpz(rph->next_record_offset);
|
||||
if (prevmiddle) {
|
||||
savebuf = prevbuf;
|
||||
skipped++;
|
||||
|
@ -1195,7 +1195,7 @@ static int refresh_attributes(const struct ACTION_RECORD *firstaction)
|
|||
case OpenNonResidentAttribute :
|
||||
extra = get_extra_offset(logr)
|
||||
- get_redo_offset(logr);
|
||||
if (logr->undo_length) {
|
||||
if (!le16_cmpz(logr->undo_length)) {
|
||||
len = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ
|
||||
- get_extra_offset(logr);
|
||||
|
@ -1350,7 +1350,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
printf(" attrib 0x%lx (%s) at offset 0x%x\n",
|
||||
(long)le32_to_cpu(mftattr),
|
||||
mftattrname(mftattr), (int)base);
|
||||
if (mftattr == AT_FILE_NAME) {
|
||||
if (le32_eq(mftattr, AT_FILE_NAME)) {
|
||||
showname(" name ",&buf[base + 90],
|
||||
buf[base + 88] & 255);
|
||||
inode = feedle64(buf, base + 24);
|
||||
|
@ -1429,7 +1429,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
firstpos = 0x30 + (((mftrecsz/512 + 1)*2 - 1 ) | 7) + 1;
|
||||
if (pa
|
||||
&& !pa->inode
|
||||
&& (pa->type == const_cpu_to_le32(0x80))
|
||||
&& le32_eq(pa->type, const_cpu_to_le32(0x80))
|
||||
&& !(offs & 3)
|
||||
&& (le16_to_cpu(logr->record_offset) == firstpos)) {
|
||||
printf(" set standard information, attr 0x%x\n",attr);
|
||||
|
@ -1572,8 +1572,8 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
inode = feedle64(buf,16);
|
||||
printf(" parent dir inode %lld\n",
|
||||
(long long)MREF(le64_to_cpu(inode)));
|
||||
if (feedle32(buf,72)
|
||||
& const_cpu_to_le32(0x10000000))
|
||||
if (!le32_andz(feedle32(buf,72),
|
||||
const_cpu_to_le32(0x10000000)))
|
||||
showname(" file (dir) ",
|
||||
&buf[base + 82],
|
||||
buf[base + 80] & 255);
|
||||
|
@ -1622,7 +1622,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
showattribute(" ",pa);
|
||||
if (pa
|
||||
&& !pa->inode
|
||||
&& (pa->type == const_cpu_to_le32(0x80))
|
||||
&& le32_eq(pa->type, const_cpu_to_le32(0x80))
|
||||
&& !(offs & 3)) {
|
||||
if (base >= -24)
|
||||
showdate(" created ",feedle64(buf,
|
||||
|
@ -1653,7 +1653,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
}
|
||||
} else {
|
||||
/* Usually caused by attr not yet defined */
|
||||
if (pa && pa->type)
|
||||
if (pa && !le32_cmpz(pa->type))
|
||||
printf("** Unexpected index parameters\n");
|
||||
}
|
||||
break;
|
||||
|
@ -1709,7 +1709,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
extra = get_extra_offset(logr)
|
||||
- (redo ? get_redo_offset(logr)
|
||||
: get_undo_offset(logr));
|
||||
if (logr->undo_length) {
|
||||
if (!le16_cmpz(logr->undo_length)) {
|
||||
len = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ
|
||||
- get_extra_offset(logr);
|
||||
|
@ -1735,7 +1735,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
|||
printf(" inode %lld\n",
|
||||
(long long)pa->inode);
|
||||
}
|
||||
if (logr->undo_length)
|
||||
if (!le16_cmpz(logr->undo_length))
|
||||
showname(" extra : attr name ", &buf[extra], len/2);
|
||||
if (!redo && length) {
|
||||
printf(" * undo attr not shown\n");
|
||||
|
@ -1846,7 +1846,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
|
||||
switch (le32_to_cpu(logr->record_type)) {
|
||||
case 1 :
|
||||
onmft = logr->cluster_index
|
||||
onmft = !le16_cmpz(logr->cluster_index)
|
||||
|| acts_on_mft(le16_to_cpu(logr->redo_operation))
|
||||
|| acts_on_mft(le16_to_cpu(logr->undo_operation));
|
||||
printf("redo_operation %04x %s\n",
|
||||
|
@ -1925,7 +1925,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
* 4) extra : unknown data (end of undo to data_length)
|
||||
*/
|
||||
end = le32_to_cpu(logr->client_data_length) + LOG_RECORD_HEAD_SZ;
|
||||
if (logr->redo_length && logr->undo_length)
|
||||
if (!le16_cmpz(logr->redo_length) && !le16_cmpz(logr->undo_length))
|
||||
{
|
||||
/* both undo and redo are present */
|
||||
if (le16_to_cpu(logr->undo_offset) <=
|
||||
|
@ -1933,7 +1933,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
{
|
||||
undo = sizeof(LOG_RECORD) - 8
|
||||
+ 8*le16_to_cpu(logr->lcns_to_follow);
|
||||
if (logr->redo_offset == logr->undo_offset)
|
||||
if (le16_eq(logr->redo_offset, logr->undo_offset))
|
||||
redo = undo;
|
||||
else
|
||||
redo = undo + ((le16_to_cpu(logr->undo_length) - 1) | 7) + 1;
|
||||
|
@ -1948,7 +1948,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
}
|
||||
}
|
||||
else
|
||||
if (logr->redo_length)
|
||||
if (!le16_cmpz(logr->redo_length))
|
||||
{
|
||||
/* redo and not undo */
|
||||
redo = undo = sizeof(LOG_RECORD) - 8
|
||||
|
@ -1968,11 +1968,11 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
undo,(int)(((le16_to_cpu(logr->undo_length) - 1) | 7) + 1),
|
||||
extra,(int)(end > extra ? end - extra : 0));
|
||||
|
||||
if (logr->redo_length && (get_redo_offset(logr) != redo))
|
||||
if (!le16_cmpz(logr->redo_length) && (get_redo_offset(logr) != redo))
|
||||
printf("** Unexpected redo offset 0x%x %u (%u)\n",
|
||||
get_redo_offset(logr),(int)redo,
|
||||
(int)le16_to_cpu(logr->lcns_to_follow));
|
||||
if (logr->undo_length && (get_undo_offset(logr) != undo))
|
||||
if (!le16_cmpz(logr->undo_length) && (get_undo_offset(logr) != undo))
|
||||
printf("** Unexpected undo offset 0x%x %u (%u)\n",
|
||||
get_undo_offset(logr),(int)undo,
|
||||
(int)le16_to_cpu(logr->lcns_to_follow));
|
||||
|
@ -1984,9 +1984,9 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
if (extra <= end)
|
||||
{
|
||||
/* show redo data */
|
||||
if (logr->redo_length)
|
||||
if (!le16_cmpz(logr->redo_length))
|
||||
{
|
||||
if (logr->lcns_to_follow)
|
||||
if (!le16_cmpz(logr->lcns_to_follow))
|
||||
{
|
||||
off = le16_to_cpu(logr->record_offset)
|
||||
+ le16_to_cpu(logr->attribute_offset);
|
||||
|
@ -2013,9 +2013,9 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
}
|
||||
|
||||
/* show undo data */
|
||||
if (logr->undo_length)
|
||||
if (!le16_cmpz(logr->undo_length))
|
||||
{
|
||||
if (logr->lcns_to_follow)
|
||||
if (!le16_cmpz(logr->lcns_to_follow))
|
||||
{
|
||||
off = le16_to_cpu(logr->record_offset)
|
||||
+ le16_to_cpu(logr->attribute_offset);
|
||||
|
@ -2059,10 +2059,10 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
|||
else
|
||||
{
|
||||
/* sometimes the designated data overflows */
|
||||
if (logr->redo_length
|
||||
if (!le16_cmpz(logr->redo_length)
|
||||
&& ((u32)(redo + le16_to_cpu(logr->redo_length)) > end))
|
||||
printf("* redo data overflows from record\n");
|
||||
if (logr->undo_length
|
||||
if (!le16_cmpz(logr->undo_length)
|
||||
&& ((u32)(undo + le16_to_cpu(logr->undo_length)) > end))
|
||||
printf("* undo data overflows from record\n");
|
||||
}
|
||||
|
@ -2165,7 +2165,7 @@ static void showlogr(CONTEXT *ctx, int k, const struct LOG_RECORD *logr)
|
|||
if (optt) {
|
||||
const char *state;
|
||||
|
||||
if (logr->record_type == const_cpu_to_le32(2))
|
||||
if (le32_eq(logr->record_type, const_cpu_to_le32(2)))
|
||||
state = "--checkpoint--";
|
||||
else
|
||||
state = commitment(sle64_to_cpu(logr->this_lsn));
|
||||
|
@ -2174,9 +2174,9 @@ static void showlogr(CONTEXT *ctx, int k, const struct LOG_RECORD *logr)
|
|||
state,
|
||||
(long)(sle64_to_cpu(logr->this_lsn) - synced_lsn),
|
||||
actionname(le16_to_cpu(logr->redo_operation)));
|
||||
if (logr->client_previous_lsn || logr->client_undo_next_lsn) {
|
||||
if (logr->client_previous_lsn
|
||||
== logr->client_undo_next_lsn) {
|
||||
if (!sle64_cmpz(logr->client_previous_lsn) || !sle64_cmpz(logr->client_undo_next_lsn)) {
|
||||
if (sle64_eq(logr->client_previous_lsn,
|
||||
logr->client_undo_next_lsn)) {
|
||||
printf(" "
|
||||
" previous and undo %016llx\n",
|
||||
(long long)sle64_to_cpu(
|
||||
|
@ -2187,7 +2187,7 @@ static void showlogr(CONTEXT *ctx, int k, const struct LOG_RECORD *logr)
|
|||
(long long)sle64_to_cpu(
|
||||
logr->client_previous_lsn));
|
||||
|
||||
if (logr->client_undo_next_lsn)
|
||||
if (!sle64_cmpz(logr->client_undo_next_lsn))
|
||||
printf(" undo %016llx\n",
|
||||
(long long)sle64_to_cpu(
|
||||
logr->client_undo_next_lsn));
|
||||
|
@ -2217,10 +2217,10 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
|
|||
id = const_cpu_to_le32(0);
|
||||
for (action=lastaction; action; action=action->prev) {
|
||||
logr = &action->record;
|
||||
if ((logr->redo_operation
|
||||
== const_cpu_to_le16(ForgetTransaction))
|
||||
if (le16_eq(logr->redo_operation,
|
||||
const_cpu_to_le16(ForgetTransaction))
|
||||
&& !(action->flags & ACTION_TO_REDO)
|
||||
&& !id) {
|
||||
&& le32_cmpz(id)) {
|
||||
id = logr->transaction_id;
|
||||
action->flags |= ACTION_TO_REDO;
|
||||
if (optv)
|
||||
|
@ -2229,11 +2229,11 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
|
|||
}
|
||||
committed = ((s64)(sle64_to_cpu(logr->this_lsn)
|
||||
- committed_lsn)) <= 0;
|
||||
if (!logr->transaction_id
|
||||
if (le32_cmpz(logr->transaction_id)
|
||||
&& committed)
|
||||
action->flags |= ACTION_TO_REDO;
|
||||
if (id
|
||||
&& (logr->transaction_id == id)
|
||||
if (!le32_cmpz(id)
|
||||
&& le32_eq(logr->transaction_id, id)
|
||||
&& committed) {
|
||||
action->flags |= ACTION_TO_REDO;
|
||||
more = TRUE;
|
||||
|
@ -2248,7 +2248,7 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
|
|||
if (optv) {
|
||||
for (action=lastaction; action; action=action->prev) {
|
||||
logr = &action->record;
|
||||
if (logr->transaction_id
|
||||
if (!le32_cmpz(logr->transaction_id)
|
||||
&& !(action->flags & ACTION_TO_REDO))
|
||||
printf("** Action %d was aborted\n",
|
||||
(int)action->num);
|
||||
|
@ -2289,7 +2289,7 @@ static TRISTATE enqueue_action(CONTEXT *ctx, const struct LOG_RECORD *logr,
|
|||
err = 0;
|
||||
state = T_OK;
|
||||
if ((optp || optu)
|
||||
&& (logr->record_type == const_cpu_to_le32(2))) {
|
||||
&& le32_eq(logr->record_type, const_cpu_to_le32(2))) {
|
||||
/* if chkp process queue, and increment count */
|
||||
playedactions++;
|
||||
if (playedactions <= playcount) {
|
||||
|
@ -2596,7 +2596,7 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
|||
BOOL stop;
|
||||
|
||||
rph = &buf->block.record;
|
||||
if (rph && (rph->head.magic == magic_RCRD)) {
|
||||
if (rph && le32_eq(rph->head.magic, magic_RCRD)) {
|
||||
data = buf->block.data;
|
||||
showheadrcrd(blk, rph);
|
||||
k = buf->headsz;
|
||||
|
@ -2653,7 +2653,7 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
|||
k + size);
|
||||
}
|
||||
showlogr(ctx, k, logr);
|
||||
if (!logr->client_data_length) {
|
||||
if (le32_cmpz(logr->client_data_length)) {
|
||||
printf("** Bad"
|
||||
" client_data_length\n");
|
||||
stop = TRUE;
|
||||
|
@ -2690,8 +2690,8 @@ static void showrest(const struct RESTART_PAGE_HEADER *rest)
|
|||
const char *data;
|
||||
|
||||
data = (const char*)rest;
|
||||
if ((rest->head.magic == magic_RSTR)
|
||||
|| (rest->head.magic == magic_CHKD)) {
|
||||
if (le32_eq(rest->head.magic, magic_RSTR)
|
||||
|| le32_eq(rest->head.magic, magic_CHKD)) {
|
||||
if (optv) {
|
||||
printf("magic %08lx\n",
|
||||
(long)le32_to_cpu(rest->head.magic));
|
||||
|
@ -2819,7 +2819,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
|||
offs += le16_to_cpu(restart.client_array_offset);
|
||||
memcpy(&client, &data[offs],
|
||||
sizeof(struct RESTART_CLIENT));
|
||||
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
|
||||
dirty = le16_andz(resa->flags, RESTART_VOLUME_IS_CLEAN);
|
||||
if (optv || optt)
|
||||
printf("* Using initial restart page,"
|
||||
" syncing from 0x%llx, %s\n",
|
||||
|
@ -2846,7 +2846,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
|||
}
|
||||
showrest(rph);
|
||||
/* Information from an older restart block if requested */
|
||||
dirty = !(restart.flags & RESTART_VOLUME_IS_CLEAN);
|
||||
dirty = le16_andz(restart.flags, RESTART_VOLUME_IS_CLEAN);
|
||||
diff = sle64_to_cpu(rcli->client_restart_lsn) - committed_lsn;
|
||||
if (ctx->vol) {
|
||||
change = (opts > 1) && (diff < 0);
|
||||
|
@ -2865,7 +2865,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
|||
offs += le16_to_cpu(restart.client_array_offset);
|
||||
memcpy(&client, &data[offs],
|
||||
sizeof(struct RESTART_CLIENT));
|
||||
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
|
||||
dirty = le16_andz(resa->flags, RESTART_VOLUME_IS_CLEAN);
|
||||
if (optv || optt)
|
||||
printf("* Using %s restart page,"
|
||||
" syncing from 0x%llx, %s\n",
|
||||
|
@ -2925,26 +2925,26 @@ static const struct BUFFER *read_restart(CONTEXT *ctx)
|
|||
NTFS_RECORD_TYPES magic;
|
||||
|
||||
magic = buf->block.restart.head.magic;
|
||||
switch (magic) {
|
||||
case magic_RSTR :
|
||||
break;
|
||||
case magic_CHKD :
|
||||
/* switch (magic) { */
|
||||
if (le32_eq(magic, magic_RSTR)) {
|
||||
}
|
||||
else if (le32_eq(magic, magic_CHKD)) {
|
||||
printf("** The log file has been obsoleted by chkdsk\n");
|
||||
bad = TRUE;
|
||||
break;
|
||||
case magic_empty :
|
||||
}
|
||||
else if (le32_eq(magic, magic_empty)) {
|
||||
printf("** The log file has been wiped out\n");
|
||||
bad = TRUE;
|
||||
break;
|
||||
default :
|
||||
}
|
||||
else {
|
||||
printf("** Invalid restart block\n");
|
||||
bad = TRUE;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
if (!bad && !ctx->vol)
|
||||
dorest(ctx, 0, &buf->block.restart, TRUE);
|
||||
if ((buf->block.restart.major_ver != const_cpu_to_le16(1))
|
||||
|| (buf->block.restart.minor_ver != const_cpu_to_le16(1))) {
|
||||
if (!le16_eq(buf->block.restart.major_ver, const_cpu_to_le16(1))
|
||||
|| !le16_eq(buf->block.restart.minor_ver, const_cpu_to_le16(1))) {
|
||||
printf("** Unsupported $LogFile version %d.%d\n",
|
||||
le16_to_cpu(buf->block.restart.major_ver),
|
||||
le16_to_cpu(buf->block.restart.minor_ver));
|
||||
|
@ -2972,7 +2972,7 @@ static int reset_logfile(CONTEXT *ctx __attribute__((unused)))
|
|||
if (buffer) {
|
||||
memset(buffer, 0, blocksz);
|
||||
restart.client_in_use_list = LOGFILE_NO_CLIENT;
|
||||
restart.flags |= RESTART_VOLUME_IS_CLEAN;
|
||||
restart.flags = le16_or(restart.flags, RESTART_VOLUME_IS_CLEAN);
|
||||
client.oldest_lsn = cpu_to_sle64(restart_lsn);
|
||||
memcpy(buffer, &log_header,
|
||||
sizeof(struct RESTART_PAGE_HEADER));
|
||||
|
@ -3018,7 +3018,7 @@ static const struct BUFFER *best_start(const struct BUFFER *buf,
|
|||
else
|
||||
best = buf;
|
||||
}
|
||||
if (best && (best->block.record.head.magic != magic_RCRD))
|
||||
if (best && !le32_eq(best->block.record.head.magic, magic_RCRD))
|
||||
best = (const struct BUFFER*)NULL;
|
||||
return (best);
|
||||
}
|
||||
|
@ -3179,8 +3179,8 @@ static BOOL getvolumedata(CONTEXT *ctx, char *boot)
|
|||
}
|
||||
// TODO get rest ?, meaningful ?
|
||||
if (ok && rest) {
|
||||
if (rest->client_in_use_list
|
||||
|| !(rest->flags & const_cpu_to_le16(2)))
|
||||
if (!le16_cmpz(rest->client_in_use_list)
|
||||
|| le16_andz(rest->flags, const_cpu_to_le16(2)))
|
||||
printf("Volume was not unmounted safely\n");
|
||||
else
|
||||
printf("Volume was unmounted safely\n");
|
||||
|
@ -3381,8 +3381,8 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
|||
if (prevbuf)
|
||||
prevrph = &prevbuf->block.record;
|
||||
data = buf->block.data;
|
||||
if (rph && (rph->head.magic == magic_RCRD)
|
||||
&& (!prevrph || (prevrph->head.magic == magic_RCRD))) {
|
||||
if (rph && le32_eq(rph->head.magic, magic_RCRD)
|
||||
&& (!prevrph || le32_eq(prevrph->head.magic, magic_RCRD))) {
|
||||
if (optv) {
|
||||
if (optv >= 2)
|
||||
hexdump(data,blocksz);
|
||||
|
@ -3443,7 +3443,7 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
|||
if (((u32)(k + size) <= blocksz)
|
||||
&& ((u32)(k + size) <= endoff)) {
|
||||
poslist[cnt++] = k;
|
||||
if (!logr->client_data_length)
|
||||
if (le32_cmpz(logr->client_data_length))
|
||||
stop = TRUE;
|
||||
k += size;
|
||||
if ((u32)(k
|
||||
|
@ -3483,14 +3483,14 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
|||
if ((optv | optt)
|
||||
&& (!nextbuf && (j == (cnt - 1)))) {
|
||||
printf("* This is the latest record\n");
|
||||
if (logr->this_lsn == restart.current_lsn)
|
||||
if (sle64_eq(logr->this_lsn, restart.current_lsn))
|
||||
printf(" its lsn matches the global"
|
||||
" restart lsn\n");
|
||||
if (logr->this_lsn == client.client_restart_lsn)
|
||||
if (sle64_eq(logr->this_lsn, client.client_restart_lsn))
|
||||
printf(" its lsn matches the client"
|
||||
" restart lsn\n");
|
||||
if (logr->client_data_length
|
||||
== restart.last_lsn_data_length)
|
||||
if (le32_eq(logr->client_data_length,
|
||||
restart.last_lsn_data_length))
|
||||
printf(" its length matches the"
|
||||
" last record length\n");
|
||||
}
|
||||
|
@ -3537,18 +3537,18 @@ static int walkback(CONTEXT *ctx, const struct BUFFER *buf, u32 blk,
|
|||
skipped = blk - prevblk - 1
|
||||
+ (logfilesz >> blockbits) - BASEBLKS;
|
||||
magic = prevbuf->block.record.head.magic;
|
||||
switch (magic) {
|
||||
case magic_RCRD :
|
||||
break;
|
||||
case magic_CHKD :
|
||||
/* switch (magic) { */
|
||||
if (le32_eq(magic, magic_RCRD)) {
|
||||
}
|
||||
else if (le32_eq(magic, magic_CHKD)) {
|
||||
printf("** Unexpected block type CHKD\n");
|
||||
break;
|
||||
case magic_RSTR :
|
||||
}
|
||||
else if (le32_eq(magic, magic_RSTR)) {
|
||||
printf("** Unexpected block type RSTR\n");
|
||||
break;
|
||||
default :
|
||||
}
|
||||
else {
|
||||
printf("** Invalid block %d\n",(int)prevblk);
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
if (optv) {
|
||||
if (skipped)
|
||||
|
@ -3641,24 +3641,24 @@ static int walk(CONTEXT *ctx)
|
|||
record = (const NTFS_RECORD*)&nextbuf->block.data;
|
||||
blkheadsz = nextbuf->headsz;
|
||||
magic = record->magic;
|
||||
switch (magic) {
|
||||
case magic_CHKD :
|
||||
case magic_RSTR :
|
||||
case magic_RCRD :
|
||||
break;
|
||||
default :
|
||||
/* switch (magic) { */
|
||||
if (le32_eq(magic, magic_CHKD) ||
|
||||
le32_eq(magic, magic_RSTR) ||
|
||||
le32_eq(magic, magic_RCRD)) {
|
||||
}
|
||||
else {
|
||||
printf("** Invalid block\n");
|
||||
err = 1;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
magic = buf->block.record.head.magic;
|
||||
switch (magic) {
|
||||
case magic_CHKD :
|
||||
case magic_RSTR :
|
||||
/* switch (magic) { */
|
||||
if (le32_eq(magic, magic_CHKD) ||
|
||||
le32_eq(magic, magic_RSTR)) {
|
||||
dirty = dorest(ctx, blk, &buf->block.restart,
|
||||
FALSE);
|
||||
break;
|
||||
case magic_RCRD :
|
||||
}
|
||||
else if (le32_eq(magic, magic_RCRD)) {
|
||||
if (blk < BASEBLKS)
|
||||
pos = buf->headsz;
|
||||
pos = dorcrd(ctx, blk, pos, buf, nextbuf);
|
||||
|
@ -3677,13 +3677,13 @@ static int walk(CONTEXT *ctx)
|
|||
if (nextblk != (blk + 1)) {
|
||||
nextbuf = read_buffer(ctx,nextblk);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
if (!~magic) {
|
||||
}
|
||||
else {
|
||||
if (le32_cmpz(le32_not(magic))) {
|
||||
if (optv)
|
||||
printf(" empty block\n");
|
||||
}
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"* Could not read block %d\n",nextblk);
|
||||
|
@ -3790,21 +3790,21 @@ static int walk(CONTEXT *ctx)
|
|||
if (prevbuf) {
|
||||
prevblk = prevbuf->num;
|
||||
magic = prevbuf->block.record.head.magic;
|
||||
switch (magic) {
|
||||
case magic_RCRD :
|
||||
break;
|
||||
case magic_CHKD :
|
||||
/* switch (magic) { */
|
||||
if (le32_eq(magic, magic_RCRD)) {
|
||||
}
|
||||
else if (le32_eq(magic, magic_CHKD)) {
|
||||
printf("** Unexpected block type CHKD\n");
|
||||
err = 1;
|
||||
break;
|
||||
case magic_RSTR :
|
||||
}
|
||||
else if (le32_eq(magic, magic_RSTR)) {
|
||||
err = 1;
|
||||
printf("** Unexpected block type RSTR\n");
|
||||
break;
|
||||
default :
|
||||
}
|
||||
else {
|
||||
err = 1;
|
||||
printf("** Invalid block\n");
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
} else
|
||||
prevblk = BASEBLKS;
|
||||
|
|
|
@ -187,30 +187,30 @@ static BOOL valid_type(ATTR_TYPES type)
|
|||
{
|
||||
BOOL ok;
|
||||
|
||||
switch (type) {
|
||||
case AT_STANDARD_INFORMATION :
|
||||
case AT_ATTRIBUTE_LIST :
|
||||
case AT_FILE_NAME :
|
||||
case AT_OBJECT_ID :
|
||||
case AT_SECURITY_DESCRIPTOR :
|
||||
case AT_VOLUME_NAME :
|
||||
case AT_VOLUME_INFORMATION :
|
||||
case AT_DATA :
|
||||
case AT_INDEX_ROOT :
|
||||
case AT_INDEX_ALLOCATION :
|
||||
case AT_BITMAP :
|
||||
case AT_REPARSE_POINT :
|
||||
case AT_EA_INFORMATION :
|
||||
case AT_EA :
|
||||
case AT_PROPERTY_SET :
|
||||
case AT_LOGGED_UTILITY_STREAM :
|
||||
case AT_FIRST_USER_DEFINED_ATTRIBUTE :
|
||||
case AT_END :
|
||||
if (le32_eq(type, AT_STANDARD_INFORMATION) ||
|
||||
le32_eq(type, AT_ATTRIBUTE_LIST) ||
|
||||
le32_eq(type, AT_FILE_NAME) ||
|
||||
le32_eq(type, AT_OBJECT_ID) ||
|
||||
le32_eq(type, AT_SECURITY_DESCRIPTOR) ||
|
||||
le32_eq(type, AT_VOLUME_NAME) ||
|
||||
le32_eq(type, AT_VOLUME_INFORMATION) ||
|
||||
le32_eq(type, AT_DATA) ||
|
||||
le32_eq(type, AT_INDEX_ROOT) ||
|
||||
le32_eq(type, AT_INDEX_ALLOCATION) ||
|
||||
le32_eq(type, AT_BITMAP) ||
|
||||
le32_eq(type, AT_REPARSE_POINT) ||
|
||||
le32_eq(type, AT_EA_INFORMATION) ||
|
||||
le32_eq(type, AT_EA) ||
|
||||
le32_eq(type, AT_PROPERTY_SET) ||
|
||||
le32_eq(type, AT_LOGGED_UTILITY_STREAM) ||
|
||||
le32_eq(type, AT_FIRST_USER_DEFINED_ATTRIBUTE) ||
|
||||
le32_eq(type, AT_END))
|
||||
{
|
||||
ok = TRUE;
|
||||
break;
|
||||
default :
|
||||
}
|
||||
else {
|
||||
ok = FALSE;
|
||||
break;
|
||||
/* break; */
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ static int sanity_indx_list(const char *buffer, u32 k, u32 end)
|
|||
(int)lth,
|
||||
(int)getle16(buffer,k+12),(int)k);
|
||||
}
|
||||
done = (feedle16(buffer,k+12) & INDEX_ENTRY_END) || !lth;
|
||||
done = !le16_andz(feedle16(buffer,k+12), INDEX_ENTRY_END) || !lth;
|
||||
k += lth;
|
||||
}
|
||||
if (k != end) {
|
||||
|
@ -309,7 +309,7 @@ static int sanity_mft(const char *buffer)
|
|||
attr = (const ATTR_RECORD*)&buffer[k];
|
||||
prevtype = 0;
|
||||
while ((k < mftrecsz)
|
||||
&& (attr->type != AT_END)
|
||||
&& !le32_eq(attr->type, AT_END)
|
||||
&& valid_type(attr->type)) {
|
||||
type = le32_to_cpu(attr->type);
|
||||
if (type < prevtype) {
|
||||
|
@ -333,7 +333,7 @@ static int sanity_mft(const char *buffer)
|
|||
instances |= (u64)1 << instance;
|
||||
}
|
||||
if (optv > 1) {
|
||||
if ((attr->type == AT_FILE_NAME)
|
||||
if (le32_eq(attr->type, AT_FILE_NAME)
|
||||
&& buffer[k + 88]) {
|
||||
printf("attr %08lx offs 0x%x nres %d",
|
||||
(long)type, (int)k,
|
||||
|
@ -345,7 +345,7 @@ static int sanity_mft(const char *buffer)
|
|||
(long)type, (int)k,
|
||||
(int)attr->non_resident);
|
||||
}
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& sanity_indx_list(buffer,
|
||||
k + le16_to_cpu(attr->value_offset) + 32,
|
||||
k + le32_to_cpu(attr->length))) {
|
||||
|
@ -355,10 +355,10 @@ static int sanity_mft(const char *buffer)
|
|||
attr = (const ATTR_RECORD*)&buffer[k];
|
||||
prevtype = type;
|
||||
}
|
||||
if ((optv > 1) && (attr->type == AT_END))
|
||||
if ((optv > 1) && le32_eq(attr->type, AT_END))
|
||||
printf("attr %08lx offs 0x%x\n",
|
||||
(long)le32_to_cpu(attr->type), (int)k);
|
||||
if ((attr->type != AT_END)
|
||||
if (!le32_eq(attr->type, AT_END)
|
||||
|| (le32_to_cpu(record->bytes_in_use) != (k + 8))
|
||||
|| (le32_to_cpu(record->bytes_allocated) < (k + 8))) {
|
||||
printf("** Bad MFT record length %ld"
|
||||
|
@ -761,7 +761,7 @@ static void adjust_instance(const ATTR_RECORD *attr, MFT_RECORD *entry, int incr
|
|||
|
||||
if (increment > 0) {
|
||||
/* Allocating a new instance ? */
|
||||
if (attr->instance == entry->next_attr_instance) {
|
||||
if (le16_eq(attr->instance, entry->next_attr_instance)) {
|
||||
instance = (le16_to_cpu(entry->next_attr_instance)
|
||||
+ 1) & 0xffff;
|
||||
entry->next_attr_instance = cpu_to_le16(instance);
|
||||
|
@ -771,7 +771,7 @@ static void adjust_instance(const ATTR_RECORD *attr, MFT_RECORD *entry, int incr
|
|||
/* Freeing the latest instance ? */
|
||||
instance = (le16_to_cpu(entry->next_attr_instance)
|
||||
- 1) & 0xffff;
|
||||
if (attr->instance == cpu_to_le16(instance))
|
||||
if (le16_eq(attr->instance, cpu_to_le16(instance)))
|
||||
entry->next_attr_instance = attr->instance;
|
||||
}
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ static BOOL index_match_undo(const char *first, const char *second, int length)
|
|||
dump(second,length);
|
||||
}
|
||||
len = (first[80] & 255)*2 + 2;
|
||||
match = (feedle64(first, 16) == feedle64(second, 16))
|
||||
match = le64_eq(feedle64(first, 16), feedle64(second, 16))
|
||||
&& !memcmp(first + 80, second + 80, len);
|
||||
if (match && optv)
|
||||
printf("However parent dir and name do match\n");
|
||||
|
@ -855,7 +855,7 @@ static int change_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
int changed;
|
||||
|
||||
err = 1;
|
||||
if (action->record.undo_length != action->record.redo_length)
|
||||
if (!le16_eq(action->record.undo_length, action->record.redo_length))
|
||||
printf("** Error size change in change_resident\n");
|
||||
if (optv > 1) {
|
||||
lcn = le64_to_cpu(action->record.lcn_list[0]);
|
||||
|
@ -909,7 +909,7 @@ static int change_resident_expect(ntfs_volume *vol, const struct ACTION_RECORD *
|
|||
BOOL found;
|
||||
|
||||
err = 1;
|
||||
if (action->record.undo_length != action->record.redo_length)
|
||||
if (!le16_eq(action->record.undo_length, action->record.redo_length))
|
||||
printf("** Error size change in change_resident\n");
|
||||
if (optv > 1) {
|
||||
lcn = le64_to_cpu(action->record.lcn_list[0]);
|
||||
|
@ -925,7 +925,7 @@ static int change_resident_expect(ntfs_volume *vol, const struct ACTION_RECORD *
|
|||
printf("-> full record :\n");
|
||||
dump((char*)attr, le32_to_cpu(attr->length));
|
||||
}
|
||||
if ((attr->type == type)
|
||||
if (le32_eq(attr->type, type)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= mftrecsz)) {
|
||||
found = !memcmp(buffer + target, expected, length);
|
||||
|
@ -1209,15 +1209,15 @@ static int insert_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
newused = le32_to_cpu(entry->bytes_in_use)
|
||||
+ length;
|
||||
entry->bytes_in_use = cpu_to_le32(newused);
|
||||
if (action->record.redo_operation
|
||||
== const_cpu_to_le16(CreateAttribute)) {
|
||||
if (le16_eq(action->record.redo_operation,
|
||||
const_cpu_to_le16(CreateAttribute))) {
|
||||
/*
|
||||
* For a real create, may have to adjust
|
||||
* the next attribute instance
|
||||
*/
|
||||
adjust_instance(newattr, entry, 1);
|
||||
}
|
||||
if (newattr->type == AT_FILE_NAME) {
|
||||
if (le32_eq(newattr->type, AT_FILE_NAME)) {
|
||||
links = le16_to_cpu(entry->link_count) + 1;
|
||||
entry->link_count = cpu_to_le16(links);
|
||||
}
|
||||
|
@ -1272,7 +1272,7 @@ static int remove_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
&& ((target + length) <= mftrecsz)) {
|
||||
/* This has to be an idempotent action */
|
||||
/* For AT_DATA the value is not always present */
|
||||
if (attr->type == AT_DATA)
|
||||
if (le32_eq(attr->type, AT_DATA))
|
||||
found = !memcmp(buffer + target, data,
|
||||
le16_to_cpu(attr->value_offset));
|
||||
else
|
||||
|
@ -1293,12 +1293,12 @@ static int remove_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
}
|
||||
err = 0;
|
||||
if (found) {
|
||||
if (attr->type == AT_FILE_NAME) {
|
||||
if (le32_eq(attr->type, AT_FILE_NAME)) {
|
||||
links = le16_to_cpu(entry->link_count) - 1;
|
||||
entry->link_count = cpu_to_le16(links);
|
||||
}
|
||||
if (action->record.redo_operation
|
||||
== const_cpu_to_le16(CreateAttribute)) {
|
||||
if (le16_eq(action->record.redo_operation,
|
||||
const_cpu_to_le16(CreateAttribute))) {
|
||||
adjust_instance(attr, entry, -1);
|
||||
}
|
||||
/* Remove the entry */
|
||||
|
@ -1489,7 +1489,7 @@ static int update_index(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
printf("-> existing index :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -1533,7 +1533,7 @@ static int delete_names(char *buffer)
|
|||
do {
|
||||
attr = (ATTR_RECORD*)&buffer[pos];
|
||||
length = le32_to_cpu(attr->length);
|
||||
if (attr->type == AT_FILE_NAME) {
|
||||
if (le32_eq(attr->type, AT_FILE_NAME)) {
|
||||
if (optv)
|
||||
showname("Controversial deletion of ",
|
||||
&buffer[pos+90], buffer[pos+88] & 255);
|
||||
|
@ -1620,7 +1620,7 @@ static int insert_index_allocation(ntfs_volume *vol, char *buffer, u32 offs)
|
|||
length = le32_to_cpu(attr->length);
|
||||
addedlength = length - 8 /* index allocation */
|
||||
+ length - 48; /* bitmap */
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& ((pos + length) == offs)
|
||||
&& ((used + addedlength) < mftrecsz)) {
|
||||
/* Make space for the attribute */
|
||||
|
@ -1708,9 +1708,9 @@ static BOOL check_full_mft(const struct ACTION_RECORD *action, BOOL redoing)
|
|||
length = le16_to_cpu(action->record.undo_length);
|
||||
}
|
||||
/* The length in use must be fed */
|
||||
ok = !action->record.record_offset
|
||||
&& !action->record.attribute_offset
|
||||
&& (record->magic == magic_FILE)
|
||||
ok = le16_cmpz(action->record.record_offset)
|
||||
&& le16_cmpz(action->record.attribute_offset)
|
||||
&& le32_eq(record->magic, magic_FILE)
|
||||
&& (length <= mftrecsz)
|
||||
&& (length >= (offsetof(MFT_RECORD, bytes_in_use)
|
||||
+ sizeof(record->bytes_in_use)));
|
||||
|
@ -1718,14 +1718,14 @@ static BOOL check_full_mft(const struct ACTION_RECORD *action, BOOL redoing)
|
|||
k = le16_to_cpu(record->attrs_offset);
|
||||
attr = (const ATTR_RECORD*)((const char*)record + k);
|
||||
while (((k + sizeof(attr->type)) <= length)
|
||||
&& (attr->type != AT_END)
|
||||
&& !le32_eq(attr->type, AT_END)
|
||||
&& valid_type(attr->type)) {
|
||||
k += le32_to_cpu(attr->length);
|
||||
attr = (const ATTR_RECORD*)((const char*)record + k);
|
||||
}
|
||||
/* AT_END must be present */
|
||||
ok = ((k + sizeof(attr->type)) <= length)
|
||||
&& (attr->type == AT_END);
|
||||
&& le32_eq(attr->type, AT_END);
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
@ -1751,9 +1751,9 @@ static BOOL check_full_index(const struct ACTION_RECORD *action, BOOL redoing)
|
|||
length = le16_to_cpu(action->record.undo_length);
|
||||
}
|
||||
/* the index length must be fed, so must be the full index block */
|
||||
return (!action->record.record_offset
|
||||
&& !action->record.attribute_offset
|
||||
&& (indx->magic == magic_INDX)
|
||||
return (le16_cmpz(action->record.record_offset)
|
||||
&& le16_cmpz(action->record.attribute_offset)
|
||||
&& le32_eq(indx->magic, magic_INDX)
|
||||
&& (length >= (offsetof(INDEX_BLOCK, index.index_length) + 4))
|
||||
&& (length >= (le32_to_cpu(indx->index.index_length) + 24)));
|
||||
}
|
||||
|
@ -1876,7 +1876,7 @@ static int redo_add_index(ntfs_volume *vol, const struct ACTION_RECORD *action,
|
|||
printf("-> existing record :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -1942,7 +1942,7 @@ static int redo_add_root_index(ntfs_volume *vol,
|
|||
printf("existing index :\n");
|
||||
dump(buffer + target,length);
|
||||
}
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= mftrecsz)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -2019,9 +2019,9 @@ static int redo_create_file(ntfs_volume *vol,
|
|||
if ((target + length) <= mftrecsz) {
|
||||
changed = memcmp(buffer + target, data, length);
|
||||
err = 0;
|
||||
if (changed || !(record->flags & MFT_RECORD_IN_USE)) {
|
||||
if (changed || le16_andz(record->flags, MFT_RECORD_IN_USE)) {
|
||||
memcpy(buffer + target, data, length);
|
||||
record->flags |= MFT_RECORD_IN_USE;
|
||||
record->flags = le16_or(record->flags, MFT_RECORD_IN_USE);
|
||||
if (optv > 1) {
|
||||
printf("-> new record :\n");
|
||||
dump(buffer,mftrecsz);
|
||||
|
@ -2056,7 +2056,7 @@ static int redo_create_attribute(ntfs_volume *vol,
|
|||
target = le16_to_cpu(action->record.record_offset)
|
||||
+ le16_to_cpu(action->record.attribute_offset);
|
||||
// Could also be AT_DATA or AT_INDEX_ALLOCATION
|
||||
if (!action->record.undo_length)
|
||||
if (le16_cmpz(action->record.undo_length))
|
||||
err = insert_resident(vol, action, buffer, data,
|
||||
target, length);
|
||||
return (err);
|
||||
|
@ -2078,7 +2078,7 @@ static int redo_delete_attribute(ntfs_volume *vol,
|
|||
length = le16_to_cpu(action->record.undo_length);
|
||||
target = le16_to_cpu(action->record.record_offset)
|
||||
+ le16_to_cpu(action->record.attribute_offset);
|
||||
if (!action->record.redo_length)
|
||||
if (le16_cmpz(action->record.redo_length))
|
||||
err = remove_resident(vol, action, buffer, data,
|
||||
target, length);
|
||||
return (err);
|
||||
|
@ -2117,11 +2117,11 @@ static int redo_delete_file(ntfs_volume *vol,
|
|||
if ((target + length) <= mftrecsz) {
|
||||
/* write a void mft entry (needed ?) */
|
||||
changed = memcmp(buffer + target, data, length)
|
||||
|| (record->flags & MFT_RECORD_IN_USE);
|
||||
|| !le16_andz(record->flags, MFT_RECORD_IN_USE);
|
||||
err = 0;
|
||||
if (changed) {
|
||||
memcpy(buffer + target, data, length);
|
||||
record->flags &= ~MFT_RECORD_IN_USE;
|
||||
record->flags = le16_and(record->flags, le16_not(MFT_RECORD_IN_USE));
|
||||
if (optv > 1) {
|
||||
printf("-> new record :\n");
|
||||
dump(buffer,mftrecsz);
|
||||
|
@ -2171,7 +2171,7 @@ static int redo_delete_index(ntfs_volume *vol,
|
|||
printf("-> existing record :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -2233,7 +2233,7 @@ static int redo_delete_root_index(ntfs_volume *vol,
|
|||
printf("existing index :\n");
|
||||
dump(buffer + target,length);
|
||||
}
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= mftrecsz)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -2280,8 +2280,8 @@ static int redo_force_bits(ntfs_volume *vol,
|
|||
+ get_redo_offset(&action->record));
|
||||
firstbit = le32_to_cpu(data->firstbit);
|
||||
count = le32_to_cpu(data->count);
|
||||
if (action->record.redo_operation
|
||||
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.redo_operation,
|
||||
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
|
||||
wanted = 1;
|
||||
else
|
||||
wanted = 0;
|
||||
|
@ -2325,7 +2325,7 @@ static int redo_open_attribute(ntfs_volume *vol __attribute__((unused)),
|
|||
+ get_redo_offset(&action->record);
|
||||
length = le16_to_cpu(action->record.redo_length);
|
||||
extra = get_extra_offset(&action->record);
|
||||
if (action->record.undo_length) {
|
||||
if (!le16_cmpz(action->record.undo_length)) {
|
||||
name = ((const char*)&action->record) + extra;
|
||||
namelen = le32_to_cpu(action->record.client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ - extra;
|
||||
|
@ -2354,13 +2354,13 @@ static int redo_open_attribute(ntfs_volume *vol __attribute__((unused)),
|
|||
/* Badly aligned */
|
||||
memcpy(&inode, &attr_old->inode, 8);
|
||||
err = (MREF(le64_to_cpu(inode)) != pa->inode)
|
||||
|| (attr_old->type != pa->type);
|
||||
|| !le32_eq(attr_old->type, pa->type);
|
||||
break;
|
||||
case sizeof(struct ATTR_NEW) :
|
||||
attr_new = (const struct ATTR_NEW*)data;
|
||||
err = (MREF(le64_to_cpu(attr_new->inode))
|
||||
!= pa->inode)
|
||||
|| (attr_new->type != pa->type);
|
||||
|| !le32_eq(attr_new->type, pa->type);
|
||||
break;
|
||||
default : err = 1;
|
||||
}
|
||||
|
@ -2840,14 +2840,14 @@ static int redo_write_index(ntfs_volume *vol,
|
|||
}
|
||||
xsize = vol->indx_record_size;
|
||||
indx = (INDEX_BLOCK*)buffer;
|
||||
if (action->record.record_offset) {
|
||||
if (!le16_cmpz(action->record.record_offset)) {
|
||||
printf("** Non-null record_offset in redo_write_index()\n");
|
||||
}
|
||||
if (optv > 1) {
|
||||
printf("-> existing index :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -2934,7 +2934,7 @@ static int undo_add_index(ntfs_volume *vol,
|
|||
printf("-> existing record :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -2999,7 +2999,7 @@ static int undo_add_root_index(ntfs_volume *vol,
|
|||
printf("existing index :\n");
|
||||
dump(buffer + target,length);
|
||||
}
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= mftrecsz)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -3042,7 +3042,7 @@ static int undo_create_attribute(ntfs_volume *vol,
|
|||
length = le16_to_cpu(action->record.redo_length);
|
||||
target = le16_to_cpu(action->record.record_offset)
|
||||
+ le16_to_cpu(action->record.attribute_offset);
|
||||
if (!action->record.undo_length)
|
||||
if (le16_cmpz(action->record.undo_length))
|
||||
err = remove_resident(vol, action, buffer, data,
|
||||
target, length);
|
||||
return (err);
|
||||
|
@ -3064,7 +3064,7 @@ static int undo_delete_attribute(ntfs_volume *vol,
|
|||
length = le16_to_cpu(action->record.undo_length);
|
||||
target = le16_to_cpu(action->record.record_offset)
|
||||
+ le16_to_cpu(action->record.attribute_offset);
|
||||
if (!action->record.redo_length)
|
||||
if (le16_cmpz(action->record.redo_length))
|
||||
err = insert_resident(vol, action, buffer, data,
|
||||
target, length);
|
||||
return (err);
|
||||
|
@ -3104,7 +3104,7 @@ static int undo_delete_index(ntfs_volume *vol,
|
|||
printf("-> existing record :\n");
|
||||
dump(&buffer[target], length);
|
||||
}
|
||||
if ((indx->magic == magic_INDX)
|
||||
if (le32_eq(indx->magic, magic_INDX)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= xsize)
|
||||
&& !sanity_indx(vol,buffer)) {
|
||||
|
@ -3169,7 +3169,7 @@ static int undo_delete_root_index(ntfs_volume *vol,
|
|||
+ le16_to_cpu(action->record.record_offset));
|
||||
index = (INDEX_ROOT*)(((char*)attr)
|
||||
+ le16_to_cpu(attr->value_offset));
|
||||
if (attr->type != AT_INDEX_ROOT) {
|
||||
if (!le32_eq(attr->type, AT_INDEX_ROOT)) {
|
||||
printf("** Unexpected attr type 0x%lx\n",
|
||||
(long)le32_to_cpu(attr->type));
|
||||
printf("existing mft\n");
|
||||
|
@ -3181,7 +3181,7 @@ static int undo_delete_root_index(ntfs_volume *vol,
|
|||
printf("existing index :\n");
|
||||
dump(buffer + target,length);
|
||||
}
|
||||
if ((attr->type == AT_INDEX_ROOT)
|
||||
if (le32_eq(attr->type, AT_INDEX_ROOT)
|
||||
&& !(length & 7)
|
||||
&& ((target + length) <= mftrecsz)) {
|
||||
/* This has to be an idempotent action */
|
||||
|
@ -3244,9 +3244,9 @@ static int undo_create_file(ntfs_volume *vol,
|
|||
if ((target + length) <= mftrecsz) {
|
||||
changed = memcmp(buffer + target, data, length);
|
||||
err = 0;
|
||||
if (changed || (record->flags & MFT_RECORD_IN_USE)) {
|
||||
if (changed || !le16_andz(record->flags, MFT_RECORD_IN_USE)) {
|
||||
memcpy(buffer + target, data, length);
|
||||
record->flags &= ~MFT_RECORD_IN_USE;
|
||||
record->flags = le16_and(record->flags, le16_not(MFT_RECORD_IN_USE));
|
||||
if (optv > 1) {
|
||||
printf("-> new record :\n");
|
||||
dump(buffer,mftrecsz);
|
||||
|
@ -3294,7 +3294,7 @@ static int undo_delete_file(ntfs_volume *vol,
|
|||
record = (MFT_RECORD*)buffer;
|
||||
if ((target + length) <= mftrecsz) {
|
||||
changed = memcmp(buffer + target, data, length)
|
||||
|| !(record->flags & MFT_RECORD_IN_USE);
|
||||
|| le16_andz(record->flags, MFT_RECORD_IN_USE);
|
||||
err = 0;
|
||||
if (changed) {
|
||||
memcpy(buffer + target, data, length);
|
||||
|
@ -3310,10 +3310,10 @@ static int undo_delete_file(ntfs_volume *vol,
|
|||
* the record now appears to not be in use and there are
|
||||
* links.
|
||||
*/
|
||||
if (record->link_count
|
||||
&& !(record->flags & MFT_RECORD_IN_USE))
|
||||
if (!le16_cmpz(record->link_count)
|
||||
&& le16_andz(record->flags, MFT_RECORD_IN_USE))
|
||||
err = delete_names(buffer);
|
||||
record->flags |= MFT_RECORD_IN_USE;
|
||||
record->flags = le16_or(record->flags, MFT_RECORD_IN_USE);
|
||||
if (optv > 1) {
|
||||
printf("-> new record :\n");
|
||||
dump(buffer,mftrecsz);
|
||||
|
@ -3350,8 +3350,8 @@ static int undo_force_bits(ntfs_volume *vol,
|
|||
+ get_redo_offset(&action->record));
|
||||
firstbit = le32_to_cpu(data->firstbit);
|
||||
count = le32_to_cpu(data->count);
|
||||
if (action->record.redo_operation
|
||||
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.redo_operation,
|
||||
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
|
||||
wanted = 0;
|
||||
else
|
||||
wanted = 1;
|
||||
|
@ -3395,7 +3395,7 @@ static int undo_open_attribute(ntfs_volume *vol __attribute__((unused)),
|
|||
+ get_redo_offset(&action->record);
|
||||
length = le16_to_cpu(action->record.redo_length);
|
||||
extra = get_extra_offset(&action->record);
|
||||
if (action->record.undo_length) {
|
||||
if (!le16_cmpz(action->record.undo_length)) {
|
||||
name = ((const char*)&action->record) + extra;
|
||||
namelen = le32_to_cpu(action->record.client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ - extra;
|
||||
|
@ -3420,12 +3420,12 @@ static int undo_open_attribute(ntfs_volume *vol __attribute__((unused)),
|
|||
/* Badly aligned */
|
||||
memcpy(&inode, &attr_old->inode, 8);
|
||||
err = (MREF(le64_to_cpu(inode)) != pa->inode)
|
||||
|| (attr_old->type != pa->type);
|
||||
|| !le32_eq(attr_old->type, pa->type);
|
||||
break;
|
||||
case sizeof(struct ATTR_NEW) :
|
||||
attr_new = (const struct ATTR_NEW*)data;
|
||||
err = (MREF(le64_to_cpu(attr_new->inode))!= pa->inode)
|
||||
|| (attr_new->type != pa->type);
|
||||
|| !le32_eq(attr_new->type, pa->type);
|
||||
break;
|
||||
default : err = 1;
|
||||
}
|
||||
|
@ -3465,14 +3465,14 @@ static int undo_sizes(ntfs_volume *vol,
|
|||
+ le16_to_cpu(action->record.attribute_offset)
|
||||
+ offsetof(ATTR_RECORD, allocated_size);
|
||||
entry = (MFT_RECORD*)buffer;
|
||||
if (!(entry->flags & MFT_RECORD_IS_DIRECTORY))
|
||||
if (le16_andz(entry->flags, MFT_RECORD_IS_DIRECTORY))
|
||||
err = change_resident(vol, action, buffer,
|
||||
data, target, length);
|
||||
else {
|
||||
/* On a directory, may have to build an index allocation */
|
||||
offs = le16_to_cpu(action->record.record_offset);
|
||||
attr = (ATTR_RECORD*)(buffer + offs);
|
||||
if (attr->type != AT_INDEX_ALLOCATION) {
|
||||
if (!le32_eq(attr->type, AT_INDEX_ALLOCATION)) {
|
||||
err = insert_index_allocation(vol, buffer, offs);
|
||||
if (!err)
|
||||
err = change_resident(vol, action, buffer,
|
||||
|
@ -3990,14 +3990,14 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
|
|||
* Unfortunately, only on some cases we can determine
|
||||
* the action was defined by Win10 (or subsequent).
|
||||
*/
|
||||
if (action->record.log_record_flags
|
||||
& const_cpu_to_le16(RECORD_DELETING | RECORD_ADDING)) {
|
||||
if (action->record.attribute_flags
|
||||
& const_cpu_to_le16(ACTS_ON_INDX))
|
||||
if (!le16_andz(action->record.log_record_flags,
|
||||
const_cpu_to_le16(RECORD_DELETING | RECORD_ADDING))) {
|
||||
if (!le16_andz(action->record.attribute_flags,
|
||||
const_cpu_to_le16(ACTS_ON_INDX)))
|
||||
kind = ON_INDX;
|
||||
else
|
||||
if (action->record.attribute_flags
|
||||
& const_cpu_to_le16(ACTS_ON_MFT))
|
||||
if (!le16_andz(action->record.attribute_flags,
|
||||
const_cpu_to_le16(ACTS_ON_MFT)))
|
||||
kind = ON_MFT;
|
||||
else
|
||||
kind = ON_RAW;
|
||||
|
@ -4008,7 +4008,7 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
|
|||
*/
|
||||
pa = getattrentry(le16_to_cpu(
|
||||
action->record.target_attribute),0);
|
||||
if (!pa || !pa->type) {
|
||||
if (!pa || le32_cmpz(pa->type)) {
|
||||
/*
|
||||
* Even when the attribute has not been recorded,
|
||||
* we can sometimes tell the record does not apply
|
||||
|
@ -4020,8 +4020,8 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
|
|||
*/
|
||||
data = (const char*)&action->record
|
||||
+ get_redo_offset(&action->record);
|
||||
if (action->record.record_offset
|
||||
|| (!action->record.attribute_offset
|
||||
if (!le16_cmpz(action->record.record_offset)
|
||||
|| (le16_cmpz(action->record.attribute_offset)
|
||||
&& (le16_to_cpu(action->record.redo_length)
|
||||
>= 4)
|
||||
&& memcmp(data,"FILE",4)
|
||||
|
@ -4035,7 +4035,7 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
|
|||
kind = ON_NONE;
|
||||
}
|
||||
} else {
|
||||
if (pa->type == AT_INDEX_ALLOCATION)
|
||||
if (le32_eq(pa->type, AT_INDEX_ALLOCATION))
|
||||
kind = ON_INDX;
|
||||
else
|
||||
kind = ON_RAW;
|
||||
|
@ -4074,93 +4074,93 @@ static int distribute_redos(ntfs_volume *vol,
|
|||
uop = le16_to_cpu(action->record.undo_operation);
|
||||
switch (rop) {
|
||||
case AddIndexEntryAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteIndexEntryAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteIndexEntryAllocation)))
|
||||
err = redo_add_index(vol, action, buffer);
|
||||
break;
|
||||
case AddIndexEntryRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteIndexEntryRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteIndexEntryRoot)))
|
||||
err = redo_add_root_index(vol, action, buffer);
|
||||
break;
|
||||
case ClearBitsInNonResidentBitMap :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
|
||||
err = redo_force_bits(vol, action, buffer);
|
||||
break;
|
||||
case CompensationlogRecord :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = redo_compensate(vol, action, buffer);
|
||||
break;
|
||||
case CreateAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteAttribute))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteAttribute)))
|
||||
err = redo_create_attribute(vol, action, buffer);
|
||||
break;
|
||||
case DeallocateFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(InitializeFileRecordSegment))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(InitializeFileRecordSegment)))
|
||||
err = redo_delete_file(vol, action, buffer);
|
||||
break;
|
||||
case DeleteAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(CreateAttribute))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(CreateAttribute)))
|
||||
err = redo_delete_attribute(vol, action, buffer);
|
||||
break;
|
||||
case DeleteIndexEntryAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(AddIndexEntryAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(AddIndexEntryAllocation)))
|
||||
err = redo_delete_index(vol, action, buffer);
|
||||
break;
|
||||
case DeleteIndexEntryRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(AddIndexEntryRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(AddIndexEntryRoot)))
|
||||
err = redo_delete_root_index(vol, action, buffer);
|
||||
break;
|
||||
case InitializeFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = redo_create_file(vol, action, buffer);
|
||||
break;
|
||||
case OpenNonResidentAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = redo_open_attribute(vol, action);
|
||||
break;
|
||||
case SetBitsInNonResidentBitMap :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(ClearBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(ClearBitsInNonResidentBitMap)))
|
||||
err = redo_force_bits(vol, action, buffer);
|
||||
break;
|
||||
case SetIndexEntryVcnAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetIndexEntryVcnAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetIndexEntryVcnAllocation)))
|
||||
err = redo_update_vcn(vol, action, buffer);
|
||||
break;
|
||||
case SetIndexEntryVcnRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetIndexEntryVcnRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetIndexEntryVcnRoot)))
|
||||
err = redo_update_root_vcn(vol, action, buffer);
|
||||
break;
|
||||
case SetNewAttributeSizes :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetNewAttributeSizes))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetNewAttributeSizes)))
|
||||
err = redo_sizes(vol, action, buffer);
|
||||
break;
|
||||
case UpdateFileNameAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateFileNameAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateFileNameAllocation)))
|
||||
err = redo_update_index(vol, action, buffer);
|
||||
break;
|
||||
case UpdateFileNameRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateFileNameRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateFileNameRoot)))
|
||||
err = redo_update_root_index(vol, action, buffer);
|
||||
break;
|
||||
case UpdateMappingPairs :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateMappingPairs))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateMappingPairs)))
|
||||
err = redo_update_mapping(vol, action, buffer);
|
||||
break;
|
||||
case UpdateNonResidentValue :
|
||||
|
@ -4177,23 +4177,23 @@ static int distribute_redos(ntfs_volume *vol,
|
|||
}
|
||||
break;
|
||||
case UpdateResidentValue :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateResidentValue))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateResidentValue)))
|
||||
err = redo_update_resident(vol, action, buffer);
|
||||
break;
|
||||
case Win10Action37 :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = redo_action37(vol, action, buffer);
|
||||
break;
|
||||
case WriteEndofFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(WriteEndofFileRecordSegment))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(WriteEndofFileRecordSegment)))
|
||||
err = redo_write_end(vol, action, buffer);
|
||||
break;
|
||||
case WriteEndOfIndexBuffer :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(WriteEndOfIndexBuffer))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(WriteEndOfIndexBuffer)))
|
||||
err = redo_write_index(vol, action, buffer);
|
||||
break;
|
||||
case AttributeNamesDump :
|
||||
|
@ -4334,7 +4334,7 @@ printf("** %s (action %d) not acting on MFT\n",actionname(rop),(int)action->num)
|
|||
buffer = read_protected(vol, &action->record,
|
||||
mftrecsz, warn);
|
||||
entry = (MFT_RECORD*)buffer;
|
||||
if (entry && (entry->magic == magic_FILE)) {
|
||||
if (entry && le32_eq(entry->magic, magic_FILE)) {
|
||||
data_lsn = sle64_to_cpu(entry->lsn);
|
||||
/*
|
||||
* Beware of records not updated
|
||||
|
@ -4376,7 +4376,7 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
|
|||
buffer = read_protected(vol, &action->record,
|
||||
xsize, warn);
|
||||
indx = (INDEX_BLOCK*)buffer;
|
||||
if (indx && (indx->magic == magic_INDX)) {
|
||||
if (indx && le32_eq(indx->magic, magic_INDX)) {
|
||||
data_lsn = sle64_to_cpu(indx->lsn);
|
||||
/*
|
||||
* Beware of records not updated
|
||||
|
@ -4406,8 +4406,8 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
|
|||
}
|
||||
break;
|
||||
case ON_RAW :
|
||||
if (action->record.attribute_flags
|
||||
& (const_cpu_to_le16(ACTS_ON_INDX | ACTS_ON_MFT))) {
|
||||
if (!le16_andz(action->record.attribute_flags,
|
||||
(const_cpu_to_le16(ACTS_ON_INDX | ACTS_ON_MFT)))) {
|
||||
printf("** Error : action %s on MFT"
|
||||
" or INDX\n",
|
||||
actionname(rop));
|
||||
|
@ -4474,88 +4474,88 @@ static int distribute_undos(ntfs_volume *vol, const struct ACTION_RECORD *action
|
|||
uop = le16_to_cpu(action->record.undo_operation);
|
||||
switch (rop) {
|
||||
case AddIndexEntryAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteIndexEntryAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteIndexEntryAllocation)))
|
||||
err = undo_add_index(vol, action, buffer);
|
||||
break;
|
||||
case AddIndexEntryRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteIndexEntryRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteIndexEntryRoot)))
|
||||
err = undo_add_root_index(vol, action, buffer);
|
||||
break;
|
||||
case ClearBitsInNonResidentBitMap :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
|
||||
err = undo_force_bits(vol, action, buffer);
|
||||
break;
|
||||
case CreateAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(DeleteAttribute))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(DeleteAttribute)))
|
||||
err = undo_create_attribute(vol, action, buffer);
|
||||
break;
|
||||
case DeallocateFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(InitializeFileRecordSegment))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(InitializeFileRecordSegment)))
|
||||
err = undo_delete_file(vol, action, buffer);
|
||||
break;
|
||||
case DeleteAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(CreateAttribute))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(CreateAttribute)))
|
||||
err = undo_delete_attribute(vol, action, buffer);
|
||||
break;
|
||||
case DeleteIndexEntryAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(AddIndexEntryAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(AddIndexEntryAllocation)))
|
||||
err = undo_delete_index(vol, action, buffer);
|
||||
break;
|
||||
case DeleteIndexEntryRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(AddIndexEntryRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(AddIndexEntryRoot)))
|
||||
err = undo_delete_root_index(vol, action, buffer);
|
||||
break;
|
||||
case InitializeFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = undo_create_file(vol, action, buffer);
|
||||
break;
|
||||
case OpenNonResidentAttribute :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = undo_open_attribute(vol, action);
|
||||
break;
|
||||
case SetBitsInNonResidentBitMap :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(ClearBitsInNonResidentBitMap))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(ClearBitsInNonResidentBitMap)))
|
||||
err = undo_force_bits(vol, action, buffer);
|
||||
break;
|
||||
case SetIndexEntryVcnAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetIndexEntryVcnAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetIndexEntryVcnAllocation)))
|
||||
err = undo_update_vcn(vol, action, buffer);
|
||||
break;
|
||||
case SetIndexEntryVcnRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetIndexEntryVcnRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetIndexEntryVcnRoot)))
|
||||
err = undo_update_root_vcn(vol, action, buffer);
|
||||
break;
|
||||
case SetNewAttributeSizes :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(SetNewAttributeSizes))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(SetNewAttributeSizes)))
|
||||
err = undo_sizes(vol, action, buffer);
|
||||
break;
|
||||
case UpdateFileNameAllocation :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateFileNameAllocation))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateFileNameAllocation)))
|
||||
err = undo_update_index(vol, action, buffer);
|
||||
break;
|
||||
case UpdateFileNameRoot :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateFileNameRoot))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateFileNameRoot)))
|
||||
err = undo_update_root_index(vol, action, buffer);
|
||||
break;
|
||||
case UpdateMappingPairs :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateMappingPairs))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateMappingPairs)))
|
||||
err = undo_update_mapping(vol, action, buffer);
|
||||
break;
|
||||
case UpdateNonResidentValue :
|
||||
|
@ -4572,23 +4572,23 @@ static int distribute_undos(ntfs_volume *vol, const struct ACTION_RECORD *action
|
|||
}
|
||||
break;
|
||||
case UpdateResidentValue :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(UpdateResidentValue))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(UpdateResidentValue)))
|
||||
err = undo_update_resident(vol, action, buffer);
|
||||
break;
|
||||
case Win10Action37 :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(Noop))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(Noop)))
|
||||
err = undo_action37(vol, action, buffer);
|
||||
break;
|
||||
case WriteEndofFileRecordSegment :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(WriteEndofFileRecordSegment))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(WriteEndofFileRecordSegment)))
|
||||
err = undo_write_end(vol, action, buffer);
|
||||
break;
|
||||
case WriteEndOfIndexBuffer :
|
||||
if (action->record.undo_operation
|
||||
== const_cpu_to_le16(WriteEndOfIndexBuffer))
|
||||
if (le16_eq(action->record.undo_operation,
|
||||
const_cpu_to_le16(WriteEndOfIndexBuffer)))
|
||||
err = undo_write_index(vol, action, buffer);
|
||||
break;
|
||||
case AttributeNamesDump :
|
||||
|
@ -4713,7 +4713,7 @@ printf("** %s (action %d) not acting on MFT\n",actionname(rop),(int)action->num)
|
|||
buffer = read_protected(vol, &action->record, mftrecsz, TRUE);
|
||||
entry = (MFT_RECORD*)buffer;
|
||||
if (entry) {
|
||||
if (entry->magic == magic_FILE) {
|
||||
if (le32_eq(entry->magic, magic_FILE)) {
|
||||
executed = !older_record(entry,
|
||||
&action->record);
|
||||
if (!executed
|
||||
|
@ -4747,7 +4747,7 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
|
|||
buffer = read_protected(vol, &action->record, xsize, TRUE);
|
||||
indx = (INDEX_BLOCK*)buffer;
|
||||
if (indx) {
|
||||
if (indx->magic == magic_INDX) {
|
||||
if (le32_eq(indx->magic, magic_INDX)) {
|
||||
executed = !older_record(indx,
|
||||
&action->record);
|
||||
if (!executed
|
||||
|
@ -4775,8 +4775,8 @@ printf("index lsn 0x%llx is %s than action %d lsn 0x%llx\n",
|
|||
}
|
||||
break;
|
||||
case ON_RAW :
|
||||
if (action->record.attribute_flags
|
||||
& (const_cpu_to_le16(ACTS_ON_INDX | ACTS_ON_MFT))) {
|
||||
if (!le16_andz(action->record.attribute_flags,
|
||||
(const_cpu_to_le16(ACTS_ON_INDX | ACTS_ON_MFT)))) {
|
||||
printf("** Error : action %s on MFT or INDX\n",
|
||||
actionname(rop));
|
||||
err = 1;
|
||||
|
|
Loading…
Reference in New Issue