diff --git a/fs/hmdfs/authority/authentication.c b/fs/hmdfs/authority/authentication.c index 076e738c92e71b95281a157d3788ae631dee0ccf..fb98cbf9307271337d7adc32b299cb3277302f03 100644 --- a/fs/hmdfs/authority/authentication.c +++ b/fs/hmdfs/authority/authentication.c @@ -83,6 +83,7 @@ const struct cred *hmdfs_override_dir_fsids(struct inode *dir, * services: dfs_share : dfs_share * other : media_rw : media_rw **/ + hmdfs_info("HMDFS_PERM_DFS-dentry->d_name.name: %s", dentry->d_name.name); if (!strcmp(dentry->d_name.name, DFS_SHARE_NAME)) { perm = HMDFS_DIR_SERVICES | level; cred->fsuid = DFS_SHARE_UID; @@ -91,6 +92,8 @@ const struct cred *hmdfs_override_dir_fsids(struct inode *dir, } if (!strcmp(dentry->d_name.name, PKG_ROOT_NAME)) { perm = HMDFS_DIR_DATA | level; + } if (!strcmp(dentry->d_name.name, FILES_NAME)) { + perm = AUTH_FILE_MANAGER | HMDFS_DIR_PUBLIC | level; } else { perm = HMDFS_DIR_PUBLIC | level; } @@ -130,12 +133,18 @@ const struct cred *hmdfs_override_dir_fsids(struct inode *dir, } break; case HMDFS_PERM_OTHER: + hmdfs_info("HMDFS_PERM_OTHER-dentry->d_name.name: %s", dentry->d_name.name); cred->fsuid = dir->i_uid; cred->fsgid = dir->i_gid; if (is_pkg_auth(hii->perm)) perm = AUTH_PKG | HMDFS_DIR_PKG_SUB | level; - else + else if (is_filemanager_auth(hii->perm)) { + perm = AUTH_FILE_MANAGER | HMDFS_DIR_DEFAULT | level; + cred->fsuid = FILE_MANAGER_UID; + cred->fsgid = FILE_MANAGER_GID; + } else { perm = (hii->perm & AUTH_MASK) | HMDFS_DIR_DEFAULT | level; + } break; default: /* ! it should not get to here */ @@ -273,6 +282,7 @@ static __u16 __inherit_perm_dir(struct inode *parent, struct inode *inode) * services: dfs_share : dfs_share * other : media_rw : media_rw **/ + hmdfs_info("HMDFS_PERM_DFS-dentry->d_name.name: %s", dentry->d_name.name); if (!strcmp(dentry->d_name.name, DFS_SHARE_NAME)) { // "services" perm = HMDFS_DIR_SERVICES | level; @@ -282,6 +292,10 @@ static __u16 __inherit_perm_dir(struct inode *parent, struct inode *inode) } else if (!strcmp(dentry->d_name.name, SYSTEM_NAME)) { // "system" perm = AUTH_SYSTEM | HMDFS_DIR_SYSTEM | level; + } else if (!strcmp(dentry->d_name.name, FILES_NAME)) { + // "files" + hmdfs_info("HMDFS_PERM_DFS-dentry->d_name.name: %s", dentry->d_name.name); + perm = AUTH_FILE_MANAGER | HMDFS_DIR_PUBLIC | level; } else { perm = HMDFS_DIR_PUBLIC | level; } @@ -305,10 +319,15 @@ static __u16 __inherit_perm_dir(struct inode *parent, struct inode *inode) } break; case HMDFS_PERM_OTHER: - if (is_pkg_auth(info->perm)) + hmdfs_info("HMDFS_PERM_OTHER-dentry->d_name.name: %s", dentry->d_name.name); + if (is_pkg_auth(info->perm)) { perm = AUTH_PKG | HMDFS_DIR_PKG_SUB | level; - else + } else if (is_filemanager_auth(info->perm)) { + hmdfs_info("HMDFS_PERM_OTHER-dentry->d_name.name: %s", dentry->d_name.name); + perm = AUTH_FILE_MANAGER | HMDFS_DIR_DEFAULT | level; + } else { perm = (info->perm & AUTH_MASK) | HMDFS_DIR_DEFAULT | level; + } break; default: /* ! it should not get to here */ @@ -329,8 +348,12 @@ static __u16 __inherit_perm_file(struct inode *parent) if (is_pkg_auth(hii->perm)) perm = AUTH_PKG | HMDFS_FILE_PKG_SUB | level; - else + else if (is_filemanager_auth(hii->perm)) { + hmdfs_info("__inherit_perm_file->hii->perm: %lld", hii->perm); + perm = AUTH_FILE_MANAGER | HMDFS_FILE_DEFAULT | level; + } else { perm = (hii->perm & AUTH_MASK) | HMDFS_FILE_DEFAULT | level; + } return perm; } @@ -389,6 +412,8 @@ void check_and_fixup_ownership_remote(struct inode *dir, } if (!strcmp(dentry->d_name.name, PKG_ROOT_NAME)) { perm = HMDFS_DIR_DATA | level; + } if (!strcmp(dentry->d_name.name, FILES_NAME)) { + perm = AUTH_FILE_MANAGER | HMDFS_DIR_PUBLIC | level; } else { perm = HMDFS_DIR_PUBLIC | level; } @@ -435,10 +460,15 @@ void check_and_fixup_ownership_remote(struct inode *dir, perm = AUTH_PKG | HMDFS_DIR_PKG_SUB | level; break; } - if (is_pkg_auth(hii->perm)) + if (is_pkg_auth(hii->perm)) { perm = AUTH_PKG | HMDFS_DIR_PKG_SUB | level; - else + } else if (is_filemanager_auth(hii->perm)) { + perm = AUTH_FILE_MANAGER | HMDFS_DIR_DEFAULT | level; + dinode->i_uid = FILE_MANAGER_UID; + dinode->i_gid = FILE_MANAGER_GID; + } else { perm = (hii->perm & AUTH_MASK) | HMDFS_DIR_DEFAULT | level; + } break; default: /* ! it should not get to here */ diff --git a/fs/hmdfs/authority/authentication.h b/fs/hmdfs/authority/authentication.h index a36636a782865672089d8fd46c45bea78315917d..0a7d55e3db5fb0937f7513d430fdd3631f1e939f 100644 --- a/fs/hmdfs/authority/authentication.h +++ b/fs/hmdfs/authority/authentication.h @@ -27,6 +27,7 @@ struct cache_fs_override { #define OID_ROOT 0 #define OID_SYSTEM 1000 #define OID_USER_DATA_RW 1008 +#define OID_FILE_MANAGER 1006 #define OID_DFS_SHARE 3822 /* copied from sdcardfs/multiuser.h */ @@ -38,21 +39,24 @@ struct cache_fs_override { #define SYSTEM_UID KUIDT_INIT(OID_SYSTEM) #define USER_DATA_RW_UID KUIDT_INIT(OID_USER_DATA_RW) #define DFS_SHARE_UID KUIDT_INIT(OID_DFS_SHARE) +#define FILE_MANAGER_UID KUIDT_INIT(OID_FILE_MANAGER) #define ROOT_GID KGIDT_INIT(OID_ROOT) #define SYSTEM_GID KGIDT_INIT(OID_SYSTEM) #define USER_DATA_RW_GID KGIDT_INIT(OID_USER_DATA_RW) #define DFS_SHARE_GID KGIDT_INIT(OID_DFS_SHARE) +#define FILE_MANAGER_GID KGIDT_INIT(OID_FILE_MANAGER) #define PKG_ROOT_NAME "data" #define DFS_SHARE_NAME "services" #define SYSTEM_NAME "system" +#define FILES_NAME "files" /* * | perm fix | permmnt | permdfs | permpkg | perm other - * /mnt/mdfs/ accoundID / device view / local / DATA / packageName /... + * /mnt/mdfs/ accoundID / device view / local / data / packageName /... * / system /... - * / documents /... + * / files /... * / devid /....... * / merge view / * / sdcard / @@ -168,6 +172,7 @@ static inline bool is_default_file(__u16 perm) #define AUTH_PKG 0x0100 #define AUTH_SYSTEM 0x0200 #define AUTH_SERVICES 0x0400 +#define AUTH_FILE_MANAGER 0x0800 static inline bool is_pkg_auth(__u16 perm) { @@ -183,6 +188,11 @@ static inline bool is_service_auth(__u16 perm) { return (perm & AUTH_MASK) == AUTH_SERVICES; } + +static inline bool is_filemanager_auth(__u16 perm) +{ + return (perm & AUTH_FILE_MANAGER) == AUTH_FILE_MANAGER; +} #define HMDFS_MOUNT_POINT_MASK 0xF000 #define HMDFS_MNT_COMMON 0x0000 // sdcard #define HMDFS_MNT_SDCARD 0x1000 // sdcard diff --git a/fs/hmdfs/inode_local.c b/fs/hmdfs/inode_local.c index 346309fd94aa5ee063b350800acfdc3e76892f98..4810d13267b3db5aa3f7de8d9c8b75b0f7a6280e 100644 --- a/fs/hmdfs/inode_local.c +++ b/fs/hmdfs/inode_local.c @@ -274,7 +274,7 @@ struct dentry *hmdfs_lookup_local(struct inode *parent_inode, hmdfs_put_reset_lower_path(child_dentry); goto out_err; } - + // fix check_and_fixup_ownership(parent_inode, child_inode); goto out_err; } @@ -849,7 +849,7 @@ struct dentry *hmdfs_lookup_share(struct inode *parent_inode, hmdfs_put_reset_lower_path(child_dentry); goto err_out; } - + // fix check_and_fixup_ownership(parent_inode, child_inode); err_out: