bugfix for ntfs_rl_pread,pwrite for pos > 0

(Logical change 1.428)
edge.strict_endians
flatcap.org!ntfs 2004-06-20 16:47:19 +00:00
parent 715d0aa024
commit b429c1fc69
1 changed files with 9 additions and 4 deletions

View File

@ -3,6 +3,7 @@
*
* Copyright (c) 2002-2004 Anton Altaparmakov
* Copyright (c) 2002 Richard Russon
* Copyright (c) 2004 Yura Pakhuchiy
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@ -1032,8 +1033,10 @@ s64 ntfs_rl_pread(const ntfs_volume *vol, const runlist_element *rl,
if (!count)
return count;
/* Seek in @rl to the run containing @pos. */
for (ofs = 0; rl->length && (ofs + rl->length <= pos); rl++)
ofs += rl->length;
for (ofs = 0; rl->length &&
(ofs + rl->length << vol->cluster_size_bits <= pos); rl++) {
ofs += rl->length * vol->cluster_size;
}
/* Offset in the run at which to begin reading. */
ofs = pos - ofs;
for (total = 0LL; count; rl++, ofs = 0) {
@ -1115,8 +1118,10 @@ s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl,
if (!count)
return count;
/* Seek in @rl to the run containing @pos. */
for (ofs = 0; rl->length && (ofs + rl->length <= pos); rl++)
ofs += rl->length;
for (ofs = 0; rl->length &&
(ofs + rl->length << vol->cluster_size_bits <= pos); rl++) {
ofs += rl->length * vol->cluster_size;
}
/* Offset in the run at which to begin writing. */
ofs = pos - ofs;
for (total = 0LL; count; rl++, ofs = 0) {