]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
A few cleanups and fixes from recent changes
[wimlib] / src / mount_image.c
index 94feb4eeb473fa36cdbb85eff811919c2d3a0742..2e50d6c3422c2e650727917caba50a38d8ae90e1 100644 (file)
 #  error "FUSE mount not supported on Windows!  Please configure --without-fuse"
 #endif
 
-#include "wimlib/dentry.h"
-#include "wimlib/encoding.h"
-#include "wimlib/metadata.h"
-#include "wimlib/paths.h"
-#include "wimlib/progress.h"
-#include "wimlib/reparse.h"
-#include "wimlib/timestamp.h"
-#include "wimlib/unix_data.h"
-#include "wimlib/write.h"
-#include "wimlib/xml.h"
+#define FUSE_USE_VERSION 26
 
+#include <attr/xattr.h>
 #include <dirent.h>
 #include <errno.h>
+#include <fuse.h>
 #include <limits.h>
 #include <mqueue.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <utime.h>
 
-#define FUSE_USE_VERSION 26
-#include <fuse.h>
-#include <attr/xattr.h>
+#include "wimlib/dentry.h"
+#include "wimlib/encoding.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/metadata.h"
+#include "wimlib/paths.h"
+#include "wimlib/progress.h"
+#include "wimlib/reparse.h"
+#include "wimlib/timestamp.h"
+#include "wimlib/unix_data.h"
+#include "wimlib/write.h"
+#include "wimlib/xml.h"
 
 #ifndef O_NOFOLLOW
 #  define O_NOFOLLOW 0  /* Security only...  */
@@ -323,15 +324,7 @@ close_wimfs_fd(struct wimfs_fd *fd)
        if (fd->f_idx < inode->i_next_fd)
                inode->i_next_fd = fd->f_idx;
        FREE(fd);
-       if (--inode->i_num_opened_fds == 0) {
-               /* The last file descriptor to this inode was closed.  */
-               FREE(inode->i_fds);
-               inode->i_fds = NULL;
-               inode->i_num_allocated_fds = 0;
-               if (inode->i_nlink == 0)
-                       /* No links to this inode remain.  Get rid of it.  */
-                       free_inode(inode);
-       }
+       inode_dec_num_opened_fds(inode);
        return ret;
 }
 
@@ -371,12 +364,12 @@ wim_pathname_to_stream(const struct wimfs_context *ctx, const char *path,
                       int lookup_flags,
                       struct wim_dentry **dentry_ret,
                       struct wim_lookup_table_entry **lte_ret,
-                      u16 *stream_idx_ret)
+                      unsigned *stream_idx_ret)
 {
        WIMStruct *wim = ctx->wim;
        struct wim_dentry *dentry;
        struct wim_lookup_table_entry *lte;
-       u16 stream_idx;
+       unsigned stream_idx;
        const char *stream_name = NULL;
        struct wim_inode *inode;
        char *p = NULL;
@@ -679,7 +672,7 @@ retry:
  */
 static int
 extract_resource_to_staging_dir(struct wim_inode *inode,
-                               u16 stream_idx,
+                               unsigned stream_idx,
                                struct wim_lookup_table_entry **lte_ptr,
                                off_t size,
                                const struct wimfs_context *ctx)
@@ -1438,12 +1431,10 @@ wimfs_link(const char *existing_path, const char *new_path)
        if (new_dentry(new_name, &new_alias))
                return -ENOMEM;
 
-       new_alias->d_inode = inode;
-       inode_add_dentry(new_alias, inode);
+       inode_ref_streams(inode);
+       d_associate(new_alias, inode);
        dentry_add_child(dir, new_alias);
        touch_inode(dir->d_inode);
-       inode->i_nlink++;
-       inode_ref_streams(inode);
        return 0;
 }
 
@@ -1584,7 +1575,7 @@ wimfs_open(const char *path, struct fuse_file_info *fi)
        struct wim_dentry *dentry;
        struct wim_inode *inode;
        struct wim_lookup_table_entry *lte;
-       u16 stream_idx;
+       unsigned stream_idx;
        struct wimfs_fd *fd;
        int ret;
 
@@ -1912,7 +1903,7 @@ wimfs_truncate(const char *path, off_t size)
        const struct wimfs_context *ctx = wimfs_get_context();
        struct wim_dentry *dentry;
        struct wim_lookup_table_entry *lte;
-       u16 stream_idx;
+       unsigned stream_idx;
        int ret;
        int fd;
 
@@ -1946,7 +1937,7 @@ wimfs_unlink(const char *path)
 {
        const struct wimfs_context *ctx = wimfs_get_context();
        struct wim_dentry *dentry;
-       u16 stream_idx;
+       unsigned stream_idx;
        int ret;
 
        ret = wim_pathname_to_stream(ctx, path, 0, &dentry, NULL, &stream_idx);