]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
mount_image.c: Use fuse_context.umask only when available
[wimlib] / src / mount_image.c
index b00a2a686c28bcb7cebb67f97f4d18d562bb8187..bd27a46aa74902ad71bb72a613c13abee87b76ef 100644 (file)
@@ -347,6 +347,15 @@ close_wimfs_fd(struct wimfs_fd *fd)
        return 0;
 }
 
+static mode_t
+fuse_mask_mode(mode_t mode, struct fuse_context *fuse_ctx)
+{
+#if FUSE_MAJOR_VERSION > 2 || (FUSE_MAJOR_VERSION == 2 && FUSE_MINOR_VERSION >= 8)
+       mode &= ~fuse_ctx->umask;
+#endif
+       return mode;
+}
+
 /*
  * Add a new dentry with a new inode to a WIM image.
  *
@@ -385,7 +394,7 @@ create_dentry(struct fuse_context *fuse_ctx, const char *path,
                if (inode_set_unix_data(new->d_inode,
                                        fuse_ctx->uid,
                                        fuse_ctx->gid,
-                                       mode & ~fuse_ctx->umask,
+                                       fuse_mask_mode(mode, fuse_ctx),
                                        wimfs_ctx->wim->lookup_table,
                                        UNIX_DATA_ALL | UNIX_DATA_CREATE))
                {
@@ -2026,7 +2035,7 @@ wimfs_readlink(const char *path, char *buf, size_t buf_len)
                return -EINVAL;
        if (buf_len == 0)
                return -ENAMETOOLONG;
-       ret = inode_readlink(inode, buf, buf_len - 1, ctx->wim, true);
+       ret = wim_inode_readlink(inode, buf, buf_len - 1);
        if (ret >= 0) {
                wimlib_assert(ret <= buf_len - 1);
                buf[ret] = '\0';
@@ -2217,11 +2226,14 @@ wimfs_symlink(const char *to, const char *from)
                            FILE_ATTRIBUTE_REPARSE_POINT, &dentry);
        if (ret == 0) {
                dentry->d_inode->i_reparse_tag = WIM_IO_REPARSE_TAG_SYMLINK;
-               if (inode_set_symlink(dentry->d_inode, to,
-                                     wimfs_ctx->wim->lookup_table, NULL))
-               {
+               ret = wim_inode_set_symlink(dentry->d_inode, to,
+                                           wimfs_ctx->wim->lookup_table);
+               if (ret) {
                        remove_dentry(dentry, wimfs_ctx->wim->lookup_table);
-                       ret = -ENOMEM;
+                       if (ret == WIMLIB_ERR_NOMEM)
+                               ret = -ENOMEM;
+                       else
+                               ret = -EIO;
                }
        }
        return ret;