shithub: lwext4

Download patch

ref: 9293ce9f84d052c9de71b375ba9f93470cdff456
parent: cc2ee3402d4a4de0f7827397313f16f3c1b4fa3f
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Tue Jan 26 01:15:35 EST 2016

ext4: ext4_chmod now only allows modifying the lowest 12bit of i_mode.

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -1989,7 +1989,7 @@
 int ext4_chmod(const char *path, uint32_t mode)
 {
 	int r;
-	uint32_t ino;
+	uint32_t ino, orig_mode;
 	ext4_file f;
 	struct ext4_sblock *sb;
 	struct ext4_inode_ref inode_ref;
@@ -2017,7 +2017,10 @@
 		return r;
 	}
 
-	ext4_inode_set_mode(sb, inode_ref.inode, mode);
+	orig_mode = ext4_inode_get_mode(sb, inode_ref.inode);
+	orig_mode &= ~0xFFF;
+	orig_mode |= mode & 0xFFF;
+	ext4_inode_set_mode(sb, inode_ref.inode, orig_mode);
 	inode_ref.dirty = true;
 
 	r = ext4_fs_put_inode_ref(&inode_ref);