There is indeed a bug in ntfsfallocate when there is initially
no allocation at all.
In your example a possible workaround is to allocate a sparse
cluster after the touch ("truncate -s 4096 /12tb/test/6")
Of course, in a real situation you would have to insert a
test to avoid truncating valid data.
Attached is a proposed patch which you might apply to fix
the case.
Jean-Pierre
Pascal via ntfs-3g-devel wrote:
I can't seem to get ntfsfallocate to do anything:
# mount /dev/sdq1 /12tb/
# ll /12tb/test/6
ls: cannot access /12tb/test/6: No such file or directory
# touch /12tb/test/6
# umount /12tb
# ntfsinfo -v /dev/sdq1 -F test/6 > 0
# ntfsfallocate -l 537308676 /dev/sdq1 test/6
ntfsfallocate v2017.3.23 (libntfs-3g)
ntfsfallocate completed successfully. Have a nice day.
# ntfsinfo -v /dev/sdq1 -F test/6 > 1
# diff 0 1
#
Fully patched CentOS 7
ntfs-3g.x86_64 2:2017.3.23-11.el7 @epel
ntfsprogs.x86_64 2:2017.3.23-11.el7 @epel
WD Easystore 12TB External USB 3.0 Hard Drive
-Pascal
--- /shared/ntfs/ntfslow/ntfs-3g/ntfsprogs/ntfsfallocate.c.old 2020-02-06 09:23:52.243763200 +0100
+++ /shared/ntfs/ntfslow/ntfs-3g/ntfsprogs/ntfsfallocate.c.new 2020-02-06 09:23:52.300373400 +0100
@@ -775,10 +775,14 @@
/* Get and save the initial allocations */
allocated_size = na->allocated_size;
data_size = ni->data_size;
- err = ntfs_attr_map_whole_runlist(na);
+ if (na->rl)
+ err = ntfs_attr_map_whole_runlist(na);
if (!err) {
- oldrl = ntfs_save_rl(na->rl);
- if (oldrl) {
+ if (na->rl)
+ oldrl = ntfs_save_rl(na->rl);
+ else
+ oldrl = (runlist_element*)NULL;
+ if (!na->rl || oldrl) {
err = ntfs_full_allocation(na, ctx,
alloc_offs, alloc_len);
if (err) {
_______________________________________________
ntfs-3g-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel