]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
Move inode_to_stbuf() to mount_image.c
[wimlib] / src / dentry.c
index ae71c1d54d92b0c8a7cd36a94f587d6f2704b17d..daab2fea4bd16a3f96cc851897a0e6f3d6659976 100644 (file)
  * wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include <errno.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "dentry.h"
 #include "buffer_io.h"
+#include "dentry.h"
 #include "lookup_table.h"
-#include "sha1.h"
 #include "timestamp.h"
 #include "wimlib_internal.h"
 
-
 /* Calculates the unaligned length, in bytes, of an on-disk WIM dentry that has
  * a file name and short name that take the specified numbers of bytes.  This
  * excludes any alternate data stream entries that may follow the dentry. */
@@ -175,52 +168,6 @@ static u64 dentry_total_length(const struct dentry *dentry)
        return __dentry_total_length(dentry, dentry->length);
 }
 
-#ifdef WITH_FUSE
-/* 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. */
-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;
-}
-#endif
-
 int for_dentry_in_rbtree(struct rb_node *root,
                         int (*visitor)(struct dentry *, void *),
                         void *arg)
@@ -1833,4 +1780,3 @@ u8 *write_dentry_tree(const struct dentry *root, u8 *p)
        /* Recursively write the rest of the dentry tree. */
        return write_dentry_tree_recursive(root, p);
 }
-