Make wimfs files executable by default
authorEric Biggers <ebiggers3@gmail.com>
Mon, 12 Nov 2012 00:23:22 +0000 (18:23 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 12 Nov 2012 00:23:22 +0000 (18:23 -0600)
Also allow chmod(), as long as it doesn't actually change anything.

src/dentry.c
src/mount.c

index 9306212d82cf4ffef0bec7ca8dbce2ab310efe6c..359ebf1602c005e4eef8dee6f6c9238aa514e63b 100644 (file)
@@ -221,7 +221,7 @@ int inode_to_stbuf(const struct inode *inode, struct lookup_table_entry *lte,
        else if (inode_is_directory(inode))
                stbuf->st_mode = S_IFDIR | 0755;
        else
-               stbuf->st_mode = S_IFREG | 0644;
+               stbuf->st_mode = S_IFREG | 0755;
 
        stbuf->st_ino   = (ino_t)inode->ino;
        stbuf->st_nlink = inode->link_count;
index b9da36e172f5f1e5e11702a56325db4f57941409..834d5855303d7b42c59f3afa71e2696980312c99 100644 (file)
@@ -746,6 +746,28 @@ static int wimfs_access(const char *path, int mask)
        return 0;
 }
 
+static int wimfs_chmod(const char *path, mode_t mask)
+{
+       struct dentry *dentry;
+       struct wimfs_context *ctx = wimfs_get_context();
+       struct inode *inode;
+       struct stat stbuf;
+       int ret;
+
+       ret = lookup_resource(ctx->wim, path,
+                             get_lookup_flags(ctx) | LOOKUP_FLAG_DIRECTORY_OK,
+                             &dentry, NULL, NULL);
+       if (ret != 0)
+               return ret;
+       inode = dentry->d_inode;
+       inode_to_stbuf(inode, NULL, &stbuf);
+       if (mask == stbuf.st_mode)
+               return 0;
+       else
+               return -EPERM;
+
+}
+
 static void inode_update_lte_ptr(struct inode *inode,
                                 struct lookup_table_entry *old_lte,
                                 struct lookup_table_entry *new_lte)
@@ -1747,6 +1769,7 @@ static int wimfs_write(const char *path, const char *buf, size_t size,
 
 static struct fuse_operations wimfs_operations = {
        .access      = wimfs_access,
+       .chmod       = wimfs_chmod,
        .destroy     = wimfs_destroy,
 #if 0
        .fallocate   = wimfs_fallocate,