diff --git a/configure.ac b/configure.ac index 3dd68d46..c1144a3f 100644 --- a/configure.ac +++ b/configure.ac @@ -232,8 +232,8 @@ if test "$enable_fuse_module" != "no"; then fi AM_CONDITIONAL(ENABLE_FUSE_MODULE, $compile_fuse_module) -PKG_CHECK_MODULES(NTFS_3G_MODULE, libntfs-3g >= 2009.4.4, [], - AC_MSG_ERROR([ntfs-3g.progs requires libntfs-3g version >= 2009.4.4.]) +PKG_CHECK_MODULES(NTFS_3G_MODULE, libntfs-3g >= 2010.5.22, [], + AC_MSG_ERROR([ntfs-3g.progs requires libntfs-3g version >= 2009.5.22.]) ) # Autodetect whether we can build crypto stuff or not. diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 577d451a..7a34fbb5 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -523,11 +523,15 @@ static BOOL mkntfs_parse_options(int argc, char *argv[], struct mkntfs_options * /** * mkntfs_time */ -static time_t mkntfs_time(void) +static struct timespec mkntfs_time(void) { + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 0; if (!opts.use_epoch_time) - return time(NULL); - return 0; + ts.tv_sec = time(NULL); + return ts; } /** @@ -1336,10 +1340,10 @@ static int mkntfs_attr_find(const ATTR_TYPES type, const ntfschar *name, a->name_length, ic, upcase, upcase_len)) { int rc; - rc = ntfs_names_collate(name, name_len, + rc = ntfs_names_full_collate(name, name_len, (ntfschar*)((char*)a + le16_to_cpu(a->name_offset)), - a->name_length, 1, IGNORE_CASE, + a->name_length, IGNORE_CASE, upcase, upcase_len); /* * If @name collates before a->name, there is no @@ -1352,10 +1356,10 @@ static int mkntfs_attr_find(const ATTR_TYPES type, const ntfschar *name, /* If the strings are not equal, continue search. */ if (rc) continue; - rc = ntfs_names_collate(name, name_len, + rc = ntfs_names_full_collate(name, name_len, (ntfschar*)((char*)a + le16_to_cpu(a->name_offset)), - a->name_length, 1, CASE_SENSITIVE, + a->name_length, CASE_SENSITIVE, upcase, upcase_len); if (rc == -1) { errno = ENOENT; @@ -1566,7 +1570,7 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m, } else { hdr_size = 64; if (val_len) { - mpa_size = ntfs_get_size_for_mapping_pairs(g_vol, rl, 0); + mpa_size = ntfs_get_size_for_mapping_pairs(g_vol, rl, 0, INT_MAX); if (mpa_size < 0) { err = -errno; ntfs_log_error("Failed to get size for mapping " @@ -1759,7 +1763,7 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m, } else { hdr_size = 64; if (val_len) { - mpa_size = ntfs_get_size_for_mapping_pairs(g_vol, rl, 0); + mpa_size = ntfs_get_size_for_mapping_pairs(g_vol, rl, 0, INT_MAX); if (mpa_size < 0) { err = -errno; ntfs_log_error("Failed to get size for mapping " @@ -1980,7 +1984,7 @@ static int add_attr_std_info(MFT_RECORD *m, const FILE_ATTR_FLAGS flags, sd_size = 48; - si.creation_time = utc2ntfs(mkntfs_time()); + si.creation_time = timespec2ntfs(mkntfs_time()); si.last_data_change_time = si.creation_time; si.last_mft_change_time = si.creation_time; si.last_access_time = si.creation_time; @@ -2895,7 +2899,7 @@ static int initialize_quota(MFT_RECORD *m) if (g_vol->minor_ver == 0) idx_entry_q1_data->flags |= QUOTA_FLAG_OUT_OF_DATE; idx_entry_q1_data->bytes_used = const_cpu_to_le64(0x00); - idx_entry_q1_data->change_time = utc2ntfs(mkntfs_time()); + idx_entry_q1_data->change_time = timespec2ntfs(mkntfs_time()); idx_entry_q1_data->threshold = const_cpu_to_le64((s64)-1); idx_entry_q1_data->limit = const_cpu_to_le64((s64)-1); idx_entry_q1_data->exceeded_time = const_cpu_to_le64(0x00); @@ -2922,7 +2926,7 @@ static int initialize_quota(MFT_RECORD *m) idx_entry_q2_data->version = const_cpu_to_le32(0x02); idx_entry_q2_data->flags = QUOTA_FLAG_DEFAULT_LIMITS; idx_entry_q2_data->bytes_used = const_cpu_to_le64(0x00); - idx_entry_q2_data->change_time = utc2ntfs(mkntfs_time());; + idx_entry_q2_data->change_time = timespec2ntfs(mkntfs_time());; idx_entry_q2_data->threshold = const_cpu_to_le64((s64)-1); idx_entry_q2_data->limit = const_cpu_to_le64((s64)-1); idx_entry_q2_data->exceeded_time = const_cpu_to_le64(0x00); @@ -3125,7 +3129,7 @@ static int create_hardlink_res(MFT_RECORD *m_parent, const MFT_REF ref_parent, return -errno; fn->parent_directory = ref_parent; /* FIXME: copy the creation_time from the std info */ - fn->creation_time = utc2ntfs(mkntfs_time()); + fn->creation_time = timespec2ntfs(mkntfs_time()); fn->last_data_change_time = fn->creation_time; fn->last_mft_change_time = fn->creation_time; fn->last_access_time = fn->creation_time; @@ -3241,7 +3245,7 @@ static int create_hardlink(INDEX_BLOCK *idx, const MFT_REF ref_parent, fn->parent_directory = ref_parent; /* FIXME: Is this correct? Or do we have to copy the creation_time */ /* from the std info? */ - fn->creation_time = utc2ntfs(mkntfs_time()); + fn->creation_time = timespec2ntfs(mkntfs_time()); fn->last_data_change_time = fn->creation_time; fn->last_mft_change_time = fn->creation_time; fn->last_access_time = fn->creation_time; @@ -4956,7 +4960,7 @@ static int mkntfs_redirect(struct mkntfs_options *opts2) goto done; } /* Initialize the random number generator with the current time. */ - srandom(mkntfs_time()); + srandom(mkntfs_time().tv_sec); /* Allocate and initialize ntfs_volume structure g_vol. */ g_vol = ntfs_volume_alloc(); if (!g_vol) { diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 8c6797fc..8809955d 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -716,7 +716,8 @@ static void restore_image(void) static void wipe_index_entry_timestams(INDEX_ENTRY *e) { - s64 timestamp = utc2ntfs(0); + static const struct timespec zero_time = { .tv_sec = 0, .tv_nsec = 0 }; + s64 timestamp = timespec2ntfs(zero_time); while (!(e->ie_flags & INDEX_ENTRY_END)) { @@ -806,7 +807,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr) } } - if (ntfs_rl_pwrite(vol, na->rl, 0, na->data_size, indexa) != na->data_size) + if (ntfs_rl_pwrite(vol, na->rl, 0, 0, na->data_size, indexa) != na->data_size) ntfs_log_perror("ntfs_rl_pwrite failed"); out_indexa: free(indexa); @@ -879,8 +880,9 @@ do { \ static void wipe_timestamps(ntfs_walk_clusters_ctx *image) { + static const struct timespec zero_time = { .tv_sec = 0, .tv_nsec = 0 }; ATTR_RECORD *a = image->ctx->attr; - s64 timestamp = utc2ntfs(0); + s64 timestamp = timespec2ntfs(zero_time); if (a->type == AT_FILE_NAME) WIPE_TIMESTAMPS(FILE_NAME_ATTR, a, timestamp); diff --git a/ntfsprogs/ntfsinfo.c b/ntfsprogs/ntfsinfo.c index 150f95a4..62f54829 100644 --- a/ntfsprogs/ntfsinfo.c +++ b/ntfsprogs/ntfsinfo.c @@ -319,8 +319,8 @@ static int parse_options(int argc, char *argv[]) */ static char *ntfsinfo_time_to_str(const s64 sle_ntfs_clock) { - time_t unix_clock = ntfs2utc(sle_ntfs_clock); - return ctime(&unix_clock); + struct timespec unix_clock = ntfs2timespec((ntfs_time) sle_ntfs_clock); + return ctime(&unix_clock.tv_sec); } /** diff --git a/ntfsprogs/ntfsls.c b/ntfsprogs/ntfsls.c index c42e6d33..022c933a 100644 --- a/ntfsprogs/ntfsls.c +++ b/ntfsprogs/ntfsls.c @@ -552,7 +552,7 @@ static int list_dir_entry(ntfsls_dirent * dirent, const ntfschar * name, ntfs_attr_search_ctx *ctx = NULL; FILE_NAME_ATTR *file_name_attr; ATTR_RECORD *attr; - time_t ntfs_time; + struct timespec ntfs_time; char t_buf[26]; result = -1; // Everything else is bad @@ -575,8 +575,8 @@ static int list_dir_entry(ntfsls_dirent * dirent, const ntfschar * name, if (!file_name_attr) goto release; - ntfs_time = ntfs2utc(file_name_attr->last_data_change_time); - strcpy(t_buf, ctime(&ntfs_time)); + ntfs_time = ntfs2timespec(file_name_attr->last_data_change_time); + strcpy(t_buf, ctime(&ntfs_time.tv_sec)); memmove(t_buf+16, t_buf+19, 5); t_buf[21] = '\0'; diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index e1f44238..919ede42 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -1146,7 +1146,7 @@ static void replace_attribute_runlist(ntfs_volume *vol, rl_fixup(&rl); - if ((mp_size = ntfs_get_size_for_mapping_pairs(vol, rl, 0)) == -1) + if ((mp_size = ntfs_get_size_for_mapping_pairs(vol, rl, 0, INT_MAX)) == -1) perr_exit("ntfs_get_size_for_mapping_pairs"); if (a->name_length) { @@ -1964,7 +1964,7 @@ static void truncate_bitmap_data_attr(ntfs_resize_t *resize) * attribute too, for now chkdsk will do this for us. */ - size = ntfs_rl_pwrite(vol, rl, 0, bm_bsize, resize->lcn_bitmap.bm); + size = ntfs_rl_pwrite(vol, rl, 0, 0, bm_bsize, resize->lcn_bitmap.bm); if (bm_bsize != size) { if (size == -1) perr_exit("Couldn't write $Bitmap"); diff --git a/ntfsprogs/ntfsundelete.c b/ntfsprogs/ntfsundelete.c index 1e76bc25..7ab52292 100644 --- a/ntfsprogs/ntfsundelete.c +++ b/ntfsprogs/ntfsundelete.c @@ -793,7 +793,7 @@ static FILE_NAME_ATTR* verify_parent(struct filename* name, MFT_RECORD* rec) filename_attr = (FILE_NAME_ATTR*)((char*)attr30 + le16_to_cpu(attr30->value_offset)); /* if name is older than this dir -> can't determine */ - if (ntfs2utc(filename_attr->creation_time) > name->date_c) { + if (ntfs2timespec(filename_attr->creation_time).tv_sec > name->date_c) { return NULL; } @@ -923,10 +923,10 @@ static int get_filenames(struct ufile *file, ntfs_volume* vol) name->size_data = sle64_to_cpu(attr->data_size); name->flags = attr->file_attributes; - name->date_c = ntfs2utc(attr->creation_time); - name->date_a = ntfs2utc(attr->last_data_change_time); - name->date_m = ntfs2utc(attr->last_mft_change_time); - name->date_r = ntfs2utc(attr->last_access_time); + name->date_c = ntfs2timespec(attr->creation_time).tv_sec; + name->date_a = ntfs2timespec(attr->last_data_change_time).tv_sec; + name->date_m = ntfs2timespec(attr->last_mft_change_time).tv_sec; + name->date_r = ntfs2timespec(attr->last_access_time).tv_sec; if (ntfs_ucstombs(name->uname, name->uname_len, &name->name, 0) < 0) { @@ -1101,7 +1101,7 @@ static struct ufile * read_record(ntfs_volume *vol, long long record) if (attr10) { STANDARD_INFORMATION *si; si = (STANDARD_INFORMATION *) ((char *) attr10 + le16_to_cpu(attr10->value_offset)); - file->date = ntfs2utc(si->last_data_change_time); + file->date = ntfs2timespec(si->last_data_change_time).tv_sec; } if (attr20 || !attr10)