From 1d898377d67701075d0b9e6d7f8541aad21599a4 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 2 May 2015 10:11:43 -0500 Subject: [PATCH] NTFS-3g capture: open inodes by inode number --- include/wimlib/ntfs_3g.h | 2 +- src/blob_table.c | 11 +++-------- src/ntfs-3g_capture.c | 18 ++++++++---------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/wimlib/ntfs_3g.h b/include/wimlib/ntfs_3g.h index 6648e5a1..7eda7c12 100644 --- a/include/wimlib/ntfs_3g.h +++ b/include/wimlib/ntfs_3g.h @@ -11,7 +11,7 @@ struct _ntfs_volume; struct _ntfs_volume; struct ntfs_location { struct _ntfs_volume *ntfs_vol; - char *path; + u64 mft_no; utf16lechar *attr_name; unsigned attr_name_nchars; unsigned attr_type; diff --git a/src/blob_table.c b/src/blob_table.c index 891c0a5a..39dc865b 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -143,13 +143,9 @@ clone_blob_descriptor(const struct blob_descriptor *old) sizeof(struct ntfs_location)); if (new->ntfs_loc == NULL) goto out_free; - new->ntfs_loc->path = STRDUP(old->ntfs_loc->path); - new->ntfs_loc->attr_name = NULL; - if (new->ntfs_loc->path == NULL) - goto out_free; - if (new->ntfs_loc->attr_name_nchars != 0) { + if (new->ntfs_loc->attr_name != NULL) { new->ntfs_loc->attr_name = - utf16le_dup(old->ntfs_loc->attr_name); + utf16le_dup(new->ntfs_loc->attr_name); if (new->ntfs_loc->attr_name == NULL) goto out_free; } @@ -191,7 +187,6 @@ blob_release_location(struct blob_descriptor *blob) #ifdef WITH_NTFS_3G case BLOB_IN_NTFS_VOLUME: if (blob->ntfs_loc) { - FREE(blob->ntfs_loc->path); FREE(blob->ntfs_loc->attr_name); FREE(blob->ntfs_loc); } @@ -453,7 +448,7 @@ cmp_blobs_by_sequential_order(const void *p1, const void *p2) return tstrcmp(blob1->file_on_disk, blob2->file_on_disk); #ifdef WITH_NTFS_3G case BLOB_IN_NTFS_VOLUME: - return tstrcmp(blob1->ntfs_loc->path, blob2->ntfs_loc->path); + return cmp_u64(blob1->ntfs_loc->mft_no, blob2->ntfs_loc->mft_no); #endif default: /* No additional sorting order defined for this resource diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index dd6cae76..75690917 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -65,8 +65,8 @@ open_ntfs_attr(ntfs_inode *ni, const struct ntfs_location *loc) loc->attr_name, loc->attr_name_nchars); if (!na) { - ERROR_WITH_ERRNO("Failed to open attribute of \"%"TS"\" in " - "NTFS volume", loc->path); + ERROR_WITH_ERRNO("Failed to open attribute of NTFS inode %"PRIu64, + loc->mft_no); } return na; } @@ -84,9 +84,10 @@ read_ntfs_attribute_prefix(const struct blob_descriptor *blob, u64 size, int ret; u8 buf[BUFFER_SIZE]; - ni = ntfs_pathname_to_inode(vol, NULL, loc->path); + ni = ntfs_inode_open(vol, loc->mft_no); if (!ni) { - ERROR_WITH_ERRNO("Can't find NTFS inode for \"%"TS"\"", loc->path); + ERROR_WITH_ERRNO("Failed to open NTFS inode %"PRIu64, + loc->mft_no); ret = WIMLIB_ERR_NTFS_3G; goto out; } @@ -102,7 +103,8 @@ read_ntfs_attribute_prefix(const struct blob_descriptor *blob, u64 size, while (bytes_remaining) { s64 to_read = min(bytes_remaining, sizeof(buf)); if (ntfs_attr_pread(na, pos, to_read, buf) != to_read) { - ERROR_WITH_ERRNO("Error reading \"%"TS"\"", loc->path); + ERROR_WITH_ERRNO("Error reading data from NTFS inode " + "%"PRIu64, loc->mft_no); ret = WIMLIB_ERR_NTFS_3G; goto out_close_ntfs_attr; } @@ -212,11 +214,7 @@ scan_ntfs_attr(struct wim_inode *inode, blob->size = data_size; blob->ntfs_loc->ntfs_vol = vol; blob->ntfs_loc->attr_type = type; - blob->ntfs_loc->path = memdup(path, path_len + 1); - if (unlikely(!blob->ntfs_loc->path)) { - ret = WIMLIB_ERR_NOMEM; - goto out_cleanup; - } + blob->ntfs_loc->mft_no = ni->mft_no; if (unlikely(name_nchars)) { blob->ntfs_loc->attr_name = utf16le_dup(stream_name); -- 2.43.0