+/* Transfers file attributes from a struct wim_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 wim_inode *inode,
+ const struct wim_lookup_table_entry *lte,
+ struct stat *stbuf)
+{
+ const struct wimfs_context *ctx = wimfs_get_context();
+
+ memset(stbuf, 0, sizeof(struct stat));
+ stbuf->st_mode = inode_default_unix_mode(inode);
+ stbuf->st_uid = ctx->default_uid;
+ stbuf->st_gid = ctx->default_gid;
+ if (ctx->mount_flags & WIMLIB_MOUNT_FLAG_UNIX_DATA) {
+ struct wimlib_unix_data unix_data;
+ if (inode_get_unix_data(inode, &unix_data, NULL) == 0) {
+ stbuf->st_uid = unix_data.uid;
+ stbuf->st_gid = unix_data.gid;
+ stbuf->st_mode = unix_data.mode;
+ }
+ }
+ stbuf->st_ino = (ino_t)inode->i_ino;