Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 107635
Collapse All | Expand All

(-)convertfs/devremap.c (-1 / +63 lines)
Lines 19-24 Link Here
19
#include <string.h>
19
#include <string.h>
20
#include <fcntl.h>
20
#include <fcntl.h>
21
#include <unistd.h>
21
#include <unistd.h>
22
#include <time.h>
22
23
23
#include "convertfs.h"
24
#include "convertfs.h"
24
25
Lines 80-85 Link Here
80
static struct superblock super;
81
static struct superblock super;
81
static struct info	 info;
82
static struct info	 info;
82
83
84
85
/* ULTRA UGLY HACK */
86
struct indexpage *hack_ip;
87
struct chunk     *hack_chunk = NULL;
88
baddr_t          *hack_physp;
89
baddr_t          hack_virt;
90
int              hack_i;
91
92
83
static void
93
static void
84
die (const char *format, ...)
94
die (const char *format, ...)
85
{
95
{
Lines 346-362 Link Here
346
	baddr_t		 virt;
356
	baddr_t		 virt;
347
	int		 i;
357
	int		 i;
348
358
359
/*        printf("find_cross_block\n"); */
360
361
        if(hack_chunk != NULL)
362
        {
363
            if ((*hack_physp == bm->to) && (*hack_physp != hack_virt))
364
            {
365
366
                ip = hack_ip;
367
                chunk = hack_chunk;
368
                physp = hack_physp;
369
                virt = hack_virt;
370
                i = hack_i;
371
372
                goto VERY_UGLY_HACK;
373
            }
374
        }
375
349
	i = bm->i + 1;
376
	i = bm->i + 1;
350
	chunk = bm->chunk;
377
	chunk = bm->chunk;
351
	for (ip = bm->ip; ip; ip = ip->next, chunk = ip->chunk)
378
	for (ip = bm->ip; ip; ip = ip->next, chunk = ip->chunk)
352
		for (; chunk; chunk = next_chunk(ip, chunk), i = 0) {
379
		for (; chunk; chunk = next_chunk(ip, chunk), i = 0) {
380
381
/*  printf("chunk: %p  bm->to: %lx\n", chunk, (long int)bm->to); */
382
353
			virt = chunk->offset + i;
383
			virt = chunk->offset + i;
354
			physp = &chunk->block[i];
384
			physp = &chunk->block[i];
355
			for (; i < chunk->nblocks; i++, virt++, physp++)
385
			for (; i < chunk->nblocks; i++, virt++, physp++) {
386
                                VERY_UGLY_HACK:
387
 
356
				if ((*physp == bm->to) && (*physp != virt)) {
388
				if ((*physp == bm->to) && (*physp != virt)) {
389
390
                                        hack_ip = ip;
391
                                        hack_chunk = chunk;
392
                                        hack_physp = physp;
393
                                        hack_virt = virt;
394
                                        hack_i = i;
395
396
                                        hack_i++;
397
                                        hack_virt++;
398
                                        hack_physp++;
399
400
                                        if(hack_i >= chunk->nblocks)
401
                                        {
402
                                            hack_chunk = next_chunk(hack_ip, hack_chunk);
403
                                            hack_i = 0;
404
405
                                            if(hack_chunk)
406
                                            {
407
                                                hack_virt = hack_chunk->offset + hack_i;
408
                                                hack_physp = &hack_chunk->block[hack_i];
409
                                            }
410
                                        }
411
357
					handle_cross_block(ip, bm, physp, virt);
412
					handle_cross_block(ip, bm, physp, virt);
358
					return 1;
413
					return 1;
359
				}
414
				}
415
                       }
360
		}
416
		}
361
	return 0;
417
	return 0;
362
}
418
}
Lines 606-611 Link Here
606
int
662
int
607
main (int argc, char *argv[])
663
main (int argc, char *argv[])
608
{
664
{
665
        time_t t;
666
609
	selfname = argv[0];
667
	selfname = argv[0];
610
	if (argc != 2) {
668
	if (argc != 2) {
611
		fprintf(stderr, "Usage: %s DEVICE\n", selfname);
669
		fprintf(stderr, "Usage: %s DEVICE\n", selfname);
Lines 621-629 Link Here
621
	replay_log();
679
	replay_log();
622
	load_index();
680
	load_index();
623
	while (info.ip) {
681
	while (info.ip) {
682
                t = time(NULL);
683
624
		prepare_log();
684
		prepare_log();
625
		write_log();
685
		write_log();
626
		commit_log();
686
		commit_log();
687
688
                printf("...that took %d seconds.\n", (int)(time(NULL)-t));
627
	}
689
	}
628
	printf("And now the block0...\n");
690
	printf("And now the block0...\n");
629
	bmove(super.block0, 0);
691
	bmove(super.block0, 0);

Return to bug 107635