]> wimlib.net Git - wimlib/blobdiff - src/mount.c
Alternate stream entries fixes
[wimlib] / src / mount.c
index 53a7f364e0989f6eb1e4d56e04a02ff94d2a2527..c6ce55885905fb260613973b924a678a321a3238 100644 (file)
@@ -32,6 +32,7 @@
 #include "sha1.h"
 #include "lookup_table.h"
 #include "xml.h"
+#include "timestamp.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
@@ -118,7 +119,11 @@ static int remove_file_or_directory(const char *fpath, const struct stat *sb,
  */
 static inline int delete_staging_dir()
 {
-       return nftw(staging_dir_name, remove_file_or_directory, 10, FTW_DEPTH);
+       int ret;
+       
+       ret = nftw(staging_dir_name, remove_file_or_directory,10, FTW_DEPTH);
+       staging_dir_name = NULL;
+       return ret;
 }
 
 /* Name and message queue descriptors for message queues between the filesystem
@@ -490,7 +495,7 @@ static int wimfs_mkdir(const char *path, mode_t mode)
                return -EEXIST;
 
        newdir = new_dentry(basename);
-       newdir->attributes |= WIM_FILE_ATTRIBUTE_DIRECTORY;
+       newdir->attributes |= FILE_ATTRIBUTE_DIRECTORY;
        link_dentry(newdir, parent);
        return 0;
 }
@@ -580,8 +585,6 @@ static int wimfs_mknod(const char *path, mode_t mode, dev_t rdev)
 
        /* Create a lookup table entry having the same hash value */
        lte = new_lookup_table_entry();
-       lte->staging_num_times_opened = 0;
-       lte->resource_entry.original_size = 0;
        memcpy(lte->hash, dentry->hash, WIM_HASH_SIZE);
 
        fd = create_staging_file(&tmpfile_name);
@@ -630,10 +633,14 @@ static int wimfs_open(const char *path, struct fuse_file_info *fi)
                }
        } else {
                /* no lookup table entry, so the file must be empty.  Create a
-                * lookup table entry for the file. */
+                * lookup table entry for the file, unless it's a read-only
+                * filesystem.  */
                char *tmpfile_name;
                int fd;
 
+               if (!staging_dir_name) /* Read-only filesystem */
+                       return 0;
+
                lte = new_lookup_table_entry();
                if (!lte)
                        return -ENOMEM;
@@ -981,6 +988,20 @@ static int wimfs_unlink(const char *path)
        return 0;
 }
 
+static int wimfs_utimens(const char *path, const struct timespec tv[2])
+{
+       struct dentry *dentry = get_dentry(w, path);
+       if (!dentry)
+               return -ENOENT;
+       time_t last_access_t = (tv[0].tv_nsec == UTIME_NOW) ? 
+                               time(NULL) : tv[0].tv_sec;
+       dentry->last_access_time = unix_timestamp_to_ms(last_access_t);
+       time_t last_mod_t = (tv[1].tv_nsec == UTIME_NOW) ?  
+                               time(NULL) : tv[1].tv_sec;
+       dentry->last_write_time = unix_timestamp_to_ms(last_mod_t);
+       return 0;
+}
+
 /* Writes to a file in the WIM filesystem. */
 static int wimfs_write(const char *path, const char *buf, size_t size, 
                                off_t offset, struct fuse_file_info *fi)
@@ -1054,6 +1075,7 @@ static struct fuse_operations wimfs_oper = {
        .rmdir    = wimfs_rmdir,
        .truncate = wimfs_truncate,
        .unlink   = wimfs_unlink,
+       .utimens  = wimfs_utimens,
        .write    = wimfs_write,
 };
 
@@ -1081,6 +1103,11 @@ WIMLIBAPI int wimlib_mount(WIMStruct *wim, int image, const char *dir,
        if (flags & WIMLIB_MOUNT_FLAG_READWRITE)
                wim_get_current_image_metadata(wim)->modified = true;
 
+       if (!(flags & (WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE |
+                      WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR |
+                      WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS)))
+               flags |= WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR;
+
        mount_dir = dir;
        working_directory = getcwd(NULL, 0);
        if (!working_directory) {