X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fmount.c;h=ed428fca58907d1b943fb51b7590cbd934c92ace;hp=ac56415ecd5906607e69f3e68987df7443a2bfcc;hb=d5b841b4d3243c7c6922d9254fb4e5b9f0b58d41;hpb=a74b18bea7d988a718da91143b6a1374736bb1a9 diff --git a/src/mount.c b/src/mount.c index ac56415e..ed428fca 100644 --- a/src/mount.c +++ b/src/mount.c @@ -956,7 +956,7 @@ static int wimfs_ftruncate(const char *path, off_t size, struct wimlib_fd *fd = (struct wimlib_fd*)(uintptr_t)fi->fh; int ret = ftruncate(fd->staging_fd, size); if (ret != 0) - return ret; + return -errno; if (fd->f_lte && size < fd->f_lte->resource_entry.original_size) fd->f_lte->resource_entry.original_size = size; return 0; @@ -1249,9 +1249,9 @@ static int wimfs_opendir(const char *path, struct fuse_file_info *fi) struct inode *inode; int ret; struct wimlib_fd *fd = NULL; - struct wimfs_context *ctx = wimfs_get_context(); + WIMStruct *w = wimfs_get_WIMStruct(); - inode = wim_pathname_to_inode(ctx->wim, path); + inode = wim_pathname_to_inode(w, path); if (!inode) return -ENOENT; if (!inode_is_directory(inode)) @@ -1308,6 +1308,18 @@ static int wimfs_read(const char *path, char *buf, size_t size, } } +struct fill_params { + void *buf; + fuse_fill_dir_t filler; +}; + +static int dentry_fuse_fill(struct dentry *dentry, void *arg) +{ + struct fill_params *fill_params = arg; + return fill_params->filler(fill_params->buf, dentry->file_name_utf8, + NULL, 0); +} + /* 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, @@ -1315,27 +1327,22 @@ static int wimfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, { struct wimlib_fd *fd = (struct wimlib_fd*)(uintptr_t)fi->fh; struct inode *inode; - struct dentry *child; if (!fd) return -EBADF; inode = fd->f_inode; + struct fill_params fill_params = { + .buf = buf, + .filler = filler, + }; + filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); - child = inode->children; - - if (!child) - return 0; - - do { - if (filler(buf, child->file_name_utf8, NULL, 0)) - return 0; - child = child->next; - } while (child != inode->children); - return 0; + return for_dentry_in_rbtree(inode->children.rb_node, + dentry_fuse_fill, &fill_params); } @@ -1439,7 +1446,7 @@ static int wimfs_rename(const char *from, const char *to) * directory */ if (!dentry_is_directory(dst)) return -ENOTDIR; - if (dst->d_inode->children != NULL) + if (inode_has_children(dst->d_inode)) return -ENOTEMPTY; } parent_of_dst = dst->parent; @@ -1692,6 +1699,8 @@ static int wimfs_utime(const char *path, struct utimbuf *times) { struct dentry *dentry; struct inode *inode; + WIMStruct *w = wimfs_get_WIMStruct(); + dentry = get_dentry(w, path); if (!dentry) return -ENOENT;