Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv24769
Modified Files:
rl.c
Log Message:
fixed up the rest of the test cases, a memory bug and other minor stuff
Index: rl.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/scripts/rl.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -U2 -r1.10 -r1.11
--- rl.c 10 Feb 2002 22:40:09 -0000 1.10
+++ rl.c 11 Feb 2002 04:00:41 -0000 1.11
@@ -1,10 +1,18 @@
#include "compat.c"
-#define CONTIG 1
-#define MULTI 0
-
/**
* config
*/
+
+#ifndef CONTIG
+#define CONTIG 1
+#endif
+#ifndef MULTI
+#define MULTI 1
+#endif
+#ifndef TEST
+#define TEST 1
+#endif
+
#if CONTIG
int fudge = 0;
@@ -59,8 +67,8 @@
run_list *nrl;
- old = PAGE_ALIGN (old * sizeof (run_list));
- new = PAGE_ALIGN (new * sizeof (run_list));
if (old == new)
return orig;
+ old = PAGE_ALIGN (old * sizeof (run_list));
+ new = PAGE_ALIGN (new * sizeof (run_list));
nrl = ntfs_malloc_nofs (new);
@@ -138,4 +146,9 @@
res[loc].length = res[loc+1].vcn - res[loc].vcn;
+ if (!right) {
+ if (res[loc+nsize+1].lcn == LCN_ENOENT)
+ res[loc+nsize+1].vcn = res[loc+nsize].vcn + res[loc+nsize].length;
+ }
+
return res;
}
@@ -189,10 +202,13 @@
//if (res[loc+nsize-left+disc-hole].lcn <= LCN_HOLE) {
- if (1) {
+ //printf ("%d %lld res[loc+nsize-left].lcn\n", loc+nsize-left, res[loc+nsize-left].lcn);
+ if (res[loc+nsize-left+disc-hole].lcn == LCN_HOLE) {
+ res[loc+nsize-left+disc-hole].length -= (new[nsize-1].vcn +
+ new[nsize-1].length - new[0].vcn);
+ }
+ if (res[loc+nsize-left+disc-hole].lcn <= LCN_HOLE) {
res[loc+nsize-left+disc-hole].vcn =
res[loc+nsize-left+disc-hole-1].vcn +
res[loc+nsize-left+disc-hole-1].length;
- res[loc+nsize-left+disc-hole].length -= (new[nsize-1].vcn +
- new[nsize-1].length - new[0].vcn);
}
@@ -213,4 +229,11 @@
}
+ if (disc) {
+ //printf ("%llu res[loc+nsize-left+disc].lcn\n", res[loc+nsize-left+disc].lcn);
+ if (res[loc+nsize-left+disc].lcn == LCN_ENOENT)
+ res[loc+nsize-left+disc].vcn = res[loc+nsize-left+disc-1].vcn +
+ res[loc+nsize-left+disc-1].length;
+ }
+
return res;
}
@@ -256,4 +279,10 @@
rl_mc (res, loc, new, left, nsize - left);
+ if (!right) {
+ if (res[loc+nsize-left].lcn == LCN_ENOENT)
+ res[loc+nsize-left].vcn = res[loc+nsize-left-1].vcn +
+ res[loc+nsize-left-1].length;
+ }
+
return res;
}
@@ -323,8 +352,8 @@
lcn >= LCN_HOLE. */
- ntfs_debug ("dst:\n");
- ntfs_debug_dump_runlist (drl);
- ntfs_debug ("src:\n");
- ntfs_debug_dump_runlist (srl);
+ //ntfs_debug ("dst:\n");
+ //ntfs_debug_dump_runlist (drl);
+ //ntfs_debug ("src:\n");
+ //ntfs_debug_dump_runlist (srl);
/* Check for silly calling... */
@@ -371,5 +400,4 @@
* with this... (AIA)
*/
- // FIXME RAR
while (drl[di].length && drl[di].lcn < (LCN)LCN_HOLE)
di++;
@@ -447,14 +475,10 @@
if (likely (!IS_ERR (nrl))) {
/* The merge was completed successfully. */
- if (nrl != drl)
- ntfs_free (drl);
finished:
- if (nrl != srl)
- ntfs_free (srl);
/*ntfs_debug ("Done.\n");*/
/*ntfs_debug ("Merged run list:\n");*/
- ntfs_debug ("res:\n");
- ntfs_debug_dump_runlist (nrl);
+ //ntfs_debug ("res:\n");
+ //ntfs_debug_dump_runlist (nrl);
} else {
ntfs_error (NULL, "Merge failed, returning error code %ld.",
@@ -739,5 +763,5 @@
int main (int argc, char *argv[])
{
-#if 0
+#if 0 || defined(TESTRL)
/**
* files
@@ -751,6 +775,5 @@
{ 300, 1300, 100 }, /* DATA */
{ 400, -1, 100 }, /* HOLE */
- { 0, -2, 0 }, /* END */
- { 0, -3, 0 } /* NOENT */
+ { 500, -3, 0 } /* NOENT */
};
@@ -759,6 +782,5 @@
{ 0, 1000, 100 }, /* DATA */
{ 100, -1, 100 }, /* HOLE */
- { 0, -2, 0 }, /* END */
- { 0, -3, 0 } /* NOENT */
+ { 200, -3, 0 } /* NOENT */
};
@@ -766,11 +788,9 @@
/* VCN, LCN, len */
{ 0, 1000, 100 }, /* DATA */
- { 0, -2, 0 }, /* END */
- { 0, -3, 0 } /* NOENT */
+ { 100, -3, 0 } /* NOENT */
};
run_list file4[] = {
/* VCN, LCN, len */
- { 0, -2, 0 }, /* END */
{ 0, -3, 0 } /* NOENT */
};
@@ -781,21 +801,20 @@
* tests
*/
-#if !MULTI
+#if MULTI
#define RL_SRC(X,Y,Z) \
run_list s##X[] = \
{ \
- { Y, fudge + Y + 1000, Z }, \
- { 0, LCN_RL_NOT_MAPPED, 0 } \
+ { Y, fudge + Y + 1000, Z/4 }, \
+ { Y+(1*Z/4), fudge + Y + 1000 + (1*Z/4), Z/4 }, \
+ { Y+(2*Z/4), fudge + Y + 1000 + (2*Z/4), Z/4 }, \
+ { Y+(3*Z/4), fudge + Y + 1000 + (3*Z/4), Z/4 }, \
+ { Y+Z, LCN_RL_NOT_MAPPED, 0 } \
};
-
#else
#define RL_SRC(X,Y,Z) \
run_list s##X[] = \
{ \
- { Y, fudge + Y + 1000, Z/4 }, \
- { Y+(1*Z/4), fudge + Y + 1000 + (1*Z/4), Z/4 }, \
- { Y+(2*Z/4), fudge + Y + 1000 + (2*Z/4), Z/4 }, \
- { Y+(3*Z/4), fudge + Y + 1000 + (3*Z/4), Z/4 }, \
- { 0, LCN_RL_NOT_MAPPED, 0 } \
+ { Y, fudge + Y + 1000, Z }, \
+ { Y+Z, LCN_RL_NOT_MAPPED, 0 } \
};
#endif
@@ -850,26 +869,7 @@
* run
*/
-#if 1
+#if 0
- TEST_RL(1,1)
- TEST_RL(2,1)
- TEST_RL(3,1)
- TEST_RL(4,1)
- TEST_RL(5,1)
- TEST_RL(6,1)
- TEST_RL(7,1)
- TEST_RL(8,1)
- TEST_RL(9,1)
- TEST_RL(10,1)
- TEST_RL(11,1)
- TEST_RL(12,1)
- TEST_RL(13,2)
- TEST_RL(14,2)
TEST_RL(15,2)
- TEST_RL(16,2)
- TEST_RL(17,3)
- TEST_RL(18,3)
- TEST_RL(19,4)
- TEST_RL(20,4)
#else
@@ -924,4 +924,6 @@
if (IS_ERR(jim))
return 1;
+
+ ntfs_free (jim);
/*
}
@@ -929,5 +931,5 @@
#endif
-#if 1
+#if 1 || !defined (TESTF)
/**
* fragged
@@ -944,4 +946,6 @@
run_list *rl2 = NULL;
run_list *rl3 = NULL;
+ run_list *res1 = NULL;
+ run_list *res2 = NULL;
ntfs_volume vol;
@@ -967,20 +971,58 @@
return 1;
+ //printf ("marker1\n");
rl1 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf1, NULL);
if (IS_ERR (rl1))
return 1;
- rl2 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf2, rl1);
+ //printf ("marker2\n");
+ rl2 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf2, NULL);
if (IS_ERR (rl2))
return 1;
- rl3 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf3, rl2);
+ //printf ("marker3\n");
+ rl3 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf3, NULL);
if (IS_ERR (rl3))
return 1;
+ //printf ("marker4\n");
+
+ //ntfs_debug_dump_runlist (rl1);
+ //ntfs_debug_dump_runlist (rl2);
+ //ntfs_debug_dump_runlist (rl3);
+
+ switch (TEST)
+ {
+ case 1:
+ res1 = merge_run_lists (rl1, rl2);
+ res2 = merge_run_lists (res1, rl3);
+ break;
+ case 2:
+ res1 = merge_run_lists (rl1, rl3);
+ res2 = merge_run_lists (res1, rl2);
+ break;
+ case 3:
+ res1 = merge_run_lists (rl2, rl1);
+ res2 = merge_run_lists (res1, rl3);
+ break;
+ case 4:
+ res1 = merge_run_lists (rl2, rl3);
+ res2 = merge_run_lists (res1, rl1);
+ break;
+ case 5:
+ res1 = merge_run_lists (rl3, rl1);
+ res2 = merge_run_lists (res1, rl2);
+ break;
+ case 6:
+ res1 = merge_run_lists (rl3, rl2);
+ res2 = merge_run_lists (res1, rl1);
+ break;
+ }
- printf ("success\n");
+ ntfs_debug_dump_runlist (res2);
+ ntfs_free (res2);
+ //printf ("success\n");
/*
}
*/
#endif
- //printf ("%d,%d\n", ntfs_a, ntfs_f);
+ printf ("%d,%d\n", ntfs_a, ntfs_f);
return 0;
}
|