#include "sha1.h"
#include "lookup_table.h"
#include "xml.h"
-#include "io.h"
+#include "buffer_io.h"
#include "timestamp.h"
#include <limits.h>
#include <stdlib.h>
put_dentry(dentry);
}
+/* Transfers file attributes from a struct inode to a `stat' buffer.
+ *
+ * The lookup table entry tells us which stream in the inode we are statting.
+ * For a named data stream, everything returned is the same as the unnamed data
+ * stream except possibly the size and block count. */
+static int inode_to_stbuf(const struct inode *inode,
+ struct lookup_table_entry *lte, struct stat *stbuf)
+{
+ if (inode_is_symlink(inode))
+ stbuf->st_mode = S_IFLNK | 0777;
+ else if (inode_is_directory(inode))
+ stbuf->st_mode = S_IFDIR | 0755;
+ else
+ stbuf->st_mode = S_IFREG | 0755;
+
+ stbuf->st_ino = (ino_t)inode->ino;
+ stbuf->st_nlink = inode->link_count;
+ stbuf->st_uid = getuid();
+ stbuf->st_gid = getgid();
+
+ if (lte) {
+ if (lte->resource_location == RESOURCE_IN_STAGING_FILE) {
+ wimlib_assert(lte->staging_file_name);
+ struct stat native_stat;
+ if (stat(lte->staging_file_name, &native_stat) != 0) {
+ DEBUG("Failed to stat `%s': %m",
+ lte->staging_file_name);
+ return -errno;
+ }
+ stbuf->st_size = native_stat.st_size;
+ } else {
+ stbuf->st_size = wim_resource_size(lte);
+ }
+ } else {
+ stbuf->st_size = 0;
+ }
+
+ stbuf->st_atime = wim_timestamp_to_unix(inode->last_access_time);
+ stbuf->st_mtime = wim_timestamp_to_unix(inode->last_write_time);
+ stbuf->st_ctime = wim_timestamp_to_unix(inode->creation_time);
+ stbuf->st_blocks = (stbuf->st_size + 511) / 512;
+ return 0;
+}
+
/* Creates a new staging file and returns its file descriptor opened for
* writing.
*
struct lookup_table *joined_tab, *wim_tab_save;
struct image_metadata *imd;
struct wimfs_context ctx;
+ struct hlist_node *cur_node;
+ struct inode *inode;
DEBUG("Mount: wim = %p, image = %d, dir = %s, flags = %d, ",
wim, image, dir, mount_flags);
imd->has_been_mounted_rw = 1;
}
- /* Resolve all the lookup table entries of the dentry tree */
- DEBUG("Resolving lookup table entries");
- for_dentry_in_tree(imd->root_dentry, dentry_resolve_ltes,
- wim->lookup_table);
+ /* Resolve the lookup table entries for every inode in the image, and
+ * assign inode numbers */
+ DEBUG("Resolving lookup table entries and assigning inode numbers");
- ctx.next_ino = assign_inode_numbers(&imd->inode_list);
+ ctx.next_ino = 1;
+ hlist_for_each_entry(inode, cur_node, &imd->inode_list, hlist) {
+ inode_resolve_ltes(inode, wim->lookup_table);
+ inode->ino = ctx.next_ino++;
+ }
+ /*ctx.next_ino = assign_inode_numbers(&imd->inode_list);*/
DEBUG("(next_ino = %"PRIu64")", ctx.next_ino);
-
DEBUG("Calling fuse_main()");
ret = fuse_main(argc, argv, &wimfs_operations, &ctx);