return -EMFILE;
num_new_fds = min(fds_per_alloc,
max_fds - inode->num_allocated_fds);
-
+
fds = REALLOC(inode->fds,
(inode->num_allocated_fds + num_new_fds) *
sizeof(inode->fds[0]));
DEBUG("Creating staging file `%s'", name);
- fd = open(name, open_flags | O_CREAT | O_TRUNC, 0600);
+ fd = open(name, open_flags | O_CREAT | O_TRUNC, 0600);
if (fd == -1) {
errno_save = errno;
FREE(name);
return fd;
}
-/*
+/*
* Extract a WIM resource to the staging directory.
*
* @inode: Inode that contains the stream we are extracting
* opening it read-write. Identify those file descriptors and
* change their lookup table entry pointers to point to the new
* lookup table entry, and open staging file descriptors for
- * them.
+ * them.
*
* At the same time, we need to count the number of these opened
* file descriptors to the new lookup table entry. If there's
return ret;
}
-/*
+/*
* Creates a randomly named staging directory and returns its name into the
* static variable staging_dir_name.
*
}
-/*
- * Deletes the staging directory and all the files contained in it.
+/*
+ * Deletes the staging directory and all the files contained in it.
*/
static int delete_staging_dir()
{
int ret;
-
+
ret = nftw(staging_dir_name, remove_file_or_directory,10, FTW_DEPTH);
staging_dir_name = NULL;
return ret;
static mqd_t daemon_to_unmount_mq;
/* Simple function that returns the concatenation of 4 strings. */
-static char *strcat_dup(const char *s1, const char *s2, const char *s3,
+static char *strcat_dup(const char *s1, const char *s2, const char *s3,
const char *s4)
{
size_t len = strlen(s1) + strlen(s2) + strlen(s3) + strlen(s4) + 1;
}
}
-/*
+/*
* Opens two POSIX message queue: one for sending messages from the unmount
* process to the daemon process, and one to go the other way. The names of the
* message queues, which must be system-wide unique, are be based on the mount
else
flags = O_WRONLY | O_CREAT;
- unmount_to_daemon_mq = mq_open(unmount_to_daemon_mq_name, flags,
+ unmount_to_daemon_mq = mq_open(unmount_to_daemon_mq_name, flags,
0700, NULL);
if (unmount_to_daemon_mq == (mqd_t)-1) {
else
flags = O_RDONLY | O_CREAT;
- daemon_to_unmount_mq = mq_open(daemon_to_unmount_mq_name, flags,
+ daemon_to_unmount_mq = mq_open(daemon_to_unmount_mq_name, flags,
0700, NULL);
if (daemon_to_unmount_mq == (mqd_t)-1) {
DEBUG("Waiting for message telling us whether to commit or not, and "
"whether to include integrity checks.");
- bytes_received = mq_timedreceive(unmount_to_daemon_mq, msg,
+ bytes_received = mq_timedreceive(unmount_to_daemon_mq, msg,
msgsize, NULL, &timeout);
commit = msg[0];
check_integrity = msg[1];
}
#endif
-/*
- * Create a directory in the WIM.
+/*
+ * Create a directory in the WIM.
* @mode is currently ignored.
*/
static int wimfs_mkdir(const char *path, mode_t mode)
struct dentry *parent;
struct dentry *newdir;
const char *basename;
-
+
parent = get_parent_dentry(w, path);
if (!parent)
return -ENOENT;
struct inode *inode;
int ret;
struct wimlib_fd *fd = NULL;
-
+
inode = wim_pathname_to_inode(w, path);
if (!inode)
return -ENOENT;
/*
- * Read data from a file in the WIM or in the staging directory.
+ * Read data from a file in the WIM or in the staging directory.
*/
-static int wimfs_read(const char *path, char *buf, size_t size,
+static int wimfs_read(const char *path, char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
struct wimlib_fd *fd = (struct wimlib_fd*)(uintptr_t)fi->fh;
/* Read from WIM */
u64 res_size = wim_resource_size(fd->f_lte);
-
+
if (offset > res_size)
return -EOVERFLOW;
/* Fills in the entries of the directory specified by @path using the
* FUSE-provided function @filler. */
-static int wimfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
+static int wimfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
struct wimlib_fd *fd = (struct wimlib_fd*)(uintptr_t)fi->fh;
/* This rename() implementation currently only supports actual files
* (not alternate data streams) */
-
+
src = get_dentry(w, from);
if (!src)
return -ENOENT;
static int wimfs_rmdir(const char *path)
{
struct dentry *dentry;
-
+
dentry = get_dentry(w, path);
if (!dentry)
return -ENOENT;
struct dentry *dentry_parent, *dentry;
const char *link_name;
struct inode *inode;
-
+
dentry_parent = get_parent_dentry(w, from);
if (!dentry_parent)
return -ENOENT;
u16 stream_idx;
u32 stream_id;
struct inode *inode;
-
+
ret = lookup_resource(w, path, get_lookup_flags(), &dentry,
<e, &stream_idx);
int ret;
u16 stream_idx;
unsigned i;
-
+
ret = lookup_resource(w, path, get_lookup_flags(), &dentry,
<e, &stream_idx);
}
#ifdef HAVE_UTIMENSAT
-/*
- * Change the timestamp on a file dentry.
+/*
+ * Change the timestamp on a file dentry.
*
* Note that alternate data streams do not have their own timestamps.
*/
}
#endif
-/* Writes to a file in the WIM filesystem.
+/* Writes to a file in the WIM filesystem.
* It may be an alternate data stream, but here we don't even notice because we
* just get a lookup table entry. */
-static int wimfs_write(const char *path, const char *buf, size_t size,
+static int wimfs_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
struct wimlib_fd *fd = (struct wimlib_fd*)(uintptr_t)fi->fh;
/* Mounts a WIM file. */
-WIMLIBAPI int wimlib_mount(WIMStruct *wim, int image, const char *dir,
+WIMLIBAPI int wimlib_mount(WIMStruct *wim, int image, const char *dir,
int flags, WIMStruct **additional_swms,
unsigned num_additional_swms)
{
if (flags & WIMLIB_MOUNT_FLAG_DEBUG)
argv[argc++] = "-d";
- /*
+ /*
* We provide the use_ino option because we are going to assign inode
* numbers oursides. We've already numbered the inodes with unique
* numbers in the assign_inode_numbers() function, and the static
}
-/*
+/*
* Unmounts the WIM file that was previously mounted on @dir by using
* wimlib_mount().
*/
msg[0] = (flags & WIMLIB_UNMOUNT_FLAG_COMMIT) ? 1 : 0;
msg[1] = (flags & WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY) ? 1 : 0;
- DEBUG("Sending message: %s, %s",
+ DEBUG("Sending message: %s, %s",
(msg[0] == 0) ? "don't commit" : "commit",
(msg[1] == 0) ? "don't check" : "check");
ret = mq_send(unmount_to_daemon_mq, msg, 2, 1);
* send a message from this process to the filesystem daemon telling
* whether --commit was specified or not. However, after that, the
* unmount process must wait for the filesystem daemon to finish writing
- * the WIM file.
+ * the WIM file.
*/
* filesystem daemon has crashed or failed for some reason.
*
* XXX come up with some method to determine if the filesystem
- * daemon has really crashed or not.
+ * daemon has really crashed or not.
*
* XXX Idea: have mount daemon write its PID into the WIM file header?
* */
return mount_unsupported_error();
}
-WIMLIBAPI int wimlib_mount(WIMStruct *wim_p, int image, const char *dir,
+WIMLIBAPI int wimlib_mount(WIMStruct *wim_p, int image, const char *dir,
int flags, WIMStruct **additional_swms,
unsigned num_additional_swms)
{