Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv7519/scripts
Modified Files:
compat.c rl.c
Log Message:
synchronise test program and driver
Index: compat.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/scripts/compat.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- compat.c 11 Feb 2002 03:58:46 -0000 1.5
+++ compat.c 11 Feb 2002 05:32:27 -0000 1.6
@@ -255,4 +255,6 @@
void ntfs_debug_dump_runlist(const run_list *rl)
{
+ int abbr = 1; /* abbreviate long lists */
+ int len = 0;
int i;
const char *lcn_str[5] = { "HOLE", "NOTMAP", "ENOENT", "EINVAL", "XXXX" };
@@ -262,7 +264,20 @@
return;
}
+
+ if (abbr)
+ for (len = 0; rl[len].length; len++) ;
+
printf(" VCN LCN len\n");
for (i = 0; ; i++) {
LCN lcn = (rl + i)->lcn;
+
+ if (abbr) {
+ if (len > 50) {
+ if (i == 3)
+ printf (" ...\n");
+ if ((i > 2) && (i < (len - 2)))
+ continue;
+ }
+ }
if (lcn < (LCN)0) {
Index: rl.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/scripts/rl.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -U2 -r1.11 -r1.12
--- rl.c 11 Feb 2002 04:00:41 -0000 1.11
+++ rl.c 11 Feb 2002 05:32:27 -0000 1.12
@@ -134,5 +134,4 @@
BUG_ON (!orig || !new);
- //printf ("append\n");
right = ntfs_rl_merge (new + nsize - 1, orig + loc + 1);
@@ -181,5 +180,4 @@
BUG_ON (!orig || !new);
- //printf ("insert\n");
if (loc > 0) {
left = ntfs_rl_merge (orig + loc - 1, new);
@@ -201,6 +199,4 @@
rl_mc (res, loc + disc - hole, new, left, nsize - left);
- //if (res[loc+nsize-left+disc-hole].lcn <= LCN_HOLE) {
- //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 +
@@ -230,5 +226,4 @@
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 +
@@ -264,5 +259,4 @@
BUG_ON (!orig || !new);
- //printf ("replace\n");
right = ntfs_rl_merge (new + nsize - 1, orig + loc + 1);
if (loc > 0)
@@ -311,5 +305,4 @@
BUG_ON (!orig || !new);
- //printf ("split\n");
res = ntfs_rl_realloc (orig, osize, osize + nsize + 1);
if (IS_ERR (res))
@@ -323,22 +316,35 @@
res[loc+nsize+1].length -= (new[nsize-1].vcn + new[nsize-1].length - new[0].vcn) + res[loc].length;
-#if 0
- #define hole1 (*(res + loc)) // preceding hole
- #define first (*(res + loc + 1)) // first inserted element
- #define last (*(res + nsize)) // last inserted element
- #define hole2 (*(res + nsize + 1)) // following hole
- #define newf (*(new + 0)) // first new element
- #define newl (*(new + nsize - 1)) // last new element
-
- hole1.length = first.vcn - hole1.vcn;
- hole2.vcn = last.vcn + last.length;
- hole2.length -= newl.vcn + newl.length - newf.vcn + hole1.length;
-#endif
-
return res;
}
/**
- * merge_run_lists
+ * merge_run_lists - merge two run_lists into one
+ * @drl: The original run_list.
+ * @srl: The new run_list to be merge into @drl.
+ *
+ * First we sanity check the two run_lists to make sure that they are sensible
+ * and can be merged. The @srl run_list must be either after the @drl run_list
+ * or completely within a hole in @drl.
+ *
+ * Merging of run lists is necessary in two cases:
+ * 1. When attribute lists are used and a further extent is being mapped.
+ * 2. When new clusters are allocated to fill a hole or extend a file.
+ *
+ * There are four possible ways @srl can be merged. It can be inserted at
+ * the beginning of a hole; split the hole in two; appended at the end of
+ * a hole; replace the whole hole. It can also be appended to the end of
+ * the run_list, which is just a variant of the insert case.
+ *
+ * N.B. Either, or both, of the input pointers may be freed if the function
+ * is successful. Only the returned pointer may be used.
+ *
+ * If the function fails, neither of the input run_lists may be safe.
+ *
+ * Return: Pointer, The resultant merged run_list.
+ *
+ * Errors: -ENOMEM, Not enough memory to allocate run list array.
+ * -EINVAL, Invalid parameters were passed in.
+ * -ERANGE, The run_lists overlap and cannot be merged.
*/
run_list * merge_run_lists (run_list *drl, run_list *srl)
@@ -352,8 +358,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... */
@@ -449,7 +455,5 @@
int ss = sfinal - sstart + 1;
- // FIXME: RAR This looks dodgy... drl[dins].lcn might well be LCN_ENOENT
- // at end of file. Is just the comment wrong? (AIA)
- start = ((drl[dins].lcn < LCN_HOLE) || /* End of file */
+ start = ((drl[dins].lcn < LCN_HOLE) || /* End of file */
(drl[dins].vcn == srl[sstart].vcn)); /* Start of hole */
finish = ((drl[dins].lcn >= LCN_RL_NOT_MAPPED) && /* End of file */
@@ -476,9 +480,11 @@
/* The merge was completed successfully. */
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.",
@@ -490,5 +496,32 @@
/**
- * decompress_mapping_pairs
+ * decompress_mapping_pairs - convert mapping pairs array to run list
+ * @vol: ntfs volume on which the attribute resides
+ * @attr: attribute record whose mapping pairs array to decompress
+ * @run_list: optional run list in which to insert @attr's run list
+ *
+ * Decompress the attribute @attr's mapping pairs array into a run_list and
+ * return the run list or -errno on error. If @run_list is not NULL then
+ * the mapping pairs array of @attr is decompressed and the run list inserted
+ * into the appropriate place in @run_list. If this is the case and the
+ * function returns success, the original pointer passed into @run_list is no
+ * longer valid.
+ *
+ * Check the return value for error with IS_ERR(ret_val). If this is FALSE,
+ * the function was successful, the return value is the new run list, and if
+ * an existing run list pointer was passed in, this is no longer valid.
+ * If IS_ERR(ret_val) returns true, there was an error, the return value is not
+ * a run_list pointer and the existing run list pointer if one was passed in
+ * has not been touched. In this case use PTR_ERR(ret_val) to obtain the error
+ * code. Following error codes are defined:
+ * -ENOMEM Not enough memory to allocate run list array.
+ * -EIO Corrupt run list.
+ * -EINVAL Invalid parameters were passed in.
+ * -ERANGE The two run lists overlap.
+ *
+ * FIXME: For now we take the conceptionally simplest approach of creating the
+ * new run list disregarding the already existing one and then splicing the
+ * two into one if that is possible (we check for overlap and discard the new
+ * run list if overlap present and return error).
*/
run_list *decompress_mapping_pairs(const ntfs_volume *vol,
@@ -931,5 +964,5 @@
#endif
-#if 1 || !defined (TESTF)
+#if 1 || defined (TESTF)
/**
* fragged
@@ -971,17 +1004,16 @@
return 1;
- //printf ("marker1\n");
rl1 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf1, NULL);
if (IS_ERR (rl1))
return 1;
- //printf ("marker2\n");
+ //printf ("rl1 %p\n", rl1);
rl2 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf2, NULL);
if (IS_ERR (rl2))
return 1;
- //printf ("marker3\n");
+ //printf ("rl2 %p\n", rl2);
rl3 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf3, NULL);
if (IS_ERR (rl3))
return 1;
- //printf ("marker4\n");
+ //printf ("rl3 %p\n", rl3);
//ntfs_debug_dump_runlist (rl1);
@@ -992,30 +1024,30 @@
{
case 1:
- res1 = merge_run_lists (rl1, rl2);
- res2 = merge_run_lists (res1, rl3);
+ res1 = merge_run_lists (rl1, rl2); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl3); //printf ("res2 %p\n", res2);
break;
case 2:
- res1 = merge_run_lists (rl1, rl3);
- res2 = merge_run_lists (res1, rl2);
+ res1 = merge_run_lists (rl1, rl3); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl2); //printf ("res2 %p\n", res2);
break;
case 3:
- res1 = merge_run_lists (rl2, rl1);
- res2 = merge_run_lists (res1, rl3);
+ res1 = merge_run_lists (rl2, rl1); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl3); //printf ("res2 %p\n", res2);
break;
case 4:
- res1 = merge_run_lists (rl2, rl3);
- res2 = merge_run_lists (res1, rl1);
+ res1 = merge_run_lists (rl2, rl3); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl1); //printf ("res2 %p\n", res2);
break;
case 5:
- res1 = merge_run_lists (rl3, rl1);
- res2 = merge_run_lists (res1, rl2);
+ res1 = merge_run_lists (rl3, rl1); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl2); //printf ("res2 %p\n", res2);
break;
case 6:
- res1 = merge_run_lists (rl3, rl2);
- res2 = merge_run_lists (res1, rl1);
+ res1 = merge_run_lists (rl3, rl2); //printf ("res1 %p\n", res1);
+ res2 = merge_run_lists (res1, rl1); //printf ("res2 %p\n", res2);
break;
}
- ntfs_debug_dump_runlist (res2);
+ //ntfs_debug_dump_runlist (res2);
ntfs_free (res2);
//printf ("success\n");
@@ -1024,5 +1056,5 @@
*/
#endif
- printf ("%d,%d\n", ntfs_a, ntfs_f);
+ //printf ("%d,%d\n", ntfs_a, ntfs_f);
return 0;
}
|