]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
Delay xml_update_image_info() until write
[wimlib] / src / mount_image.c
index eeacf94d138864ab9c0bae8975d1ff0e475302a3..bca9e4390e473c7987ae04f0522ccf6ab91901c7 100644 (file)
@@ -511,7 +511,7 @@ create_file(struct fuse_context *fuse_ctx, const char *path,
                }
        }
 
-       hlist_add_head(&inode->i_hlist,
+       hlist_add_head(&inode->i_hlist_node,
                       &wim_get_current_image_metadata(wimfs_ctx->wim)->inode_list);
 
        dentry_add_child(parent, dentry);
@@ -1051,7 +1051,6 @@ renew_current_image(struct wimfs_context *ctx)
                goto err_put_replace_imd;
 
        new_blob->refcnt = 1;
-       new_blob->unhashed = 1;
        new_blob->is_metadata = 1;
 
        /* Make the image being moved available at a new index.  Increments the
@@ -1061,7 +1060,7 @@ renew_current_image(struct wimfs_context *ctx)
        if (ret)
                goto err_free_new_blob;
 
-       ret = xml_add_image(wim, "");
+       ret = xml_add_image(wim->xml_info, NULL);
        if (ret)
                goto err_undo_append;
 
@@ -1117,7 +1116,7 @@ commit_image(struct wimfs_context *ctx, int unmount_flags, mqd_t mq)
        }
        INIT_LIST_HEAD(&ctx->orig_blob_list);
        delete_empty_blobs(ctx);
-       xml_update_image_info(ctx->wim, ctx->wim->current_image);
+       mark_image_dirty(wim_get_current_image_metadata(ctx->wim));
 
        write_flags = 0;
 
@@ -1678,7 +1677,7 @@ wimfs_read(const char *path, char *buf, size_t size,
                        ret = size;
                break;
        case BLOB_IN_STAGING_FILE:
-               ret = raw_pread(&fd->f_staging_fd, buf, size, offset);
+               ret = pread(fd->f_staging_fd.fd, buf, size, offset);
                if (ret < 0)
                        ret = -errno;
                break;
@@ -1712,18 +1711,15 @@ wimfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                return ret;
 
        for_inode_child(child, inode) {
-               char *file_name_mbs;
-               size_t file_name_mbs_nbytes;
+               char *name;
+               size_t name_nbytes;
 
-               ret = utf16le_to_tstr(child->file_name,
-                                     child->file_name_nbytes,
-                                     &file_name_mbs,
-                                     &file_name_mbs_nbytes);
-               if (ret)
+               if (utf16le_to_tstr(child->d_name, child->d_name_nbytes,
+                                   &name, &name_nbytes))
                        return -errno;
 
-               ret = filler(buf, file_name_mbs, NULL, 0);
-               FREE(file_name_mbs);
+               ret = filler(buf, name, NULL, 0);
+               FREE(name);
                if (ret)
                        return ret;
        }
@@ -2037,7 +2033,7 @@ wimfs_write(const char *path, const char *buf, size_t size,
        struct wimfs_fd *fd = WIMFS_FD(fi);
        ssize_t ret;
 
-       ret = raw_pwrite(&fd->f_staging_fd, buf, size, offset);
+       ret = pwrite(fd->f_staging_fd.fd, buf, size, offset);
        if (ret < 0)
                return -errno;
 
@@ -2132,15 +2128,16 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
        /* Get the metadata for the image to mount.  */
        imd = wim_get_current_image_metadata(wim);
 
-       if (imd->modified) {
-               /* To avoid complicating things, we don't support mounting
-                * images to which in-memory modifications have already been
-                * made.  */
+       /* To avoid complicating things, we don't support mounting images to
+        * which in-memory modifications have already been made.  */
+       if (is_image_dirty(imd)) {
                ERROR("Cannot mount a modified WIM image!");
                return WIMLIB_ERR_INVALID_PARAM;
        }
 
        if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
+               if (imd->refcnt > 1)
+                       return WIMLIB_ERR_IMAGE_HAS_MULTIPLE_REFERENCES;
                ret = lock_wim_for_append(wim);
                if (ret)
                        return ret;
@@ -2211,10 +2208,6 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
         * the file descriptor arrays  */
        prepare_inodes(&ctx);
 
-       /* If a read-write mount, mark the image as modified.  */
-       if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE)
-               imd->modified = 1;
-
        /* Save the absolute path to the mountpoint directory.  */
        ctx.mountpoint_abspath = realpath(dir, NULL);
        if (ctx.mountpoint_abspath)