Lines Matching refs:ctx

186 static s64 loclogblk(CONTEXT *ctx, unsigned int blk)
191 if (ctx->vol) {
322 static const struct BUFFER *read_buffer(CONTEXT *ctx, unsigned int num)
369 if (ctx->vol)
373 got = !fseek(ctx->file, loclogblk(ctx, rnum), 0)
375 1, ctx->file) == 1);
1097 static const struct BUFFER *findprevious(CONTEXT *ctx, const struct BUFFER *buf)
1145 prevbuf = read_buffer(ctx, prevblk);
1295 static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
1339 if (!ctx->vol && !mftrecsz && (length > 8)) {
1860 static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
2029 fixup(ctx, logr, (const char*)logr + redo, TRUE);
2036 fixup(ctx, logr, (const char*)logr + redo, TRUE);
2058 fixup(ctx, logr, (const char*)logr + undo, FALSE);
2067 fixup(ctx, logr, (const char*)logr + undo, FALSE);
2157 static void showlogr(CONTEXT *ctx, int k, const LOG_RECORD *logr)
2187 detaillogr(ctx, logr);
2289 static TRISTATE enqueue_action(CONTEXT *ctx, const LOG_RECORD *logr,
2307 action->next = ctx->firstaction;
2308 if (ctx->firstaction)
2309 ctx->firstaction->prev = action;
2311 ctx->lastaction = action;
2312 ctx->firstaction = action;
2322 err = refresh_attributes(ctx->firstaction);
2327 (int)ctx->lastaction->num,
2328 (int)ctx->firstaction->num);
2329 err = play_undos(ctx->vol, ctx->lastaction);
2339 (int)ctx->firstaction->num,
2340 (int)ctx->lastaction->num);
2341 mark_transactions(ctx->lastaction);
2342 err = play_redos(ctx->vol, ctx->firstaction);
2353 while (ctx->firstaction) {
2354 action = ctx->firstaction->next;
2355 free(ctx->firstaction);
2356 ctx->firstaction = action;
2358 ctx->lastaction = (struct ACTION_RECORD*)NULL;
2365 err = refresh_attributes(ctx->firstaction);
2366 mark_transactions(ctx->lastaction);
2370 (int)ctx->firstaction->num,
2371 (int)ctx->lastaction->num);
2372 err = play_redos(ctx->vol, ctx->firstaction);
2453 static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
2495 showlogr(ctx, k,
2526 midbuf = read_buffer(ctx, blk + i);
2542 midbuf = read_buffer(ctx, blk + skip + 1);
2562 showlogr(ctx, k,
2612 static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
2664 showlogr(ctx, k, logr);
2679 showlogr(ctx, k, logr);
2692 k = overlapshow(ctx, k, blk,
2816 static BOOL dorest(CONTEXT *ctx, unsigned long blk,
2866 (long long)loclogblk(ctx, blk));
2875 if (ctx->vol) {
2919 static const struct BUFFER *read_restart(CONTEXT *ctx)
2930 if (ctx->vol) {
2938 dorest(ctx, 0, rph, TRUE);
2940 buf = read_buffer(ctx,0);
2953 buf = read_buffer(ctx,0);
2975 if (!bad && !ctx->vol)
2976 dorest(ctx, 0, &buf->block.restart, TRUE);
3005 static int reset_logfile(CONTEXT *ctx __attribute__((unused)))
3073 * Probably not needed any more, use ctx->vol
3129 static int locatelogfile(CONTEXT *ctx)
3134 log_ni = ntfs_inode_open(ctx->vol, FILE_LogFile);
3153 static BOOL getlogfiledata(CONTEXT *ctx, const char *boot)
3164 fseek(ctx->file,0L,2);
3165 size = ftell(ctx->file);
3219 static BOOL getvolumedata(CONTEXT *ctx, char *boot)
3226 if (ctx->vol) {
3228 mftlcn = ctx->vol->mft_lcn;
3229 mftcnt = ctx->vol->mft_na->data_size/mftrecsz;
3230 if (!locatelogfile(ctx))
3236 if (ctx->file
3239 ok = getlogfiledata(ctx, boot);
3265 static BOOL open_volume(CONTEXT *ctx, const char *device_name)
3282 ctx->vol = (ntfs_volume*)NULL;
3283 ctx->file = fopen(device_name, "rb");
3284 if (ctx->file) {
3285 got = fread(boot.buf,1,1024,ctx->file);
3290 ctx->vol = (ntfs_volume*)NULL;
3291 ok = getvolumedata(ctx, boot.buf);
3293 fclose(ctx->file);
3297 fclose(ctx->file);
3302 ctx->file = (FILE*)NULL;
3303 ctx->vol = ntfs_mount(device_name,
3306 if (ctx->vol) {
3307 ok = getvolumedata(ctx, boot.buf);
3309 ntfs_umount(ctx->vol, TRUE);
3316 static u16 dorcrd(CONTEXT *ctx, u32 blk, u16 pos, const struct BUFFER *buf,
3325 (long long)loclogblk(ctx, blk),(int)pos);
3330 return (forward_rcrd(ctx, blk, pos, buf, nextbuf));
3337 static TRISTATE backoverlap(CONTEXT *ctx, int blk,
3381 morebuf = read_buffer(ctx, mblk);
3404 showlogr(ctx, k, (LOG_RECORD*)fullrec);
3406 state = enqueue_action(ctx,
3432 static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
3465 (long long)loclogblk(ctx, blk));
3469 (long long)loclogblk(ctx, blk));
3495 showlogr(ctx, k,logr);
3546 state = backoverlap(ctx, blk,
3575 showlogr(ctx, k, logr);
3577 state = enqueue_action(ctx, logr, size, actionnum);
3583 static int walkback(CONTEXT *ctx, const struct BUFFER *buf, u32 blk,
3595 (long long)loclogblk(ctx, buf->rnum));
3598 (long long)loclogblk(ctx, blk));
3600 ctx->firstaction = (struct ACTION_RECORD*)NULL;
3601 ctx->lastaction = (struct ACTION_RECORD*)NULL;
3604 state = backward_rcrd(ctx, blk, 0, buf,
3615 prevbuf = findprevious(ctx, buf);
3644 (long long)loclogblk(ctx, blk),
3653 ctx,buf->rnum));
3658 ctx, blk));
3660 state = backward_rcrd(ctx, blk, skipped,
3678 while (ctx->firstaction) {
3681 action = ctx->firstaction->next;
3682 free(ctx->firstaction);
3683 ctx->firstaction = action;
3685 ctx->lastaction = (struct ACTION_RECORD*)NULL;
3701 static const struct BUFFER *find_latest_block(CONTEXT *ctx, u32 baseblk,
3734 curbuf = read_buffer(ctx, curblk);
3756 static int block_sequence(CONTEXT *ctx)
3772 buf = read_buffer(ctx, blk);
3781 buf = read_buffer(ctx, blk + (BASEBLKS2 - RSTBLKS)/2);
3810 buf = read_buffer(ctx, target_blk);
3838 static int walk(CONTEXT *ctx)
3869 buf = read_restart(ctx);
3873 (long long)loclogblk(ctx, blk));
3883 nextbuf = read_buffer(ctx,
3886 nextbuf = read_buffer(ctx,nextblk);
3905 dirty = dorest(ctx, blk, &buf->block.restart,
3911 pos = dorcrd(ctx, blk, pos, buf, nextbuf);
3925 nextbuf = read_buffer(ctx,nextblk);
3937 if (ctx->vol) {
3952 finalblk = block_sequence(ctx);
3999 (long long)loclogblk(ctx, blk));
4009 ctx->firstaction = (struct ACTION_RECORD*)NULL;
4010 ctx->lastaction = (struct ACTION_RECORD*)NULL;
4013 nextbuf = read_buffer(ctx, blk+1);
4020 (long long)loclogblk(ctx, blk));
4033 (long long)loclogblk(ctx,
4043 buf = startbuf = find_latest_block(ctx,
4049 buf = startbuf = read_buffer(ctx, blk);
4062 prevbuf = findprevious(ctx, buf);
4085 err = walkback(ctx, buf, blk,
4379 CONTEXT ctx;
4398 if (open_volume(&ctx, argv[argc - 1])) {
4399 if (!ctx.vol
4405 err = walk(&ctx);
4406 if (ctx.vol) {
4410 reset_logfile(&ctx);
4414 ntfs_umount(ctx.vol, TRUE);
4416 fclose(ctx.file);
4426 if (ctx.vol) {