+/* Note: contrary to its documentation, ntfs_attr_pwrite() can return a short
+ * count in non-error cases --- specifically, when writing to a compressed
+ * attribute and the requested count exceeds the size of an NTFS "compression
+ * block". Therefore, we must continue calling ntfs_attr_pwrite() until all
+ * bytes have been written or a real error has occurred. */
+static bool
+ntfs_3g_full_pwrite(ntfs_attr *na, u64 offset, size_t size, const u8 *data)
+{
+ while (size) {
+ s64 res = ntfs_attr_pwrite(na, offset, size, data);
+ if (unlikely(res <= 0))
+ return false;
+ wimlib_assert(res <= size);
+ offset += res;
+ size -= res;
+ data += res;
+ }
+ return true;
+}
+