diff --git a/include/ntfs-3g/endians.h b/include/ntfs-3g/endians.h index 4c5d7325..0be0a8f7 100644 --- a/include/ntfs-3g/endians.h +++ b/include/ntfs-3g/endians.h @@ -316,4 +316,6 @@ #define le64_cmpz(a) (!(a)) +#define sle64_cmpz(a) (!(a)) + #endif /* defined _NTFS_ENDIANS_H */ diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 0e56b8be..44f3e367 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -742,7 +742,7 @@ int ntfs_attr_map_whole_runlist(ntfs_attr *na) /* Are we in the first extent? */ if (!next_vcn) { - if (a->lowest_vcn) { + if (!sle64_cmpz(a->lowest_vcn)) { errno = EIO; ntfs_log_perror("First extent of inode %llu " "attribute has non-zero lowest_vcn", @@ -5427,7 +5427,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m, ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x\n", (unsigned long long)na->ni->mft_no, na->type); - if (a->lowest_vcn) + if (!sle64_cmpz(a->lowest_vcn)) goto out; a->allocated_size = cpu_to_sle64(na->allocated_size); diff --git a/libntfs-3g/mft.c b/libntfs-3g/mft.c index 898f0a62..4263fbc6 100644 --- a/libntfs-3g/mft.c +++ b/libntfs-3g/mft.c @@ -760,7 +760,7 @@ static int ntfs_mft_bitmap_extend_allocation_i(ntfs_volume *vol) * We now have extended the mft bitmap allocated_size by one cluster. * Reflect this in the ntfs_attr structure and the attribute record. */ - if (a->lowest_vcn) { + if (!sle64_cmpz(a->lowest_vcn)) { /* * We are not in the first attribute extent, switch to it, but * first ensure the changes will make it to disk later. @@ -1112,7 +1112,7 @@ static int ntfs_mft_data_extend_allocation(ntfs_volume *vol) * @rl is the last (non-terminator) runlist element of mft data * attribute. */ - if (a->lowest_vcn) { + if (!sle64_cmpz(a->lowest_vcn)) { /* * We are not in the first attribute extent, switch to it, but * first ensure the changes will make it to disk later.