From 1596d7ad7bf93f0e326b070a173a59004ab9b649 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 11 Nov 2012 18:23:22 -0600 Subject: [PATCH] Make wimfs files executable by default Also allow chmod(), as long as it doesn't actually change anything. --- src/dentry.c | 2 +- src/mount.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/dentry.c b/src/dentry.c index 9306212d..359ebf16 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -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; diff --git a/src/mount.c b/src/mount.c index b9da36e1..834d5855 100644 --- a/src/mount.c +++ b/src/mount.c @@ -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, -- 2.43.0