Fixed casting data to printf format in ntfsck, ntfsmove and ntfswipe
parent
fe1a7b22a2
commit
0ec31405c6
|
@ -144,7 +144,7 @@ static int assert_u32_equal(u32 val, u32 ok, const char *name)
|
|||
{
|
||||
if (val!=ok) {
|
||||
check_failed("Assertion failed for '%lld:%s'. should be 0x%x, "
|
||||
"was 0x%x.\n", current_mft_record, name,
|
||||
"was 0x%x.\n", (long long)current_mft_record, name,
|
||||
(int)ok, (int)val);
|
||||
//errors++;
|
||||
return 1;
|
||||
|
@ -156,7 +156,8 @@ static int assert_u32_noteq(u32 val, u32 wrong, const char *name)
|
|||
{
|
||||
if (val==wrong) {
|
||||
check_failed("Assertion failed for '%lld:%s'. should not be "
|
||||
"0x%x.\n", current_mft_record, name, (int)wrong);
|
||||
"0x%x.\n", (long long)current_mft_record, name,
|
||||
(int)wrong);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -262,7 +263,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
|
|||
|
||||
if (ntfs_pread(dev, offset_to_file_record, size_of_file_record, buf) !=
|
||||
size_of_file_record) {
|
||||
check_failed("Failed to read file record at offset %lld (0x%llx).\n", offset_to_file_record, offset_to_file_record);
|
||||
check_failed("Failed to read file record at offset %lld (0x%llx).\n",
|
||||
(long long)offset_to_file_record,
|
||||
(long long)offset_to_file_record);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -279,7 +282,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
|
|||
//printf("Attr type: 0x%x.\n", attr_rec->type);
|
||||
// Check attribute record. (Only what is in the buffer)
|
||||
if (attr_rec->type==AT_END) {
|
||||
check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type), offset_to_file_record, offset_to_file_record);
|
||||
check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type),
|
||||
(long long)offset_to_file_record,
|
||||
(long long)offset_to_file_record);
|
||||
return NULL;
|
||||
}
|
||||
if ((u8*)attr_rec>buf+size_of_file_record-8) {
|
||||
|
@ -295,7 +300,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
|
|||
// Check that this attribute does not overflow the mft_record
|
||||
if ((u8*)attr_rec+length >= buf+size_of_file_record) {
|
||||
check_failed("Attribute (0x%x) is larger than FILE record at offset %lld (0x%llx).\n",
|
||||
(int)le32_to_cpu(attr_rec->type), offset_to_file_record, offset_to_file_record);
|
||||
(int)le32_to_cpu(attr_rec->type),
|
||||
(long long)offset_to_file_record,
|
||||
(long long)offset_to_file_record);
|
||||
return NULL;
|
||||
}
|
||||
// todo: what ATTRIBUTE_LIST (0x20)?
|
||||
|
@ -313,7 +320,9 @@ static runlist *load_runlist(struct ntfs_device *dev, s64 offset_to_file_record,
|
|||
attr_rec = (ATTR_RECORD*)((u8*)attr_rec+length);
|
||||
}
|
||||
// If we got here, there was an overflow.
|
||||
check_failed("file record corrupted at offset %lld (0x%llx).\n", offset_to_file_record, offset_to_file_record);
|
||||
check_failed("file record corrupted at offset %lld (0x%llx).\n",
|
||||
(long long)offset_to_file_record,
|
||||
(long long)offset_to_file_record);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -330,8 +339,8 @@ static VCN get_last_vcn(runlist *rl)
|
|||
|
||||
res = LCN_EINVAL;
|
||||
while (rl->length) {
|
||||
ntfs_log_verbose("vcn: %lld, length: %lld.\n", rl->vcn,
|
||||
rl->length);
|
||||
ntfs_log_verbose("vcn: %lld, length: %lld.\n",
|
||||
(long long)rl->vcn, (long long)rl->length);
|
||||
if (rl->vcn<0)
|
||||
res = rl->vcn;
|
||||
else
|
||||
|
@ -419,7 +428,7 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
|
|||
// Check that this attribute does not overflow the mft_record
|
||||
if ((u8*)attr_rec+length >= ((u8*)mft_rec)+buflen) {
|
||||
check_failed("Attribute (0x%x) is larger than FILE record (%lld).\n",
|
||||
(int)attr_type, current_mft_record);
|
||||
(int)attr_type, (long long)current_mft_record);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -432,7 +441,8 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
|
|||
|
||||
if (length<24) {
|
||||
check_failed("Attribute %lld:0x%x Length too short (%u).\n",
|
||||
current_mft_record, (int)attr_type, (int)length);
|
||||
(long long)current_mft_record, (int)attr_type,
|
||||
(int)length);
|
||||
goto check_attr_record_next_attr;
|
||||
}
|
||||
|
||||
|
@ -461,13 +471,13 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
|
|||
// Check flags.
|
||||
if (attr_rec->flags & ~(const_cpu_to_le16(0xc0ff))) {
|
||||
check_failed("Attribute %lld:0x%x Unknown flags (0x%x).\n",
|
||||
current_mft_record, (int)attr_type,
|
||||
(long long)current_mft_record, (int)attr_type,
|
||||
(int)le16_to_cpu(attr_rec->flags));
|
||||
}
|
||||
|
||||
if (attr_rec->non_resident>1) {
|
||||
check_failed("Attribute %lld:0x%x Unknown non-resident "
|
||||
"flag (0x%x).\n", current_mft_record,
|
||||
"flag (0x%x).\n", (long long)current_mft_record,
|
||||
(int)attr_type, (int)attr_rec->non_resident);
|
||||
goto check_attr_record_next_attr;
|
||||
}
|
||||
|
@ -487,12 +497,14 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
|
|||
// Make sure all the fields exist.
|
||||
if (length<64) {
|
||||
check_failed("Non-resident attribute %lld:0x%x too short (%u).\n",
|
||||
current_mft_record, (int)attr_type, (int)length);
|
||||
(long long)current_mft_record, (int)attr_type,
|
||||
(int)length);
|
||||
goto check_attr_record_next_attr;
|
||||
}
|
||||
if (attr_rec->compression_unit && (length<72)) {
|
||||
check_failed("Compressed attribute %lld:0x%x too short (%u).\n",
|
||||
current_mft_record, (int)attr_type, (int)length);
|
||||
(long long)current_mft_record, (int)attr_type,
|
||||
(int)length);
|
||||
goto check_attr_record_next_attr;
|
||||
}
|
||||
|
||||
|
@ -663,9 +675,11 @@ static void verify_mft_record(ntfs_volume *vol, s64 mft_num)
|
|||
|
||||
is_used = mft_bitmap_get_bit(mft_num);
|
||||
if (is_used<0) {
|
||||
ntfs_log_error("Error getting bit value for record %lld.\n", mft_num);
|
||||
ntfs_log_error("Error getting bit value for record %lld.\n",
|
||||
(long long)mft_num);
|
||||
} else if (!is_used) {
|
||||
ntfs_log_verbose("Record %lld unused. Skipping.\n", mft_num);
|
||||
ntfs_log_verbose("Record %lld unused. Skipping.\n",
|
||||
(long long)mft_num);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -673,9 +687,9 @@ static void verify_mft_record(ntfs_volume *vol, s64 mft_num)
|
|||
if (!buffer)
|
||||
goto verify_mft_record_error;
|
||||
|
||||
ntfs_log_verbose("MFT record %lld\n", mft_num);
|
||||
ntfs_log_verbose("MFT record %lld\n", (long long)mft_num);
|
||||
if (ntfs_attr_pread(vol->mft_na, mft_num*vol->mft_record_size, vol->mft_record_size, buffer) < 0) {
|
||||
ntfs_log_perror("Couldn't read $MFT record %lld", mft_num);
|
||||
ntfs_log_perror("Couldn't read $MFT record %lld", (long long)mft_num);
|
||||
goto verify_mft_record_error;
|
||||
}
|
||||
|
||||
|
@ -758,7 +772,7 @@ static void check_volume(ntfs_volume *vol)
|
|||
// For each mft record, verify that it contains a valid file record.
|
||||
nr_mft_records = vol->mft_na->initialized_size >>
|
||||
vol->mft_record_size_bits;
|
||||
ntfs_log_info("Checking %lld MFT records.\n", nr_mft_records);
|
||||
ntfs_log_info("Checking %lld MFT records.\n", (long long)nr_mft_records);
|
||||
|
||||
for (mft_num=0; mft_num < nr_mft_records; mft_num++) {
|
||||
verify_mft_record(vol, mft_num);
|
||||
|
|
|
@ -446,7 +446,8 @@ done:
|
|||
if (res) {
|
||||
for (i = 0; i < size; i++) {
|
||||
if (utils_cluster_in_use(vol, res->lcn + i)) {
|
||||
ntfs_log_info("ERROR cluster %lld in use\n", res->lcn + i);
|
||||
ntfs_log_info("ERROR cluster %lld in use\n",
|
||||
(long long)res->lcn + i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -573,7 +574,7 @@ static int data_copy(ntfs_volume *vol, runlist_element *from, runlist_element *t
|
|||
res = ntfs_pwrite(vol->dev, (to->lcn+i) * vol->cluster_size,
|
||||
vol->cluster_size, buffer);
|
||||
if (res != vol->cluster_size) {
|
||||
ntfs_log_error("!write %lld\n", res);
|
||||
ntfs_log_error("!write %lld\n", (long long)res);
|
||||
res = -1;
|
||||
break;
|
||||
}
|
||||
|
@ -686,8 +687,9 @@ static s64 move_datarun(ntfs_volume *vol, ntfs_inode *ino, ATTR_RECORD *rec,
|
|||
return -1;
|
||||
}
|
||||
|
||||
ntfs_log_info("move %lld,%lld,%lld to %lld,%lld,%lld\n", run->vcn,
|
||||
run->lcn, run->length, to->vcn, to->lcn, to->length);
|
||||
ntfs_log_info("move %lld,%lld,%lld to %lld,%lld,%lld\n",
|
||||
(long long)run->vcn, (long long)run->lcn, (long long)run->length,
|
||||
(long long)to->vcn, (long long)to->lcn, (long long)to->length);
|
||||
|
||||
need_from = ntfs_get_size_for_mapping_pairs(vol, from, 0, INT_MAX);
|
||||
ntfs_log_info("orig data run = %d bytes\n", need_from);
|
||||
|
@ -905,7 +907,7 @@ int main(int argc, char *argv[])
|
|||
"flag (%d (%s))!\n", errno, strerror(errno));
|
||||
}
|
||||
|
||||
ntfs_log_info("Relocated %lld bytes\n", count);
|
||||
ntfs_log_info("Relocated %lld bytes\n", (long long)count);
|
||||
}
|
||||
if (count >= 0)
|
||||
result = 0;
|
||||
|
|
|
@ -270,7 +270,7 @@ static void parse_options(int argc, char *argv[])
|
|||
if (*s2 || ll < 0 || (ll >= LLONG_MAX && errno == ERANGE))
|
||||
err_exit("Invalid new length: %s\n", s);
|
||||
new_len = ll;
|
||||
ntfs_log_verbose("new length = %lli\n", new_len);
|
||||
ntfs_log_verbose("new length = %lli\n", (long long)new_len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -497,7 +497,8 @@ static s64 wipe_compressed_attribute(ntfs_volume *vol, int byte,
|
|||
if (size < 0) {
|
||||
ntfs_log_verbose("Internal error\n");
|
||||
ntfs_log_error("bug or damaged fs: we want "
|
||||
"allocate buffer size %lld bytes", size);
|
||||
"allocate buffer size %lld bytes",
|
||||
(long long)size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -511,7 +512,8 @@ static s64 wipe_compressed_attribute(ntfs_volume *vol, int byte,
|
|||
if (!buf) {
|
||||
ntfs_log_verbose("Not enough memory\n");
|
||||
ntfs_log_error("Not enough memory to allocate "
|
||||
"%lld bytes", size);
|
||||
"%lld bytes",
|
||||
(long long)size);
|
||||
return -1;
|
||||
}
|
||||
memset(buf, byte, size);
|
||||
|
@ -521,7 +523,9 @@ static s64 wipe_compressed_attribute(ntfs_volume *vol, int byte,
|
|||
if (ret != size) {
|
||||
ntfs_log_verbose("Internal error\n");
|
||||
ntfs_log_error("ntfs_rl_pwrite failed, offset %llu, "
|
||||
"size %lld, vcn %lld", offset, size, rlc->vcn);
|
||||
"size %lld, vcn %lld",
|
||||
(unsigned long long)offset,
|
||||
(long long)size, (long long)rlc->vcn);
|
||||
return -1;
|
||||
}
|
||||
wiped += ret;
|
||||
|
@ -563,7 +567,8 @@ static s64 wipe_attribute(ntfs_volume *vol, int byte, enum action act,
|
|||
buf = malloc(size);
|
||||
if (!buf) {
|
||||
ntfs_log_verbose("Not enough memory\n");
|
||||
ntfs_log_error("Not enough memory to allocate %lld bytes", size);
|
||||
ntfs_log_error("Not enough memory to allocate %lld bytes",
|
||||
(long long)size);
|
||||
return -1;
|
||||
}
|
||||
memset(buf, byte, size);
|
||||
|
@ -607,7 +612,7 @@ static s64 wipe_tails(ntfs_volume *vol, int byte, enum action act)
|
|||
for (inode_num = 16; inode_num < nr_mft_records; inode_num++) {
|
||||
s64 wiped;
|
||||
|
||||
ntfs_log_verbose("Inode %lld - ", inode_num);
|
||||
ntfs_log_verbose("Inode %lld - ", (long long)inode_num);
|
||||
ni = ntfs_inode_open(vol, inode_num);
|
||||
if (!ni) {
|
||||
ntfs_log_verbose("Could not open inode\n");
|
||||
|
@ -632,7 +637,8 @@ static s64 wipe_tails(ntfs_volume *vol, int byte, enum action act)
|
|||
|
||||
if (ntfs_attr_map_whole_runlist(na)) {
|
||||
ntfs_log_verbose("Internal error\n");
|
||||
ntfs_log_error("Can't map runlist (inode %lld)\n", inode_num);
|
||||
ntfs_log_error("Can't map runlist (inode %lld)\n",
|
||||
(long long)inode_num);
|
||||
goto close_attr;
|
||||
}
|
||||
|
||||
|
@ -642,12 +648,13 @@ static s64 wipe_tails(ntfs_volume *vol, int byte, enum action act)
|
|||
wiped = wipe_attribute(vol, byte, act, na);
|
||||
|
||||
if (wiped == -1) {
|
||||
ntfs_log_error(" (inode %lld)\n", inode_num);
|
||||
ntfs_log_error(" (inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr;
|
||||
}
|
||||
|
||||
if (wiped) {
|
||||
ntfs_log_verbose("Wiped %llu bytes\n", wiped);
|
||||
ntfs_log_verbose("Wiped %llu bytes\n",
|
||||
(unsigned long long)wiped);
|
||||
total += wiped;
|
||||
} else
|
||||
ntfs_log_verbose("Nothing to wipe\n");
|
||||
|
@ -656,7 +663,8 @@ close_attr:
|
|||
close_inode:
|
||||
ntfs_inode_close(ni);
|
||||
}
|
||||
ntfs_log_quiet("wipe_tails 0x%02x, %lld bytes\n", byte, total);
|
||||
ntfs_log_quiet("wipe_tails 0x%02x, %lld bytes\n", byte,
|
||||
(long long)total);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -826,7 +834,8 @@ static s64 wipe_index_allocation(ntfs_volume *vol, int byte, enum action act
|
|||
bitmap = malloc(nab->data_size);
|
||||
if (!bitmap) {
|
||||
ntfs_log_verbose("malloc failed\n");
|
||||
ntfs_log_error("Couldn't allocate %lld bytes", nab->data_size);
|
||||
ntfs_log_error("Couldn't allocate %lld bytes",
|
||||
(long long)nab->data_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -972,7 +981,7 @@ static s64 wipe_directory(ntfs_volume *vol, int byte, enum action act)
|
|||
u32 indx_record_size;
|
||||
s64 wiped;
|
||||
|
||||
ntfs_log_verbose("Inode %lld - ", inode_num);
|
||||
ntfs_log_verbose("Inode %lld - ", (long long)inode_num);
|
||||
ni = ntfs_inode_open(vol, inode_num);
|
||||
if (!ni) {
|
||||
if (opts.verbose > 2)
|
||||
|
@ -1002,14 +1011,14 @@ static s64 wipe_directory(ntfs_volume *vol, int byte, enum action act)
|
|||
if (!NAttrNonResident(naa)) {
|
||||
ntfs_log_verbose("Resident $INDEX_ALLOCATION\n");
|
||||
ntfs_log_error("damaged fs: Resident $INDEX_ALLOCATION "
|
||||
"(inode %lld)\n", inode_num);
|
||||
"(inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_allocation;
|
||||
}
|
||||
|
||||
if (ntfs_attr_map_whole_runlist(naa)) {
|
||||
ntfs_log_verbose("Internal error\n");
|
||||
ntfs_log_error("Can't map runlist for $INDEX_ALLOCATION "
|
||||
"(inode %lld)\n", inode_num);
|
||||
"(inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_allocation;
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1027,7 @@ static s64 wipe_directory(ntfs_volume *vol, int byte, enum action act)
|
|||
ntfs_log_verbose("Couldn't open $BITMAP\n");
|
||||
ntfs_log_error("damaged fs: $INDEX_ALLOCATION is present, "
|
||||
"but we can't open $BITMAP with same "
|
||||
"name (inode %lld)\n", inode_num);
|
||||
"name (inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_allocation;
|
||||
}
|
||||
|
||||
|
@ -1027,32 +1036,34 @@ static s64 wipe_directory(ntfs_volume *vol, int byte, enum action act)
|
|||
ntfs_log_verbose("Couldn't open $INDEX_ROOT\n");
|
||||
ntfs_log_error("damaged fs: $INDEX_ALLOCATION is present, but "
|
||||
"we can't open $INDEX_ROOT with same name"
|
||||
" (inode %lld)\n", inode_num);
|
||||
" (inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_bitmap;
|
||||
}
|
||||
|
||||
if (NAttrNonResident(nar)) {
|
||||
ntfs_log_verbose("Not resident $INDEX_ROOT\n");
|
||||
ntfs_log_error("damaged fs: Not resident $INDEX_ROOT "
|
||||
"(inode %lld)\n", inode_num);
|
||||
"(inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_root;
|
||||
}
|
||||
|
||||
indx_record_size = get_indx_record_size(nar);
|
||||
if (!indx_record_size) {
|
||||
ntfs_log_error(" (inode %lld)\n", inode_num);
|
||||
ntfs_log_error(" (inode %lld)\n", (long long)inode_num);
|
||||
goto close_attr_root;
|
||||
}
|
||||
|
||||
wiped = wipe_index_allocation(vol, byte, act,
|
||||
naa, nab, indx_record_size);
|
||||
if (wiped == -1) {
|
||||
ntfs_log_error(" (inode %lld)\n", inode_num);
|
||||
ntfs_log_error(" (inode %lld)\n",
|
||||
(long long)inode_num);
|
||||
goto close_attr_root;
|
||||
}
|
||||
|
||||
if (wiped) {
|
||||
ntfs_log_verbose("Wiped %llu bytes\n", wiped);
|
||||
ntfs_log_verbose("Wiped %llu bytes\n",
|
||||
(unsigned long long)wiped);
|
||||
total += wiped;
|
||||
} else
|
||||
ntfs_log_verbose("Nothing to wipe\n");
|
||||
|
@ -1066,7 +1077,8 @@ close_inode:
|
|||
ntfs_inode_close(ni);
|
||||
}
|
||||
|
||||
ntfs_log_quiet("wipe_directory 0x%02x, %lld bytes\n", byte, total);
|
||||
ntfs_log_quiet("wipe_directory 0x%02x, %lld bytes\n", byte,
|
||||
(long long)total);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1178,8 @@ static s64 wipe_logfile(ntfs_volume *vol, int byte, enum action act
|
|||
|
||||
ntfs_attr_close(na);
|
||||
ntfs_inode_close(ni);
|
||||
ntfs_log_quiet("wipe_logfile 0x%02x, %lld bytes\n", byte, pos);
|
||||
ntfs_log_quiet("wipe_logfile 0x%02x, %lld bytes\n", byte,
|
||||
(long long)pos);
|
||||
return pos;
|
||||
|
||||
io_error_exit:
|
||||
|
@ -1256,7 +1269,8 @@ static s64 wipe_pagefile(ntfs_volume *vol, int byte, enum action act
|
|||
|
||||
ntfs_attr_close(na);
|
||||
ntfs_inode_close(ni);
|
||||
ntfs_log_quiet("wipe_pagefile 0x%02x, %lld bytes\n", byte, pos);
|
||||
ntfs_log_quiet("wipe_pagefile 0x%02x, %lld bytes\n", byte,
|
||||
(long long)pos);
|
||||
return pos;
|
||||
|
||||
io_error_exit:
|
||||
|
|
Loading…
Reference in New Issue