Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv21969/linux/fs/ntfs
Modified Files:
attrib.c
Log Message:
testbed changes committed to mainstream
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/attrib.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -U2 -r1.61 -r1.62
--- attrib.c 11 Feb 2002 05:32:27 -0000 1.61
+++ attrib.c 13 Feb 2002 02:33:53 -0000 1.62
@@ -198,8 +198,10 @@
rl_mc (res, loc + disc - hole, new, left, nsize - left);
- if (res[loc+nsize-left+disc-hole].lcn == LCN_HOLE) {
+ if ((res[loc+nsize-left+disc-hole].lcn == LCN_HOLE) ||
+ (res[loc+nsize-left+disc-hole].lcn == LCN_RL_NOT_MAPPED)) {
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 =
@@ -220,5 +222,5 @@
res[loc].length = res[loc+1].vcn;
}
- res[loc].lcn = LCN_HOLE;
+ res[loc].lcn = LCN_RL_NOT_MAPPED;
}
}
@@ -262,4 +264,6 @@
left = ntfs_rl_merge (orig + loc - 1, new);
+ //printf("loc = %i, right = %i, left = %i\n", loc, right, left);
+
res = ntfs_rl_realloc (orig, osize, osize + nsize - left - right);
if (IS_ERR (res))
@@ -351,14 +355,17 @@
run_list *nrl; /* New run list. */
int di, si; /* Current index into @[ds]rl. */
- int dstart, sstart; /* First index with lcn > LCN_RL_NOT_MAPPED. */
+ int sstart; /* First index with lcn > LCN_RL_NOT_MAPPED. */
int dins; /* Index into @drl at which to insert @srl. */
int dend, send; /* Last index into @[ds]rl. */
int dfinal, sfinal; /* The last index into @[ds]rl with
lcn >= LCN_HOLE. */
+ int marker = 0;
+#if 1
ntfs_debug ("dst:\n");
ntfs_debug_dump_runlist (drl);
ntfs_debug ("src:\n");
ntfs_debug_dump_runlist (srl);
+#endif
/* Check for silly calling... */
@@ -394,17 +401,4 @@
while (srl[si].length && srl[si].lcn < (LCN)LCN_HOLE)
si++;
- /*
- * Can this happen for drl? - Not initially, but it will be possible in
- * the future, as I plan to cut down on the amount of work done by read
- * inode and one optimization would be not to bother reading in the
- * run list at all, i.e. the first read of the file will cause it to
- * be read but if that first read occurs somewhere into the file, the
- * first mapped part of the run list might well not be the first
- * extent of the attribute in which case exactly this code triggers. It
- * is a different question whether the current code would actually cope
- * with this... (AIA)
- */
- while (drl[di].length && drl[di].lcn < (LCN)LCN_HOLE)
- di++;
/* Can't have an entirely unmapped srl run_list. */
@@ -413,5 +407,4 @@
/* Record the starting points. */
sstart = si;
- dstart = di;
/*
@@ -442,4 +435,8 @@
;
+ if (srl[send].lcn == LCN_ENOENT) {
+ marker = send;
+ }
+
/* Scan to the last element with lcn >= LCN_HOLE. */
for (sfinal = send; sfinal >= 0 && srl[sfinal].lcn < LCN_HOLE; sfinal--)
@@ -454,14 +451,23 @@
int ss = sfinal - sstart + 1;
- start = ((drl[dins].lcn < LCN_HOLE) || /* End of file */
+ start = ((drl[dins].lcn < LCN_RL_NOT_MAPPED) || /* End of file */
(drl[dins].vcn == srl[sstart].vcn)); /* Start of hole */
finish = ((drl[dins].lcn >= LCN_RL_NOT_MAPPED) && /* End of file */
((drl[dins].vcn + drl[dins].length) <= /* End of hole */
(srl[send-1].vcn + srl[send-1].length)));
+ //srl[send-1].vcn));
- //ntfs_debug("dstart = %i, dfinal = %i, dend = %i\n", dstart, dfinal, dend);
- //ntfs_debug("sstart = %i, sfinal = %i, send = %i\n", sstart, sfinal, send);
- //ntfs_debug("start = %i, finish = %i\n", start, finish);
- //ntfs_debug("ds = %i, ss = %i, dins = %i\n", ds, ss, dins);
+ /* Or we'll lose an end marker */
+ if (start && finish && (drl[dins].length == 0))
+ ss++;
+ if (marker && (drl[dins].vcn + drl[dins].length > srl[send-1].vcn))
+ finish = FALSE;
+
+#if 0
+ ntfs_debug("dfinal = %i, dend = %i\n", dfinal, dend);
+ ntfs_debug("sstart = %i, sfinal = %i, send = %i\n", sstart, sfinal, send);
+ ntfs_debug("start = %i, finish = %i\n", start, finish);
+ ntfs_debug("ds = %i, ss = %i, dins = %i\n", ds, ss, dins);
+#endif
if (start)
if (finish)
@@ -474,4 +480,9 @@
else
nrl = ntfs_rl_split (drl, ds, srl + sstart, ss, dins);
+
+ if (marker) {
+ for (ds = 0; nrl[ds].lcn; ds++) ;
+ nrl = ntfs_rl_insert (nrl, ds+1, srl + marker, 1, ds-1);
+ }
}
@@ -484,6 +495,8 @@
/*ntfs_debug ("Merged run list:\n");*/
+#if 1
ntfs_debug ("res:\n");
ntfs_debug_dump_runlist (nrl);
+#endif
} else {
ntfs_error (NULL, "Merge failed, returning error code %ld.",
@@ -494,6 +507,4 @@
}
-// TODO: I AM HERE (AIA)
-
/**
* decompress_mapping_pairs - convert mapping pairs array to run list
@@ -580,5 +591,5 @@
*/
if (((rlpos + 3) * sizeof(run_list)) > rlsize) {
- rl2 = ntfs_malloc_nofs(rlsize + PAGE_SIZE);
+ rl2 = ntfs_malloc_nofs(rlsize + (int)PAGE_SIZE);
if (unlikely(!rl2)) {
ntfs_free(rl);
@@ -592,5 +603,5 @@
/* Enter the current vcn into the current run_list element. */
(rl + rlpos)->vcn = vcn;
- /*
+ /*
* Get the change in vcn, i.e. the run length in clusters.
* Doing it this way ensures that we signextend negative values.
@@ -697,8 +708,8 @@
*/
if (deltaxcn < --max_cluster) {
- ntfs_debug("More extents to follow; deltaxcn = 0x%Lx, "
- "max_cluster = 0x%Lx\n",
- (long long)deltaxcn,
- (long long)max_cluster);
+ //RAR ntfs_debug("More extents to follow; deltaxcn = 0x%Lx, "
+ //RAR "max_cluster = 0x%Lx\n",
+ //RAR (long long)deltaxcn,
+ //RAR (long long)max_cluster);
(rl + rlpos)->vcn = vcn;
vcn += (rl + rlpos)->length = max_cluster - deltaxcn;
@@ -719,6 +730,6 @@
(rl + rlpos)->vcn = vcn;
(rl + rlpos)->length = (s64)0;
- ntfs_debug("Mapping pairs array successfully decompressed.\n");
- ntfs_debug_dump_runlist(rl);
+ //RAR ntfs_debug("Mapping pairs array successfully decompressed.\n");
+ //RAR ntfs_debug_dump_runlist(rl);
/* If no existing run list was specified, we are done. */
if (!old_rl)
|