]> wimlib.net Git - wimlib/commitdiff
NTFS-3g capture: open inodes by inode number
authorEric Biggers <ebiggers3@gmail.com>
Sat, 2 May 2015 15:11:43 +0000 (10:11 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 2 May 2015 16:04:15 +0000 (11:04 -0500)
include/wimlib/ntfs_3g.h
src/blob_table.c
src/ntfs-3g_capture.c

index 6648e5a1cecb081e66b136df30e73e6f0351b8af..7eda7c120c81ea52883efc18ca0ca30d894a6721 100644 (file)
@@ -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;
index 891c0a5a442b266327cc6dabce5011dc9e3c93f7..39dc865bf048c6e6e7fbde2789be29f4dcc32ba1 100644 (file)
@@ -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
index dd6cae76df4756125935955ebf4808e3c5b55181..75690917aa6a4dc36fb3c133dd1472c06d69cf46 100644 (file)
@@ -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);