X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmount_image.c;h=2e50d6c3422c2e650727917caba50a38d8ae90e1;hb=ba9577d39906b70c591e4d898d5f05ca909d59e1;hp=18db8571fbd270eafe43e46ad27cae5153d40d91;hpb=4c73e29d8d74a4e969782d2d40e209337414034c;p=wimlib diff --git a/src/mount_image.c b/src/mount_image.c index 18db8571..2e50d6c3 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -37,19 +37,12 @@ # 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 #include #include +#include #include #include #include @@ -61,9 +54,17 @@ #include #include -#define FUSE_USE_VERSION 26 -#include -#include +#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; @@ -590,11 +583,11 @@ inode_to_stbuf(const struct wim_inode *inode, stbuf->st_mtim = wim_timestamp_to_timespec(inode->i_last_write_time); stbuf->st_ctim = stbuf->st_mtim; #else - stbuf->st_atime = wim_timestamp_to_unix(inode->i_last_access_time); - stbuf->st_mtime = wim_timestamp_to_unix(inode->i_last_write_time); + stbuf->st_atime = wim_timestamp_to_time_t(inode->i_last_access_time); + stbuf->st_mtime = wim_timestamp_to_time_t(inode->i_last_write_time); stbuf->st_ctime = stbuf->st_mtime; #endif - stbuf->st_blocks = (stbuf->st_size + 511) / 512; + stbuf->st_blocks = DIV_ROUND_UP(stbuf->st_size, 512); return 0; } @@ -602,7 +595,7 @@ inode_to_stbuf(const struct wim_inode *inode, static void touch_inode(struct wim_inode *inode) { - u64 now = get_wim_timestamp(); + u64 now = now_as_wim_timestamp(); inode->i_last_access_time = now; inode->i_last_write_time = now; } @@ -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) @@ -1144,7 +1137,7 @@ commit_image(struct wimfs_context *ctx, int unmount_flags, mqd_t mq) return wimlib_overwrite(ctx->wim, write_flags, 0); } -/* In the case of an allow_other mount, only the owner and root should be +/* In the case of an allow_other mount, only the mount owner and root are * allowed to unmount the filesystem. */ static bool may_unmount_wimfs(void) @@ -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); @@ -1982,15 +1973,15 @@ wimfs_utimens(const char *path, const struct timespec tv[2]) if (tv[0].tv_nsec != UTIME_OMIT) { if (tv[0].tv_nsec == UTIME_NOW) - inode->i_last_access_time = get_wim_timestamp(); + inode->i_last_access_time = now_as_wim_timestamp(); else - inode->i_last_access_time = timespec_to_wim_timestamp(tv[0]); + inode->i_last_access_time = timespec_to_wim_timestamp(&tv[0]); } if (tv[1].tv_nsec != UTIME_OMIT) { if (tv[1].tv_nsec == UTIME_NOW) - inode->i_last_write_time = get_wim_timestamp(); + inode->i_last_write_time = now_as_wim_timestamp(); else - inode->i_last_write_time = timespec_to_wim_timestamp(tv[1]); + inode->i_last_write_time = timespec_to_wim_timestamp(&tv[1]); } return 0; } @@ -2005,8 +1996,8 @@ wimfs_utime(const char *path, struct utimbuf *times) if (!inode) return -errno; - inode->i_last_access_time = unix_timestamp_to_wim(times->actime); - inode->i_last_write_time = unix_timestamp_to_wim(times->modtime); + inode->i_last_access_time = time_t_to_wim_timestamp(times->actime); + inode->i_last_write_time = time_t_to_wim_timestamp(times->modtime); return 0; } #endif /* !HAVE_UTIMENSAT */ @@ -2435,7 +2426,7 @@ do_unmount_commit(const char *dir, int unmount_flags, ret = do_unmount(dir); if (progfunc) { /* Terminate the progress thread. */ - char empty[0]; + char empty[1]; mq_send(mq, empty, 0, 1); pthread_join(commit_progress_tid, NULL); }