mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-23 10:04:00 +08:00
Typedef'ed old structs in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by declaring duplicated structs the same way
This commit is contained in:
parent
71b03fbd16
commit
2ab8bb509a
@ -114,9 +114,9 @@ typedef struct {
|
||||
|
||||
typedef enum { T_OK, T_ERR, T_DONE } TRISTATE;
|
||||
|
||||
struct RESTART_PAGE_HEADER log_header;
|
||||
struct RESTART_AREA restart;
|
||||
struct RESTART_CLIENT client;
|
||||
RESTART_PAGE_HEADER log_header;
|
||||
RESTART_AREA restart;
|
||||
LOG_CLIENT_RECORD client;
|
||||
u32 clustersz = 0;
|
||||
int clusterbits;
|
||||
u32 blocksz;
|
||||
@ -206,7 +206,7 @@ static s64 loclogblk(CONTEXT *ctx, unsigned int blk)
|
||||
static int replaceusa(struct BUFFER *buffer, unsigned int lth)
|
||||
{
|
||||
char *buf;
|
||||
struct RECORD_PAGE_HEADER *record;
|
||||
RECORD_PAGE_HEADER *record;
|
||||
unsigned int j;
|
||||
BOOL err;
|
||||
unsigned int used;
|
||||
@ -358,7 +358,7 @@ static const struct BUFFER *read_buffer(CONTEXT *ctx, unsigned int num)
|
||||
1, ctx->file) == 1);
|
||||
if (got) {
|
||||
char *data = buffer->block.data;
|
||||
buffer->headsz = sizeof(struct RECORD_PAGE_HEADER)
|
||||
buffer->headsz = sizeof(RECORD_PAGE_HEADER)
|
||||
+ ((2*getle16(data,6) - 1) | 7) + 1;
|
||||
buffer->safe = !replaceusa(buffer, blocksz);
|
||||
} else {
|
||||
@ -794,7 +794,7 @@ static BOOL acts_on_mft(int op)
|
||||
return (onmft);
|
||||
}
|
||||
|
||||
u32 get_undo_offset(const struct LOG_RECORD *logr)
|
||||
u32 get_undo_offset(const LOG_RECORD *logr)
|
||||
{
|
||||
u32 offset;
|
||||
|
||||
@ -805,7 +805,7 @@ u32 get_undo_offset(const struct LOG_RECORD *logr)
|
||||
return (offset);
|
||||
}
|
||||
|
||||
u32 get_redo_offset(const struct LOG_RECORD *logr)
|
||||
u32 get_redo_offset(const LOG_RECORD *logr)
|
||||
{
|
||||
u32 offset;
|
||||
|
||||
@ -816,7 +816,7 @@ u32 get_redo_offset(const struct LOG_RECORD *logr)
|
||||
return (offset);
|
||||
}
|
||||
|
||||
u32 get_extra_offset(const struct LOG_RECORD *logr)
|
||||
u32 get_extra_offset(const LOG_RECORD *logr)
|
||||
{
|
||||
u32 uoffset;
|
||||
u32 roffset;
|
||||
@ -828,7 +828,7 @@ u32 get_extra_offset(const struct LOG_RECORD *logr)
|
||||
return ((((uoffset > roffset ? uoffset : roffset) - 1) | 7) + 1);
|
||||
}
|
||||
|
||||
static BOOL likelyop(const struct LOG_RECORD *logr)
|
||||
static BOOL likelyop(const LOG_RECORD *logr)
|
||||
{
|
||||
BOOL likely;
|
||||
|
||||
@ -914,7 +914,7 @@ static BOOL likelyop(const struct LOG_RECORD *logr)
|
||||
|
||||
static u16 searchlikely(const struct BUFFER *buf)
|
||||
{
|
||||
const struct LOG_RECORD *logr;
|
||||
const LOG_RECORD *logr;
|
||||
const char *data;
|
||||
u16 k;
|
||||
|
||||
@ -922,11 +922,11 @@ static u16 searchlikely(const struct BUFFER *buf)
|
||||
printf("** Error : searchlikely() used for syncing\n");
|
||||
data = buf->block.data;
|
||||
k = buf->headsz;
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
if (!likelyop(logr)) {
|
||||
do {
|
||||
k += 8;
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
} while ((k <= (blocksz - LOG_RECORD_HEAD_SZ))
|
||||
&& !likelyop(logr));
|
||||
if (k > (blocksz - LOG_RECORD_HEAD_SZ))
|
||||
@ -954,9 +954,9 @@ static u16 searchlikely(const struct BUFFER *buf)
|
||||
static u16 firstrecord(int skipped, const struct BUFFER *buf,
|
||||
const struct BUFFER *prevbuf)
|
||||
{
|
||||
const struct RECORD_PAGE_HEADER *rph;
|
||||
const struct RECORD_PAGE_HEADER *prevrph;
|
||||
const struct LOG_RECORD *logr;
|
||||
const RECORD_PAGE_HEADER *rph;
|
||||
const RECORD_PAGE_HEADER *prevrph;
|
||||
const LOG_RECORD *logr;
|
||||
const char *data;
|
||||
const char *prevdata;
|
||||
u16 k;
|
||||
@ -978,7 +978,7 @@ static u16 firstrecord(int skipped, const struct BUFFER *buf,
|
||||
k = 0;
|
||||
/* Minimal size is apparently 48 : offset of redo_operation */
|
||||
if (k && ((blocksz - k) >= LOG_RECORD_HEAD_SZ)) {
|
||||
logr = (const struct LOG_RECORD*)&prevdata[k];
|
||||
logr = (const LOG_RECORD*)&prevdata[k];
|
||||
if (!logr->client_data_length) {
|
||||
/*
|
||||
* Sometimes the end of record is free space.
|
||||
@ -1051,7 +1051,7 @@ static u16 firstrecord(int skipped, const struct BUFFER *buf,
|
||||
* try to find a starting record.
|
||||
*/
|
||||
if (k && prevbuf && (prevbuf->num > buf->num)) {
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
/* Accept reaching the end with no record beginning */
|
||||
if ((k != le16_to_cpu(rph->next_record_offset))
|
||||
&& !likelyop(logr)) {
|
||||
@ -1081,7 +1081,7 @@ static const struct BUFFER *findprevious(CONTEXT *ctx, const struct BUFFER *buf)
|
||||
{
|
||||
const struct BUFFER *prevbuf;
|
||||
const struct BUFFER *savebuf;
|
||||
const struct RECORD_PAGE_HEADER *rph;
|
||||
const RECORD_PAGE_HEADER *rph;
|
||||
int skipped;
|
||||
int prevblk;
|
||||
BOOL prevmiddle;
|
||||
@ -1148,8 +1148,8 @@ static const struct BUFFER *findprevious(CONTEXT *ctx, const struct BUFFER *buf)
|
||||
|
||||
void copy_attribute(struct ATTR *pa, const char *buf, int length)
|
||||
{
|
||||
const struct ATTR_NEW *panew;
|
||||
struct ATTR_OLD old_aligned;
|
||||
const ATTR_NEW *panew;
|
||||
ATTR_OLD old_aligned;
|
||||
|
||||
if (pa) {
|
||||
switch (length) {
|
||||
@ -1176,7 +1176,7 @@ void copy_attribute(struct ATTR *pa, const char *buf, int length)
|
||||
static int refresh_attributes(const struct ACTION_RECORD *firstaction)
|
||||
{
|
||||
const struct ACTION_RECORD *action;
|
||||
const struct LOG_RECORD *logr;
|
||||
const LOG_RECORD *logr;
|
||||
struct ATTR *pa;
|
||||
const char *buf;
|
||||
u32 extra;
|
||||
@ -1267,7 +1267,7 @@ static int refresh_attributes(const struct ACTION_RECORD *firstaction)
|
||||
* Display a fixup
|
||||
*/
|
||||
|
||||
static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
||||
static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
|
||||
BOOL redo)
|
||||
{
|
||||
struct ATTR *pa;
|
||||
@ -1832,7 +1832,7 @@ static void fixup(CONTEXT *ctx, const struct LOG_RECORD *logr, const char *buf,
|
||||
}
|
||||
}
|
||||
|
||||
static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
||||
static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
|
||||
{
|
||||
u64 lcn;
|
||||
u64 baselcn;
|
||||
@ -2090,7 +2090,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
||||
(long long)sle64_to_cpu(logr->dirty_pages_lsn));
|
||||
listsize = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ
|
||||
- offsetof(struct LOG_RECORD, unknown_list);
|
||||
- offsetof(LOG_RECORD, unknown_list);
|
||||
if (listsize > 8*SHOWLISTS)
|
||||
listsize = 8*SHOWLISTS;
|
||||
for (i=0; 8*i<listsize; i++)
|
||||
@ -2110,7 +2110,7 @@ static void detaillogr(CONTEXT *ctx, const struct LOG_RECORD *logr)
|
||||
}
|
||||
}
|
||||
|
||||
BOOL within_lcn_range(const struct LOG_RECORD *logr)
|
||||
BOOL within_lcn_range(const LOG_RECORD *logr)
|
||||
{
|
||||
u64 lcn;
|
||||
unsigned int i;
|
||||
@ -2131,7 +2131,7 @@ BOOL within_lcn_range(const struct LOG_RECORD *logr)
|
||||
return (within);
|
||||
}
|
||||
|
||||
static void showlogr(CONTEXT *ctx, int k, const struct LOG_RECORD *logr)
|
||||
static void showlogr(CONTEXT *ctx, int k, const LOG_RECORD *logr)
|
||||
{
|
||||
s32 diff;
|
||||
|
||||
@ -2206,7 +2206,7 @@ static void showlogr(CONTEXT *ctx, int k, const struct LOG_RECORD *logr)
|
||||
static void mark_transactions(struct ACTION_RECORD *lastaction)
|
||||
{
|
||||
struct ACTION_RECORD *action;
|
||||
const struct LOG_RECORD *logr;
|
||||
const LOG_RECORD *logr;
|
||||
le32 id;
|
||||
int actives;
|
||||
BOOL more;
|
||||
@ -2263,7 +2263,7 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
|
||||
* Enqueue an action and play the queued actions on end of set
|
||||
*/
|
||||
|
||||
static TRISTATE enqueue_action(CONTEXT *ctx, const struct LOG_RECORD *logr,
|
||||
static TRISTATE enqueue_action(CONTEXT *ctx, const LOG_RECORD *logr,
|
||||
int size, int num)
|
||||
{
|
||||
struct ACTION_RECORD *action;
|
||||
@ -2359,7 +2359,7 @@ static TRISTATE enqueue_action(CONTEXT *ctx, const struct LOG_RECORD *logr,
|
||||
}
|
||||
|
||||
|
||||
static void showheadrcrd(u32 blk, const struct RECORD_PAGE_HEADER *rph)
|
||||
static void showheadrcrd(u32 blk, const RECORD_PAGE_HEADER *rph)
|
||||
{
|
||||
s32 diff;
|
||||
|
||||
@ -2430,7 +2430,7 @@ static void showheadrcrd(u32 blk, const struct RECORD_PAGE_HEADER *rph)
|
||||
static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
const struct BUFFER *nextbuf)
|
||||
{
|
||||
const struct LOG_RECORD *logr;
|
||||
const LOG_RECORD *logr;
|
||||
const char *data;
|
||||
const char *nextdata;
|
||||
char *fullrec;
|
||||
@ -2441,7 +2441,7 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
u16 blkheadsz;
|
||||
|
||||
data = buf->block.data;
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
size = le32_to_cpu(logr->client_data_length) + LOG_RECORD_HEAD_SZ;
|
||||
blkheadsz = buf->headsz;
|
||||
if (nextbuf && (blk >= BASEBLKS)) {
|
||||
@ -2457,7 +2457,7 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
memcpy(&fullrec[space],
|
||||
nextdata + blkheadsz,
|
||||
size - space);
|
||||
likely = likelyop((struct LOG_RECORD*)fullrec);
|
||||
likely = likelyop((LOG_RECORD*)fullrec);
|
||||
actionnum++;
|
||||
if (optv) {
|
||||
printf("\nOverlapping record %u at 0x%x"
|
||||
@ -2470,7 +2470,7 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
}
|
||||
if (likely)
|
||||
showlogr(ctx, k,
|
||||
(struct LOG_RECORD*)fullrec);
|
||||
(LOG_RECORD*)fullrec);
|
||||
else
|
||||
printf("** Skipping unlikely"
|
||||
" overlapping record\n");
|
||||
@ -2523,7 +2523,7 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
size - pos);
|
||||
else
|
||||
likely = FALSE;
|
||||
if (!likelyop((struct LOG_RECORD*)fullrec))
|
||||
if (!likelyop((LOG_RECORD*)fullrec))
|
||||
likely = FALSE;
|
||||
actionnum++;
|
||||
if (optv) {
|
||||
@ -2537,7 +2537,7 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
}
|
||||
if (likely)
|
||||
showlogr(ctx, k,
|
||||
(struct LOG_RECORD*)fullrec);
|
||||
(LOG_RECORD*)fullrec);
|
||||
else
|
||||
printf("** Skipping unlikely"
|
||||
" overlapping record\n");
|
||||
@ -2589,8 +2589,8 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
|
||||
static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
||||
const struct BUFFER *buf, const struct BUFFER *nextbuf)
|
||||
{
|
||||
const struct RECORD_PAGE_HEADER *rph;
|
||||
const struct LOG_RECORD *logr;
|
||||
const RECORD_PAGE_HEADER *rph;
|
||||
const LOG_RECORD *logr;
|
||||
const char *data;
|
||||
u16 k;
|
||||
u16 endoff;
|
||||
@ -2605,19 +2605,19 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
||||
k = ((pos - 1) | 7) + 1;
|
||||
}
|
||||
// TODO check bad start > blocksz - 48
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
stop = FALSE;
|
||||
if (!likelyop(logr)) {
|
||||
if (optv)
|
||||
printf("* Bad start 0x%x for block %d\n",
|
||||
(int)pos,(int)blk);
|
||||
k = searchlikely(buf);
|
||||
if ((k + sizeof(struct LOG_RECORD)) > blocksz) {
|
||||
if ((k + sizeof(LOG_RECORD)) > blocksz) {
|
||||
printf("No likely full record in block %lu\n",
|
||||
(unsigned long)blk);
|
||||
/* there can be a partial one */
|
||||
k = le16_to_cpu(rph->next_record_offset);
|
||||
if ((k < (u16)sizeof(struct RECORD_PAGE_HEADER))
|
||||
if ((k < (u16)sizeof(RECORD_PAGE_HEADER))
|
||||
|| ((blocksz - k) < LOG_RECORD_HEAD_SZ))
|
||||
stop = TRUE;
|
||||
} else {
|
||||
@ -2629,7 +2629,7 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
||||
while (!stop) {
|
||||
s32 size;
|
||||
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
size = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ;
|
||||
if ((size < MINRECSIZE)
|
||||
@ -2684,10 +2684,10 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
|
||||
* Display a restart page
|
||||
*/
|
||||
|
||||
static void showrest(const struct RESTART_PAGE_HEADER *rest)
|
||||
static void showrest(const RESTART_PAGE_HEADER *rest)
|
||||
{
|
||||
const struct RESTART_AREA *resa;
|
||||
const struct RESTART_CLIENT *rcli;
|
||||
const RESTART_AREA *resa;
|
||||
const LOG_CLIENT_RECORD *rcli;
|
||||
const char *data;
|
||||
|
||||
data = (const char*)rest;
|
||||
@ -2720,7 +2720,7 @@ static void showrest(const struct RESTART_PAGE_HEADER *rest)
|
||||
printf(" chkdsk %016llx\n",
|
||||
(long long)sle64_to_cpu(rest->chkdsk_lsn));
|
||||
}
|
||||
resa = (const struct RESTART_AREA*)
|
||||
resa = (const RESTART_AREA*)
|
||||
&data[le16_to_cpu(rest->restart_offset)];
|
||||
if (optv) {
|
||||
printf("current_lsn %016llx\n",
|
||||
@ -2756,7 +2756,7 @@ static void showrest(const struct RESTART_PAGE_HEADER *rest)
|
||||
(long long)sle64_to_cpu(resa->current_lsn));
|
||||
}
|
||||
|
||||
rcli = (const struct RESTART_CLIENT*)
|
||||
rcli = (const LOG_CLIENT_RECORD*)
|
||||
&data[le16_to_cpu(rest->restart_offset)
|
||||
+ le16_to_cpu(resa->client_array_offset)];
|
||||
if (optv) {
|
||||
@ -2791,10 +2791,10 @@ static void showrest(const struct RESTART_PAGE_HEADER *rest)
|
||||
}
|
||||
|
||||
static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
||||
const struct RESTART_PAGE_HEADER *rph, BOOL initial)
|
||||
const RESTART_PAGE_HEADER *rph, BOOL initial)
|
||||
{
|
||||
const struct RESTART_AREA *resa;
|
||||
const struct RESTART_CLIENT *rcli;
|
||||
const RESTART_AREA *resa;
|
||||
const LOG_CLIENT_RECORD *rcli;
|
||||
const char *data;
|
||||
s64 diff;
|
||||
int offs;
|
||||
@ -2804,8 +2804,8 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
||||
|
||||
data = (const char*)rph;
|
||||
offs = le16_to_cpu(rph->restart_offset);
|
||||
resa = (const struct RESTART_AREA*)&data[offs];
|
||||
rcli = (const struct RESTART_CLIENT*)&data[offs
|
||||
resa = (const RESTART_AREA*)&data[offs];
|
||||
rcli = (const LOG_CLIENT_RECORD*)&data[offs
|
||||
+ le16_to_cpu(resa->client_array_offset)];
|
||||
if (initial) {
|
||||
/* Information from block initially found best */
|
||||
@ -2813,13 +2813,13 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
||||
committed_lsn = sle64_to_cpu(rcli->client_restart_lsn);
|
||||
synced_lsn = sle64_to_cpu(rcli->oldest_lsn);
|
||||
memcpy(&log_header, rph,
|
||||
sizeof(struct RESTART_PAGE_HEADER));
|
||||
sizeof(RESTART_PAGE_HEADER));
|
||||
offs = le16_to_cpu(log_header.restart_offset);
|
||||
memcpy(&restart, &data[offs],
|
||||
sizeof(struct RESTART_AREA));
|
||||
sizeof(RESTART_AREA));
|
||||
offs += le16_to_cpu(restart.client_array_offset);
|
||||
memcpy(&client, &data[offs],
|
||||
sizeof(struct RESTART_CLIENT));
|
||||
sizeof(LOG_CLIENT_RECORD));
|
||||
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
|
||||
if (optv || optt)
|
||||
printf("* Using initial restart page,"
|
||||
@ -2859,13 +2859,13 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
|
||||
synced_lsn = sle64_to_cpu(rcli->oldest_lsn);
|
||||
latest_lsn = sle64_to_cpu(resa->current_lsn);
|
||||
memcpy(&log_header, rph,
|
||||
sizeof(struct RESTART_PAGE_HEADER));
|
||||
sizeof(RESTART_PAGE_HEADER));
|
||||
offs = le16_to_cpu(log_header.restart_offset);
|
||||
memcpy(&restart, &data[offs],
|
||||
sizeof(struct RESTART_AREA));
|
||||
sizeof(RESTART_AREA));
|
||||
offs += le16_to_cpu(restart.client_array_offset);
|
||||
memcpy(&client, &data[offs],
|
||||
sizeof(struct RESTART_CLIENT));
|
||||
sizeof(LOG_CLIENT_RECORD));
|
||||
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
|
||||
if (optv || optt)
|
||||
printf("* Using %s restart page,"
|
||||
@ -2898,9 +2898,9 @@ static const struct BUFFER *read_restart(CONTEXT *ctx)
|
||||
|
||||
bad = FALSE;
|
||||
if (ctx->vol) {
|
||||
struct RESTART_PAGE_HEADER *rph;
|
||||
RESTART_PAGE_HEADER *rph;
|
||||
|
||||
rph = (struct RESTART_PAGE_HEADER*)NULL;
|
||||
rph = (RESTART_PAGE_HEADER*)NULL;
|
||||
/* Full mode : use the restart page selected by the library */
|
||||
if (ntfs_check_logfile(log_na, &rph)) {
|
||||
/* rph is left unchanged for a wiped out log file */
|
||||
@ -2976,13 +2976,13 @@ static int reset_logfile(CONTEXT *ctx __attribute__((unused)))
|
||||
restart.flags |= RESTART_VOLUME_IS_CLEAN;
|
||||
client.oldest_lsn = cpu_to_sle64(restart_lsn);
|
||||
memcpy(buffer, &log_header,
|
||||
sizeof(struct RESTART_PAGE_HEADER));
|
||||
sizeof(RESTART_PAGE_HEADER));
|
||||
off = le16_to_cpu(log_header.restart_offset);
|
||||
memcpy(&buffer[off], &restart,
|
||||
sizeof(struct RESTART_AREA));
|
||||
sizeof(RESTART_AREA));
|
||||
off += le16_to_cpu(restart.client_array_offset);
|
||||
memcpy(&buffer[off], &client,
|
||||
sizeof(struct RESTART_CLIENT));
|
||||
sizeof(LOG_CLIENT_RECORD));
|
||||
if (!ntfs_mst_pre_write_fixup((NTFS_RECORD*)buffer, blocksz)
|
||||
&& (ntfs_attr_pwrite(log_na, 0,
|
||||
blocksz, buffer) == blocksz)
|
||||
@ -3002,8 +3002,8 @@ static const struct BUFFER *best_start(const struct BUFFER *buf,
|
||||
const struct BUFFER *altbuf)
|
||||
{
|
||||
const struct BUFFER *best;
|
||||
const struct RECORD_PAGE_HEADER *head;
|
||||
const struct RECORD_PAGE_HEADER *althead;
|
||||
const RECORD_PAGE_HEADER *head;
|
||||
const RECORD_PAGE_HEADER *althead;
|
||||
s64 diff;
|
||||
|
||||
if (!buf || !altbuf)
|
||||
@ -3109,8 +3109,8 @@ static int locatelogfile(CONTEXT *ctx)
|
||||
|
||||
static BOOL getlogfiledata(CONTEXT *ctx, const char *boot)
|
||||
{
|
||||
const struct RESTART_PAGE_HEADER *rph;
|
||||
const struct RESTART_AREA *rest;
|
||||
const RESTART_PAGE_HEADER *rph;
|
||||
const RESTART_AREA *rest;
|
||||
BOOL ok;
|
||||
u32 off;
|
||||
s64 size;
|
||||
@ -3118,9 +3118,9 @@ static BOOL getlogfiledata(CONTEXT *ctx, const char *boot)
|
||||
ok = FALSE;
|
||||
fseek(ctx->file,0L,2);
|
||||
size = ftell(ctx->file);
|
||||
rph = (const struct RESTART_PAGE_HEADER*)boot;
|
||||
rph = (const RESTART_PAGE_HEADER*)boot;
|
||||
off = le16_to_cpu(rph->restart_offset);
|
||||
rest = (const struct RESTART_AREA*)&boot[off];
|
||||
rest = (const RESTART_AREA*)&boot[off];
|
||||
|
||||
/* estimate cluster size from log file size (unreliable) */
|
||||
switch (le32_to_cpu(rest->seq_number_bits)) {
|
||||
@ -3155,11 +3155,11 @@ static BOOL getlogfiledata(CONTEXT *ctx, const char *boot)
|
||||
|
||||
static BOOL getvolumedata(CONTEXT *ctx, char *boot)
|
||||
{
|
||||
const struct RESTART_AREA *rest;
|
||||
const RESTART_AREA *rest;
|
||||
BOOL ok;
|
||||
|
||||
ok = FALSE;
|
||||
rest = (const struct RESTART_AREA*)NULL;
|
||||
rest = (const RESTART_AREA*)NULL;
|
||||
if (ctx->vol) {
|
||||
getboot(boot);
|
||||
mftlcn = ctx->vol->mft_lcn;
|
||||
@ -3267,7 +3267,7 @@ static u16 dorcrd(CONTEXT *ctx, u32 blk, u16 pos, const struct BUFFER *buf,
|
||||
static TRISTATE backoverlap(CONTEXT *ctx, int blk,
|
||||
const char *data, const char *nextdata, int k)
|
||||
{
|
||||
const struct LOG_RECORD *logr;
|
||||
const LOG_RECORD *logr;
|
||||
char *fullrec;
|
||||
s32 size;
|
||||
int space;
|
||||
@ -3275,11 +3275,11 @@ static TRISTATE backoverlap(CONTEXT *ctx, int blk,
|
||||
TRISTATE state;
|
||||
u16 blkheadsz;
|
||||
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
state = T_ERR;
|
||||
size = le32_to_cpu(logr->client_data_length) + LOG_RECORD_HEAD_SZ;
|
||||
space = blocksz - k;
|
||||
blkheadsz = sizeof(struct RECORD_PAGE_HEADER)
|
||||
blkheadsz = sizeof(RECORD_PAGE_HEADER)
|
||||
+ ((2*getle16(data,6) - 1) | 7) + 1;
|
||||
nextspace = blocksz - blkheadsz;
|
||||
if ((space >= LOG_RECORD_HEAD_SZ)
|
||||
@ -3318,7 +3318,7 @@ static TRISTATE backoverlap(CONTEXT *ctx, int blk,
|
||||
}
|
||||
}
|
||||
|
||||
state = (likelyop((struct LOG_RECORD*)fullrec) ? T_OK : T_ERR);
|
||||
state = (likelyop((LOG_RECORD*)fullrec) ? T_OK : T_ERR);
|
||||
actionnum++;
|
||||
if (optv) {
|
||||
printf("\nOverlapping backward action %d at 0x%x"
|
||||
@ -3330,10 +3330,10 @@ static TRISTATE backoverlap(CONTEXT *ctx, int blk,
|
||||
(long)blk,(int)space,(state == T_OK));
|
||||
}
|
||||
if (state == T_OK) {
|
||||
showlogr(ctx, k, (struct LOG_RECORD*)fullrec);
|
||||
showlogr(ctx, k, (LOG_RECORD*)fullrec);
|
||||
if (optp || optu || opts)
|
||||
state = enqueue_action(ctx,
|
||||
(struct LOG_RECORD*)fullrec,
|
||||
(LOG_RECORD*)fullrec,
|
||||
size, actionnum);
|
||||
} else {
|
||||
/* Try to go on unless playing actions */
|
||||
@ -3362,10 +3362,10 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
||||
const struct BUFFER *buf, const struct BUFFER *prevbuf,
|
||||
const struct BUFFER *nextbuf)
|
||||
{
|
||||
u16 poslist[75]; /* 4096/sizeof(struct LOG_RECORD) */
|
||||
const struct RECORD_PAGE_HEADER *rph;
|
||||
const struct RECORD_PAGE_HEADER *prevrph;
|
||||
const struct LOG_RECORD *logr;
|
||||
u16 poslist[75]; /* 4096/sizeof(LOG_RECORD) */
|
||||
const RECORD_PAGE_HEADER *rph;
|
||||
const RECORD_PAGE_HEADER *prevrph;
|
||||
const LOG_RECORD *logr;
|
||||
const char *data;
|
||||
const char *nextdata;
|
||||
BOOL stop;
|
||||
@ -3378,7 +3378,7 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
||||
|
||||
state = T_ERR;
|
||||
rph = &buf->block.record;
|
||||
prevrph = (struct RECORD_PAGE_HEADER*)NULL;
|
||||
prevrph = (RECORD_PAGE_HEADER*)NULL;
|
||||
if (prevbuf)
|
||||
prevrph = &prevbuf->block.record;
|
||||
data = buf->block.data;
|
||||
@ -3399,12 +3399,12 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
||||
k = buf->headsz;
|
||||
else
|
||||
k = firstrecord(skipped, buf, prevbuf);
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
cnt = 0;
|
||||
/* check whether there is at least one beginning of record */
|
||||
endoff = le16_to_cpu(rph->next_record_offset);
|
||||
if (k && ((k < endoff) || !endoff)) {
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
if (likelyop(logr)) {
|
||||
stop = FALSE;
|
||||
state = T_OK;
|
||||
@ -3430,7 +3430,7 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
||||
}
|
||||
}
|
||||
while (!stop) {
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
size = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ;
|
||||
if ((size < MINRECSIZE)
|
||||
@ -3472,7 +3472,7 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
|
||||
}
|
||||
for (j=cnt-1; (j>=0) && (state==T_OK); j--) {
|
||||
k = poslist[j];
|
||||
logr = (const struct LOG_RECORD*)&data[k];
|
||||
logr = (const LOG_RECORD*)&data[k];
|
||||
size = le32_to_cpu(logr->client_data_length)
|
||||
+ LOG_RECORD_HEAD_SZ;
|
||||
actionnum++;
|
||||
@ -3599,7 +3599,7 @@ static int walk(CONTEXT *ctx)
|
||||
const struct BUFFER *prevbuf;
|
||||
const struct BUFFER *startbuf;
|
||||
const NTFS_RECORD *record;
|
||||
const struct RECORD_PAGE_HEADER *rph;
|
||||
const RECORD_PAGE_HEADER *rph;
|
||||
NTFS_RECORD_TYPES magic;
|
||||
u32 blk;
|
||||
u32 nextblk;
|
||||
@ -4052,28 +4052,28 @@ static BOOL checkstructs(void)
|
||||
BOOL ok;
|
||||
|
||||
ok = TRUE;
|
||||
if (sizeof(struct RECORD_PAGE_HEADER) != 40) {
|
||||
if (sizeof(RECORD_PAGE_HEADER) != 40) {
|
||||
fprintf(stderr,
|
||||
"* error : bad sizeof(struct RECORD_PAGE_HEADER) %d\n",
|
||||
(int)sizeof(struct RECORD_PAGE_HEADER));
|
||||
"* error : bad sizeof(RECORD_PAGE_HEADER) %d\n",
|
||||
(int)sizeof(RECORD_PAGE_HEADER));
|
||||
ok = FALSE;
|
||||
}
|
||||
if (sizeof(struct LOG_RECORD) != 88) {
|
||||
if (sizeof(LOG_RECORD) != 88) {
|
||||
fprintf(stderr,
|
||||
"* error : bad sizeof(struct LOG_RECORD) %d\n",
|
||||
(int)sizeof(struct LOG_RECORD));
|
||||
"* error : bad sizeof(LOG_RECORD) %d\n",
|
||||
(int)sizeof(LOG_RECORD));
|
||||
ok = FALSE;
|
||||
}
|
||||
if (sizeof(struct RESTART_PAGE_HEADER) != 32) {
|
||||
if (sizeof(RESTART_PAGE_HEADER) != 32) {
|
||||
fprintf(stderr,
|
||||
"* error : bad sizeof(struct RESTART_PAGE_HEADER) %d\n",
|
||||
(int)sizeof(struct RESTART_PAGE_HEADER));
|
||||
"* error : bad sizeof(RESTART_PAGE_HEADER) %d\n",
|
||||
(int)sizeof(RESTART_PAGE_HEADER));
|
||||
ok = FALSE;
|
||||
}
|
||||
if (sizeof(struct RESTART_AREA) != 44) {
|
||||
if (sizeof(RESTART_AREA) != 44) {
|
||||
fprintf(stderr,
|
||||
"* error : bad sizeof(struct RESTART_AREA) %d\n",
|
||||
(int)sizeof(struct RESTART_AREA));
|
||||
"* error : bad sizeof(RESTART_AREA) %d\n",
|
||||
(int)sizeof(RESTART_AREA));
|
||||
ok = FALSE;
|
||||
}
|
||||
if (sizeof(struct ATTR_OLD) != 44) {
|
||||
|
@ -128,7 +128,7 @@ typedef enum {
|
||||
|
||||
/* ntfsdoc p 39 (47), not in layout.h */
|
||||
|
||||
typedef struct RESTART_PAGE_HEADER { /* size 32 */
|
||||
typedef struct { /* size 32 */
|
||||
NTFS_RECORD head;
|
||||
leLSN chkdsk_lsn;
|
||||
le32 system_page_size;
|
||||
@ -141,7 +141,7 @@ typedef struct RESTART_PAGE_HEADER { /* size 32 */
|
||||
|
||||
/* ntfsdoc p 40 (48), not in layout.h */
|
||||
|
||||
struct RESTART_AREA { /* size 44 */
|
||||
typedef struct { /* size 44 */
|
||||
leLSN current_lsn;
|
||||
le16 log_clients;
|
||||
le16 client_free_list;
|
||||
@ -155,9 +155,9 @@ struct RESTART_AREA { /* size 44 */
|
||||
le16 record_length;
|
||||
le16 log_page_data_offset;
|
||||
le32 restart_log_open_count;
|
||||
} __attribute__((__packed__)) ;
|
||||
} __attribute__((__packed__)) RESTART_AREA;
|
||||
|
||||
typedef struct RESTART_CLIENT { /* size 160 */
|
||||
typedef struct { /* size 160 */
|
||||
/*Ofs*/
|
||||
/* 0*/ leLSN oldest_lsn; /* Oldest LSN needed by this client. On create
|
||||
set to 0. */
|
||||
@ -194,7 +194,7 @@ typedef struct RESTART_CLIENT { /* size 160 */
|
||||
|
||||
/* ntfsdoc p 41 (49), not in layout.h */
|
||||
|
||||
struct RECORD_PAGE_HEADER { /* size 40 */
|
||||
typedef struct { /* size 40 */
|
||||
NTFS_RECORD head; /* the magic is "RCRD" */
|
||||
union {
|
||||
leLSN last_lsn;
|
||||
@ -206,13 +206,13 @@ struct RECORD_PAGE_HEADER { /* size 40 */
|
||||
le16 next_record_offset;
|
||||
le16 reserved4[3];
|
||||
leLSN last_end_lsn;
|
||||
} __attribute__((__packed__)) ;
|
||||
} __attribute__((__packed__)) RECORD_PAGE_HEADER;
|
||||
|
||||
/* ntfsdoc p 42 (50), not in layout.h */
|
||||
|
||||
#define LOG_RECORD_HEAD_SZ 0x30 /* size of header of struct LOG_RECORD */
|
||||
|
||||
typedef struct LOG_RECORD { /* size 80 */
|
||||
typedef struct { /* size 80 */
|
||||
leLSN this_lsn;
|
||||
leLSN client_previous_lsn;
|
||||
leLSN client_undo_next_lsn;
|
||||
@ -259,8 +259,8 @@ struct BUFFER {
|
||||
unsigned int headsz;
|
||||
BOOL safe;
|
||||
union {
|
||||
struct RESTART_PAGE_HEADER restart;
|
||||
struct RECORD_PAGE_HEADER record;
|
||||
RESTART_PAGE_HEADER restart;
|
||||
RECORD_PAGE_HEADER record;
|
||||
char data[1];
|
||||
} block; /* variable length, keep at the end */
|
||||
} ;
|
||||
@ -270,7 +270,7 @@ struct ACTION_RECORD {
|
||||
struct ACTION_RECORD *prev;
|
||||
int num;
|
||||
unsigned int flags;
|
||||
struct LOG_RECORD record; /* variable length, keep at the end */
|
||||
LOG_RECORD record; /* variable length, keep at the end */
|
||||
} ;
|
||||
|
||||
enum { /* Flag values for ACTION_RECORD */
|
||||
@ -336,19 +336,19 @@ extern u64 synced_lsn;
|
||||
extern u64 latest_lsn;
|
||||
extern u64 restart_lsn;
|
||||
|
||||
extern struct RESTART_AREA restart;
|
||||
extern struct RESTART_CLIENT client;
|
||||
extern RESTART_AREA restart;
|
||||
extern LOG_CLIENT_RECORD client;
|
||||
|
||||
const char *actionname(int op);
|
||||
const char *mftattrname(ATTR_TYPES attr);
|
||||
void showname(const char *prefix, const char *name, int cnt);
|
||||
int fixnamelen(const char *name, int len);
|
||||
BOOL within_lcn_range(const struct LOG_RECORD *logr);
|
||||
BOOL within_lcn_range(const LOG_RECORD *logr);
|
||||
struct ATTR *getattrentry(unsigned int key, unsigned int lth);
|
||||
void copy_attribute(struct ATTR *pa, const char *buf, int length);
|
||||
u32 get_undo_offset(const struct LOG_RECORD *logr);
|
||||
u32 get_redo_offset(const struct LOG_RECORD *logr);
|
||||
u32 get_extra_offset(const struct LOG_RECORD *logr);
|
||||
u32 get_undo_offset(const LOG_RECORD *logr);
|
||||
u32 get_redo_offset(const LOG_RECORD *logr);
|
||||
u32 get_extra_offset(const LOG_RECORD *logr);
|
||||
BOOL exception(int num);
|
||||
|
||||
struct STORE;
|
||||
|
@ -117,7 +117,7 @@ static void locate(const char *s, int n, const char *p, int m)
|
||||
}
|
||||
*/
|
||||
|
||||
static u64 inode_number(const struct LOG_RECORD *logr)
|
||||
static u64 inode_number(const LOG_RECORD *logr)
|
||||
{
|
||||
u64 offset;
|
||||
|
||||
@ -409,7 +409,7 @@ static int sanity_indx(ntfs_volume *vol, const char *buffer)
|
||||
* With option -n reading is first attempted from the memory store
|
||||
*/
|
||||
|
||||
static char *read_raw(ntfs_volume *vol, const struct LOG_RECORD *logr)
|
||||
static char *read_raw(ntfs_volume *vol, const LOG_RECORD *logr)
|
||||
{
|
||||
char *buffer;
|
||||
char *target;
|
||||
@ -477,7 +477,7 @@ static char *read_raw(ntfs_volume *vol, const struct LOG_RECORD *logr)
|
||||
* With option -n a copy of the buffer is kept in memory for later use.
|
||||
*/
|
||||
|
||||
static int write_raw(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
static int write_raw(ntfs_volume *vol, const LOG_RECORD *logr,
|
||||
char *buffer)
|
||||
{
|
||||
int err;
|
||||
@ -532,7 +532,7 @@ static int write_raw(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
* Write a full set of raw clusters to mft_mirr
|
||||
*/
|
||||
|
||||
static int write_mirr(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
static int write_mirr(ntfs_volume *vol, const LOG_RECORD *logr,
|
||||
char *buffer)
|
||||
{
|
||||
int err;
|
||||
@ -566,7 +566,7 @@ static int write_mirr(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
* Allocate a buffer and read a single protected record
|
||||
*/
|
||||
|
||||
static char *read_protected(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
static char *read_protected(ntfs_volume *vol, const LOG_RECORD *logr,
|
||||
u32 size, BOOL warn)
|
||||
{
|
||||
char *buffer;
|
||||
@ -614,7 +614,7 @@ static char *read_protected(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
* than a cluster, have to read, merge and write.
|
||||
*/
|
||||
|
||||
static int write_protected(ntfs_volume *vol, const struct LOG_RECORD *logr,
|
||||
static int write_protected(ntfs_volume *vol, const LOG_RECORD *logr,
|
||||
char *buffer, u32 size)
|
||||
{
|
||||
MFT_RECORD *record;
|
||||
|
Loading…
Reference in New Issue
Block a user