#include "sha1.h"
#include "lookup_table.h"
#include "xml.h"
+#include "timestamp.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
*/
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
return -EEXIST;
newdir = new_dentry(basename);
- newdir->attributes |= WIM_FILE_ATTRIBUTE_DIRECTORY;
+ newdir->attributes |= FILE_ATTRIBUTE_DIRECTORY;
link_dentry(newdir, parent);
return 0;
}
/* 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);
}
} 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;
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)
.rmdir = wimfs_rmdir,
.truncate = wimfs_truncate,
.unlink = wimfs_unlink,
+ .utimens = wimfs_utimens,
.write = wimfs_write,
};
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) {