]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
inode.h, inode.c cleanup
[wimlib] / src / mount_image.c
index 18db8571fbd270eafe43e46ad27cae5153d40d91..0bd4a1f1d76d3463aa642ce2581f8b780f38e1c2 100644 (file)
@@ -39,6 +39,7 @@
 
 #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"
@@ -371,12 +372,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 +591,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 +603,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 +680,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 +1145,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)
@@ -1584,7 +1585,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 +1913,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 +1947,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 +1983,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 +2006,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 +2436,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);
        }