updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / convertfs / devremap.patch
blob8271628b513290b42e0bcf5d1a3fc926cd81a2c4
1 --- convertfs/devremap.c 2002-03-01 16:16:45.000000000 +0100
2 +++ convertfs2005/devremap.c 2005-09-30 15:57:24.000000000 +0200
3 @@ -19,6 +19,7 @@
4 #include <string.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 +#include <time.h>
9 #include "convertfs.h"
11 @@ -80,6 +81,15 @@
12 static struct superblock super;
13 static struct info info;
16 +/* ULTRA UGLY HACK */
17 +struct indexpage *hack_ip;
18 +struct chunk *hack_chunk = NULL;
19 +baddr_t *hack_physp;
20 +baddr_t hack_virt;
21 +int hack_i;
24 static void
25 die (const char *format, ...)
27 @@ -346,17 +356,63 @@
28 baddr_t virt;
29 int i;
31 +/* printf("find_cross_block\n"); */
33 + if(hack_chunk != NULL)
34 + {
35 + if ((*hack_physp == bm->to) && (*hack_physp != hack_virt))
36 + {
38 + ip = hack_ip;
39 + chunk = hack_chunk;
40 + physp = hack_physp;
41 + virt = hack_virt;
42 + i = hack_i;
44 + goto VERY_UGLY_HACK;
45 + }
46 + }
48 i = bm->i + 1;
49 chunk = bm->chunk;
50 for (ip = bm->ip; ip; ip = ip->next, chunk = ip->chunk)
51 for (; chunk; chunk = next_chunk(ip, chunk), i = 0) {
53 +/* printf("chunk: %p bm->to: %lx\n", chunk, (long int)bm->to); */
55 virt = chunk->offset + i;
56 physp = &chunk->block[i];
57 - for (; i < chunk->nblocks; i++, virt++, physp++)
58 + for (; i < chunk->nblocks; i++, virt++, physp++) {
59 + VERY_UGLY_HACK:
61 if ((*physp == bm->to) && (*physp != virt)) {
63 + hack_ip = ip;
64 + hack_chunk = chunk;
65 + hack_physp = physp;
66 + hack_virt = virt;
67 + hack_i = i;
69 + hack_i++;
70 + hack_virt++;
71 + hack_physp++;
73 + if(hack_i >= chunk->nblocks)
74 + {
75 + hack_chunk = next_chunk(hack_ip, hack_chunk);
76 + hack_i = 0;
78 + if(hack_chunk)
79 + {
80 + hack_virt = hack_chunk->offset + hack_i;
81 + hack_physp = &hack_chunk->block[hack_i];
82 + }
83 + }
85 handle_cross_block(ip, bm, physp, virt);
86 return 1;
88 + }
90 return 0;
92 @@ -606,6 +662,8 @@
93 int
94 main (int argc, char *argv[])
96 + time_t t;
98 selfname = argv[0];
99 if (argc != 2) {
100 fprintf(stderr, "Usage: %s DEVICE\n", selfname);
101 @@ -621,9 +679,13 @@
102 replay_log();
103 load_index();
104 while (info.ip) {
105 + t = time(NULL);
107 prepare_log();
108 write_log();
109 commit_log();
111 + printf("...that took %d seconds.\n", (int)(time(NULL)-t));
113 printf("And now the block0...\n");
114 bmove(super.block0, 0);