+/* A reference-counted NTFS volume than is automatically unmounted when the
+ * reference count reaches 0 */
+struct ntfs_volume_wrapper {
+ ntfs_volume *vol;
+ size_t refcnt;
+};
+
+/* Description of where data is located in an NTFS volume */
+struct ntfs_location {
+ struct ntfs_volume_wrapper *volume;
+ u64 mft_no;
+ utf16lechar *attr_name;
+ unsigned attr_name_nchars;
+ unsigned attr_type;
+ u64 sort_key;
+};
+
+static struct ntfs_volume_wrapper *
+get_ntfs_volume(struct ntfs_volume_wrapper *volume)
+{
+ volume->refcnt++;
+ return volume;
+}
+
+static void
+put_ntfs_volume(struct ntfs_volume_wrapper *volume)
+{
+ if (--volume->refcnt == 0) {
+ ntfs_umount(volume->vol, FALSE);
+ FREE(volume);
+ }
+}
+