4 * Capture a WIM image directly from an NTFS volume using libntfs-3g. We capture
5 * everything we can, including security data and alternate data streams.
9 * Copyright (C) 2012-2017 Eric Biggers
11 * This file is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU Lesser General Public License as published by the Free
13 * Software Foundation; either version 3 of the License, or (at your option) any
16 * This file is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this file; if not, see http://www.gnu.org/licenses/.
33 #include <ntfs-3g/attrib.h>
34 #include <ntfs-3g/compat.h> /* for ENODATA, if needed */
35 #include <ntfs-3g/object_id.h>
36 #include <ntfs-3g/reparse.h>
37 #include <ntfs-3g/security.h>
38 #include <ntfs-3g/volume.h>
40 #include "wimlib/alloca.h"
41 #include "wimlib/assert.h"
42 #include "wimlib/blob_table.h"
43 #include "wimlib/dentry.h"
44 #include "wimlib/encoding.h"
45 #include "wimlib/endianness.h"
46 #include "wimlib/error.h"
47 #include "wimlib/ntfs_3g.h"
48 #include "wimlib/object_id.h"
49 #include "wimlib/paths.h"
50 #include "wimlib/reparse.h"
51 #include "wimlib/scan.h"
52 #include "wimlib/security.h"
54 /* NTFS-3G 2013 renamed MS_RDONLY to NTFS_MNT_RDONLY. We can't check for the
55 * existence of NTFS_MNT_RDONLY at compilation time because it's an enum. We
56 * also can't check for MS_RDONLY being missing because it's also a system
57 * constant. So check if the NTFS-3G specific MS_IGNORE_HIBERFILE is defined;
58 * if yes, then we need to use the old MS_RDONLY. */
59 #ifdef MS_IGNORE_HIBERFILE
60 # define NTFS_MNT_RDONLY MS_RDONLY
63 /* A reference-counted NTFS volume than is automatically unmounted when the
64 * reference count reaches 0 */
65 struct ntfs_volume_wrapper {
71 /* Description of where data is located in an NTFS volume */
72 struct ntfs_location {
73 struct ntfs_volume_wrapper *volume;
81 static struct ntfs_volume_wrapper *
82 get_ntfs_volume(struct ntfs_volume_wrapper *volume)
89 put_ntfs_volume(struct ntfs_volume_wrapper *volume)
91 if (--volume->refcnt == 0) {
92 ntfs_umount(volume->vol, FALSE);
97 static inline const ntfschar *
98 attr_record_name(const ATTR_RECORD *record)
100 return (const ntfschar *)
101 ((const u8 *)record + le16_to_cpu(record->name_offset));
105 open_ntfs_attr(ntfs_inode *ni, const struct ntfs_location *loc)
109 na = ntfs_attr_open(ni, loc->attr_type, loc->attr_name,
110 loc->attr_name_nchars);
112 ERROR_WITH_ERRNO("Failed to open attribute of NTFS inode %"PRIu64,
119 read_ntfs_attribute_prefix(const struct blob_descriptor *blob, u64 size,
120 const struct consume_chunk_callback *cb)
122 const struct ntfs_location *loc = blob->ntfs_loc;
123 ntfs_volume *vol = loc->volume->vol;
131 ni = ntfs_inode_open(vol, loc->mft_no);
133 ERROR_WITH_ERRNO("Failed to open NTFS inode %"PRIu64,
135 ret = WIMLIB_ERR_NTFS_3G;
139 na = open_ntfs_attr(ni, loc);
141 ret = WIMLIB_ERR_NTFS_3G;
142 goto out_close_ntfs_inode;
145 pos = (loc->attr_type == AT_REPARSE_POINT) ? REPARSE_DATA_OFFSET : 0;
146 bytes_remaining = size;
147 while (bytes_remaining) {
148 s64 to_read = min(bytes_remaining, sizeof(buf));
149 if (ntfs_attr_pread(na, pos, to_read, buf) != to_read) {
150 ERROR_WITH_ERRNO("Error reading data from NTFS inode "
151 "%"PRIu64, loc->mft_no);
152 ret = WIMLIB_ERR_NTFS_3G;
153 goto out_close_ntfs_attr;
156 bytes_remaining -= to_read;
157 ret = consume_chunk(cb, buf, to_read);
159 goto out_close_ntfs_attr;
164 out_close_ntfs_inode:
165 ntfs_inode_close(ni);
171 free_ntfs_location(struct ntfs_location *loc)
173 put_ntfs_volume(loc->volume);
174 if (loc->attr_name != AT_UNNAMED)
175 FREE(loc->attr_name);
179 struct ntfs_location *
180 clone_ntfs_location(const struct ntfs_location *loc)
182 struct ntfs_location *new = memdup(loc, sizeof(*loc));
185 if (loc->attr_name != AT_UNNAMED) {
186 new->attr_name = utf16le_dup(loc->attr_name);
190 new->volume = get_ntfs_volume(loc->volume);
200 cmp_ntfs_locations(const struct ntfs_location *loc1,
201 const struct ntfs_location *loc2)
203 return cmp_u64(loc1->sort_key, loc2->sort_key);
206 /* Read rptag and rpreserved from the NTFS inode and save them in the WIM inode.
209 read_reparse_header(ntfs_inode *ni, struct wim_inode *inode)
219 na = ntfs_attr_open(ni, AT_REPARSE_POINT, AT_UNNAMED, 0);
221 return WIMLIB_ERR_NTFS_3G;
223 res = ntfs_attr_pread(na, 0, sizeof(hdr), &hdr);
227 if (res != sizeof(hdr))
228 return WIMLIB_ERR_NTFS_3G;
230 inode->i_reparse_tag = le32_to_cpu(hdr.rptag);
231 inode->i_rp_reserved = le16_to_cpu(hdr.rpreserved);
237 warn_special_reparse_points(const struct wim_inode *inode,
238 const struct scan_params *params,
239 struct ntfs_volume_wrapper *volume)
241 if (inode->i_reparse_tag == WIM_IO_REPARSE_TAG_DEDUP &&
242 (params->add_flags & WIMLIB_ADD_FLAG_WINCONFIG) &&
243 !volume->dedup_warned)
246 "Filesystem includes files deduplicated with Windows'\n"
247 " Data Deduplication feature, which to properly restore\n"
248 " would require that the chunk store in \"System Volume Information\"\n"
249 " be included in the WIM image. By default \"System Volume Information\"\n"
250 " is excluded, so you may want to use a custom capture configuration\n"
251 " file which includes it.");
252 volume->dedup_warned = true;
257 attr_type_to_wimlib_stream_type(ATTR_TYPES type)
261 return STREAM_TYPE_DATA;
262 case AT_REPARSE_POINT:
263 return STREAM_TYPE_REPARSE_POINT;
266 return STREAM_TYPE_UNKNOWN;
270 /* When sorting blobs located in NTFS volumes for sequential reading, we sort
271 * first by starting LCN of the attribute if available, otherwise no sort order
272 * is defined. This usually results in better sequential access to the volume.
275 set_attr_sort_key(ntfs_inode *ni, struct ntfs_location *loc)
280 na = open_ntfs_attr(ni, loc);
282 return WIMLIB_ERR_NTFS_3G;
284 rl = ntfs_attr_find_vcn(na, 0);
285 if (rl && rl->lcn != LCN_HOLE)
286 loc->sort_key = rl->lcn;
295 * Add a new stream to the specified inode, with duplicate checking.
297 * This works around a problem where NTFS-3G can list multiple unnamed data
298 * streams for a single file. In this case we can only keep one. We'll prefer
299 * one that is nonempty.
302 add_stream(struct wim_inode *inode, const char *path, int stream_type,
303 const utf16lechar *stream_name, struct blob_descriptor **blob_p,
304 struct list_head *unhashed_blobs)
306 struct blob_descriptor *blob = *blob_p;
307 struct wim_inode_stream *strm;
309 strm = inode_get_stream(inode, stream_type, stream_name);
310 if (unlikely(strm)) {
311 /* Stream already existed. */
314 if (stream_blob_resolved(strm)) {
315 WARNING("\"%s\" has multiple nonempty streams "
316 "with the same type and name! Only the first "
317 "will be saved.", path);
320 inode_replace_stream_blob(inode, strm, blob, NULL);
322 strm = inode_add_stream(inode, stream_type, stream_name, blob);
324 return WIMLIB_ERR_NOMEM;
326 prepare_unhashed_blob(blob, inode, strm->stream_id, unhashed_blobs);
332 /* Save information about an NTFS attribute (stream) to a WIM inode. */
334 scan_ntfs_attr(struct wim_inode *inode,
337 struct list_head *unhashed_blobs,
338 struct ntfs_volume_wrapper *volume,
340 const ATTR_RECORD *record)
342 u64 data_size = ntfs_get_attribute_value_length(record);
343 const u32 name_nchars = record->name_length;
344 struct blob_descriptor *blob = NULL;
345 utf16lechar *stream_name = (utf16lechar *)NO_STREAM_NAME;
348 if (unlikely(name_nchars)) {
350 stream_name = utf16le_dupz(attr_record_name(record),
351 name_nchars * sizeof(ntfschar));
353 ret = WIMLIB_ERR_NOMEM;
358 if (unlikely(type == AT_REPARSE_POINT)) {
359 if (data_size < REPARSE_DATA_OFFSET) {
360 ERROR("Reparse point attribute of \"%s\" "
361 "is too short!", path);
362 ret = WIMLIB_ERR_INVALID_REPARSE_DATA;
365 data_size -= REPARSE_DATA_OFFSET;
367 ret = read_reparse_header(ni, inode);
369 ERROR_WITH_ERRNO("Error reading reparse point header "
375 /* If the stream is non-empty, set up a blob descriptor for it. */
376 if (data_size != 0) {
377 blob = new_blob_descriptor();
378 if (unlikely(!blob)) {
379 ret = WIMLIB_ERR_NOMEM;
383 blob->ntfs_loc = MALLOC(sizeof(struct ntfs_location));
384 if (unlikely(!blob->ntfs_loc)) {
385 ret = WIMLIB_ERR_NOMEM;
389 blob->blob_location = BLOB_IN_NTFS_VOLUME;
390 blob->size = data_size;
391 blob->ntfs_loc->volume = get_ntfs_volume(volume);
392 blob->ntfs_loc->mft_no = ni->mft_no;
393 blob->ntfs_loc->attr_type = type;
395 if (unlikely(name_nchars)) {
396 blob->ntfs_loc->attr_name_nchars = name_nchars;
397 blob->ntfs_loc->attr_name = utf16le_dup(stream_name);
398 if (!blob->ntfs_loc->attr_name) {
399 ret = WIMLIB_ERR_NOMEM;
403 blob->ntfs_loc->attr_name_nchars = 0;
404 blob->ntfs_loc->attr_name = AT_UNNAMED;
407 ret = set_attr_sort_key(ni, blob->ntfs_loc);
412 ret = add_stream(inode, path, attr_type_to_wimlib_stream_type(type),
413 stream_name, &blob, unhashed_blobs);
415 free_blob_descriptor(blob);
416 if (stream_name != NO_STREAM_NAME)
421 /* Scan attributes of the specified type from a file in the NTFS volume */
423 scan_ntfs_attrs_with_type(struct wim_inode *inode,
426 struct list_head *unhashed_blobs,
427 struct ntfs_volume_wrapper *volume,
430 ntfs_attr_search_ctx *actx;
433 actx = ntfs_attr_get_search_ctx(ni, NULL);
435 ERROR_WITH_ERRNO("Failed to get NTFS attribute search "
436 "context for \"%s\"", path);
437 return WIMLIB_ERR_NTFS_3G;
440 while (!ntfs_attr_lookup(type, NULL, 0,
441 CASE_SENSITIVE, 0, NULL, 0, actx))
443 ret = scan_ntfs_attr(inode,
453 if (errno != ENOENT) {
454 ERROR_WITH_ERRNO("Error listing NTFS attributes of \"%s\"", path);
455 ret = WIMLIB_ERR_NTFS_3G;
460 ntfs_attr_put_search_ctx(actx);
464 static noinline_for_stack int
465 load_object_id(ntfs_inode *ni, struct wim_inode *inode)
470 len = ntfs_get_ntfs_object_id(ni, (char *)&attr, sizeof(attr));
471 if (likely(len == -ENODATA || len == 0))
474 return WIMLIB_ERR_NTFS_3G;
475 if (!inode_set_object_id(inode, &attr, len))
476 return WIMLIB_ERR_NOMEM;
480 /* Load the security descriptor of an NTFS inode into the corresponding WIM
481 * inode and the WIM image's security descriptor set. */
482 static noinline_for_stack int
483 get_security_descriptor(ntfs_inode *ni, struct wim_inode *inode,
484 ntfs_volume *vol, struct wim_sd_set *sd_set)
486 struct SECURITY_CONTEXT scx = {.vol = vol};
489 size_t avail_size = sizeof(_buf);
493 ret = ntfs_get_ntfs_acl(&scx, ni, buf, avail_size);
494 if (unlikely(ret < 0)) {
495 ret = WIMLIB_ERR_NTFS_3G;
499 if (unlikely(ret > avail_size)) {
500 if (unlikely(buf != _buf))
504 ret = WIMLIB_ERR_NOMEM;
511 if (likely(ret > 0)) {
512 inode->i_security_id = sd_set_add_sd(sd_set, buf, ret);
513 if (unlikely(inode->i_security_id < 0)) {
514 ret = WIMLIB_ERR_NOMEM;
521 if (unlikely(buf != _buf))
526 /* Binary tree that maps NTFS inode numbers to DOS names */
527 struct dos_name_map {
528 struct avl_tree_node *root;
531 struct dos_name_node {
532 struct avl_tree_node index_node;
538 #define DOS_NAME_NODE(avl_node) \
539 avl_tree_entry(avl_node, struct dos_name_node, index_node)
542 _avl_cmp_by_ntfs_ino(const struct avl_tree_node *n1,
543 const struct avl_tree_node *n2)
545 return cmp_u64(DOS_NAME_NODE(n1)->ntfs_ino,
546 DOS_NAME_NODE(n2)->ntfs_ino);
549 /* Inserts a new DOS name into the map */
551 insert_dos_name(struct dos_name_map *map, const ntfschar *dos_name,
552 size_t name_nbytes, u64 ntfs_ino)
554 struct dos_name_node *new_node;
556 new_node = MALLOC(sizeof(struct dos_name_node));
558 return WIMLIB_ERR_NOMEM;
560 /* DOS names are supposed to be 12 characters max (that's 24 bytes,
561 * assuming 2-byte ntfs characters) */
562 wimlib_assert(name_nbytes <= sizeof(new_node->dos_name));
564 /* Initialize the DOS name, DOS name length, and NTFS inode number of
565 * the search tree node */
566 memcpy(new_node->dos_name, dos_name, name_nbytes);
567 new_node->name_nbytes = name_nbytes;
568 new_node->ntfs_ino = ntfs_ino;
570 /* Insert the search tree node */
571 if (avl_tree_insert(&map->root, &new_node->index_node,
572 _avl_cmp_by_ntfs_ino))
574 /* This should be impossible since an NTFS inode cannot have
575 * multiple DOS names, and we only should get each DOS name
576 * entry once from the ntfs_readdir() calls. */
577 WARNING("NTFS inode %"PRIu64" has multiple DOS names", ntfs_ino);
583 /* Returns a structure that contains the DOS name and its length for an NTFS
584 * inode, or NULL if the inode has no DOS name. */
585 static struct dos_name_node *
586 lookup_dos_name(const struct dos_name_map *map, u64 ntfs_ino)
588 struct dos_name_node dummy;
589 struct avl_tree_node *res;
591 dummy.ntfs_ino = ntfs_ino;
593 res = avl_tree_lookup_node(map->root, &dummy.index_node,
594 _avl_cmp_by_ntfs_ino);
597 return DOS_NAME_NODE(res);
601 set_dentry_dos_name(struct wim_dentry *dentry, const struct dos_name_map *map)
603 const struct dos_name_node *node;
605 if (dentry->d_is_win32_name) {
606 node = lookup_dos_name(map, dentry->d_inode->i_ino);
608 dentry->d_short_name = utf16le_dupz(node->dos_name,
610 if (!dentry->d_short_name)
611 return WIMLIB_ERR_NOMEM;
612 dentry->d_short_name_nbytes = node->name_nbytes;
614 WARNING("NTFS inode %"PRIu64" has Win32 name with no "
615 "corresponding DOS name",
616 dentry->d_inode->i_ino);
623 destroy_dos_name_map(struct dos_name_map *map)
625 struct dos_name_node *node;
626 avl_tree_for_each_in_postorder(node, map->root,
627 struct dos_name_node, index_node)
632 struct wim_dentry *parent;
633 struct dos_name_map dos_name_map;
634 struct ntfs_volume_wrapper *volume;
635 struct scan_params *params;
640 ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_p,
642 const char *filename,
644 struct ntfs_volume_wrapper *volume,
645 struct scan_params *params);
648 filldir(void *_ctx, const ntfschar *name, const int name_nchars,
649 const int name_type, const s64 pos, const MFT_REF mref,
650 const unsigned dt_type)
652 struct readdir_ctx *ctx = _ctx;
653 struct scan_params *params = ctx->params;
654 const size_t name_nbytes = name_nchars * sizeof(ntfschar);
656 size_t mbs_name_nbytes;
657 size_t orig_path_nchars;
658 struct wim_dentry *child;
661 if (name_type & FILE_NAME_DOS) {
662 /* If this is the entry for a DOS name, store it for later. */
663 ret = insert_dos_name(&ctx->dos_name_map, name,
664 name_nbytes, MREF(mref));
666 /* Return now if an error occurred or if this is just a DOS name
667 * and not a Win32+DOS name. */
668 if (ret != 0 || name_type == FILE_NAME_DOS)
672 ret = utf16le_to_tstr(name, name_nbytes, &mbs_name, &mbs_name_nbytes);
676 if (should_ignore_filename(mbs_name, mbs_name_nbytes))
677 goto out_free_mbs_name;
679 ret = WIMLIB_ERR_NOMEM;
680 if (!pathbuf_append_name(params, mbs_name, mbs_name_nbytes,
682 goto out_free_mbs_name;
685 ret = ntfs_3g_build_dentry_tree_recursive(&child, mref, mbs_name,
686 name_type, ctx->volume,
688 pathbuf_truncate(params, orig_path_nchars);
689 attach_scanned_tree(ctx->parent, child, params->blob_table);
698 ntfs_3g_recurse_directory(ntfs_inode *ni, struct wim_dentry *parent,
699 struct ntfs_volume_wrapper *volume,
700 struct scan_params *params)
704 struct readdir_ctx ctx = {
706 .dos_name_map = { .root = NULL },
711 ret = ntfs_readdir(ni, &pos, &ctx, filldir);
717 /* error from ntfs_readdir() itself */
718 ERROR_WITH_ERRNO("Error reading directory \"%s\"",
720 ret = WIMLIB_ERR_NTFS_3G;
723 struct wim_dentry *child;
726 for_dentry_child(child, parent) {
727 ret = set_dentry_dos_name(child, &ctx.dos_name_map);
732 destroy_dos_name_map(&ctx.dos_name_map);
737 ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_ret,
739 const char *filename,
741 struct ntfs_volume_wrapper *volume,
742 struct scan_params *params)
744 const char *path = params->cur_path;
747 struct wim_dentry *root = NULL;
748 struct wim_inode *inode = NULL;
749 ntfs_inode *ni = NULL;
751 ret = try_exclude(params);
752 if (unlikely(ret < 0)) /* Excluded? */
754 if (unlikely(ret > 0)) /* Error? */
757 ni = ntfs_inode_open(volume->vol, mref);
759 ERROR_WITH_ERRNO("Failed to open NTFS file \"%s\"", path);
760 ret = WIMLIB_ERR_NTFS_3G;
764 /* Get file attributes */
765 ret = ntfs_get_ntfs_attrib(ni, (char*)&attributes, sizeof(attributes));
766 if (ret != sizeof(attributes)) {
767 ERROR_WITH_ERRNO("Failed to get NTFS attributes from \"%s\"", path);
768 ret = WIMLIB_ERR_NTFS_3G;
772 if (unlikely(attributes & FILE_ATTRIBUTE_ENCRYPTED)) {
773 if (params->add_flags & WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE)
775 ERROR("Can't archive \"%s\" because NTFS-3G capture mode "
776 "does not support encrypted files and directories", path);
777 ret = WIMLIB_ERR_UNSUPPORTED_FILE;
780 ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_UNSUPPORTED, NULL);
784 /* Create a WIM dentry with an associated inode, which may be shared */
785 ret = inode_table_new_dentry(params->inode_table, filename,
786 ni->mft_no, 0, false, &root);
790 if (name_type & FILE_NAME_WIN32) /* Win32 or Win32+DOS name (rather than POSIX) */
791 root->d_is_win32_name = 1;
793 inode = root->d_inode;
795 if (inode->i_nlink > 1) {
796 /* Shared inode; nothing more to do */
800 inode->i_creation_time = le64_to_cpu(ni->creation_time);
801 inode->i_last_write_time = le64_to_cpu(ni->last_data_change_time);
802 inode->i_last_access_time = le64_to_cpu(ni->last_access_time);
803 inode->i_attributes = attributes;
805 if (attributes & FILE_ATTRIBUTE_REPARSE_POINT) {
806 /* Scan the reparse point stream. */
807 ret = scan_ntfs_attrs_with_type(inode, ni, path,
808 params->unhashed_blobs,
809 volume, AT_REPARSE_POINT);
813 warn_special_reparse_points(inode, params, volume);
816 /* Load the object ID. */
817 ret = load_object_id(ni, inode);
819 ERROR_WITH_ERRNO("Error reading object ID of \"%s\"", path);
823 /* Scan the data streams.
825 * Note: directories should not have an unnamed data stream, but they
826 * may have named data streams. Nondirectories (including reparse
827 * points) can have an unnamed data stream as well as named data
829 ret = scan_ntfs_attrs_with_type(inode, ni, path, params->unhashed_blobs,
834 /* Reparse-point fixups are a no-op because in NTFS-3G capture mode we
835 * only allow capturing an entire volume. */
836 if (params->add_flags & WIMLIB_ADD_FLAG_RPFIX &&
837 inode_is_symlink(inode))
838 inode->i_rp_flags &= ~WIM_RP_FLAG_NOT_FIXED;
840 if (!(params->add_flags & WIMLIB_ADD_FLAG_NO_ACLS)) {
841 ret = get_security_descriptor(ni, inode, volume->vol,
844 ERROR_WITH_ERRNO("Error reading security descriptor "
850 if (inode_is_directory(inode)) {
851 ret = ntfs_3g_recurse_directory(ni, root, volume, params);
858 ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
860 ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
863 ntfs_inode_close(ni);
865 free_dentry_tree(root, params->blob_table);
867 ret = report_scan_error(params, ret);
874 ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret,
875 const char *device, struct scan_params *params)
877 struct ntfs_volume_wrapper *volume;
881 volume = CALLOC(1, sizeof(struct ntfs_volume_wrapper));
883 return WIMLIB_ERR_NOMEM;
885 vol = ntfs_mount(device, NTFS_MNT_RDONLY);
887 ERROR_WITH_ERRNO("Failed to mount NTFS volume \"%s\" read-only",
890 return WIMLIB_ERR_NTFS_3G;
896 /* Currently, libntfs-3g users that need to read security descriptors
897 * are required to call ntfs_open_secure() to open the volume's security
898 * descriptor index, "$Secure". This is only required to work on NTFS
899 * v3.0+, as older versions did not have a security descriptor index. */
900 if (ntfs_open_secure(vol) && vol->major_ver >= 3) {
901 ERROR_WITH_ERRNO("Unable to open security descriptor index of "
902 "NTFS volume \"%s\"", device);
903 ret = WIMLIB_ERR_NTFS_3G;
904 goto out_put_ntfs_volume;
907 /* We don't want to capture the special NTFS files such as $Bitmap. Not
908 * to be confused with "hidden" or "system" files which are real files
909 * that we do need to capture. */
910 NVolClearShowSysFiles(vol);
912 ret = pathbuf_init(params, "/");
914 goto out_close_secure;
916 ret = ntfs_3g_build_dentry_tree_recursive(root_ret, FILE_root, "",
917 FILE_NAME_POSIX, volume,
920 /* Undo the effects of ntfs_open_secure(). This is not yet done
921 * automatically by ntfs_umount(). But NULL out the inode to
922 * potentially be robust against future versions doing so. */
923 if (vol->secure_ni) {
924 ntfs_index_ctx_put(vol->secure_xsii);
925 ntfs_index_ctx_put(vol->secure_xsdh);
926 ntfs_inode_close(vol->secure_ni);
927 vol->secure_ni = NULL;
930 put_ntfs_volume(volume);
933 #endif /* WITH_NTFS_3G */