#include "sdcardfs.h"
#include "strtok.h"
-#include "hashtable.h"
+#include <linux/hashtable.h>
#include <linux/syscalls.h>
#include <linux/kthread.h>
#include <linux/inotify.h>
#define STRING_BUF_SIZE (512)
struct hashtable_entry {
- struct hlist_node hlist;
- void *key;
+ struct hlist_node hlist;
+ void *key;
int value;
};
}
static int contain_appid_key(struct packagelist_data *pkgl_dat, void *appid) {
- struct hashtable_entry *hash_cur;
- struct hlist_node *h_n;
+ struct hashtable_entry *hash_cur;
+
+ hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist, (unsigned int)appid)
- hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist, (unsigned int)appid, h_n)
- if (appid == hash_cur->key)
- return 1;
+ if (appid == hash_cur->key)
+ return 1;
return 0;
}
return 1;
}
- appid = multiuser_get_app_id(current_fsuid());
+ appid = multiuser_get_app_id(from_kuid(&init_user_ns, current_fsuid()));
mutex_lock(&pkgl_dat->hashtable_lock);
ret = contain_appid_key(pkgl_dat, (void *)appid);
mutex_unlock(&pkgl_dat->hashtable_lock);
{
struct packagelist_data *pkgl_dat = (struct packagelist_data *)pkgl_id;
struct hashtable_entry *hash_cur;
- struct hlist_node *h_n;
unsigned int hash = str_hash((void *)app_name);
appid_t ret_id;
//printk(KERN_INFO "sdcardfs: %s: %s, %u\n", __func__, (char *)app_name, hash);
mutex_lock(&pkgl_dat->hashtable_lock);
- hash_for_each_possible(pkgl_dat->package_to_appid, hash_cur, hlist, hash, h_n) {
+ hash_for_each_possible(pkgl_dat->package_to_appid, hash_cur, hlist, hash) {
//printk(KERN_INFO "sdcardfs: %s: %s\n", __func__, (char *)hash_cur->key);
if (!strcasecmp(app_name, hash_cur->key)) {
ret_id = (appid_t)hash_cur->value;
/* Root always has access; access for any other UIDs should always
* be controlled through packages.list. */
- if (current_fsuid() == 0) {
+ if (from_kuid(&init_user_ns, current_fsuid()) == 0) {
return 1;
}
* parent or holds sdcard_rw. */
if (w_ok) {
if (parent_node &&
- (current_fsuid() == SDCARDFS_I(parent_node)->d_uid)) {
+ (from_kuid(&init_user_ns, current_fsuid()) ==
+ SDCARDFS_I(parent_node)->d_uid)) {
return 1;
}
return has_rw;
static int insert_str_to_int(struct packagelist_data *pkgl_dat, void *key, int value) {
struct hashtable_entry *hash_cur;
struct hashtable_entry *new_entry;
- struct hlist_node *h_n;
unsigned int hash = str_hash(key);
//printk(KERN_INFO "sdcardfs: %s: %s: %d, %u\n", __func__, (char *)key, value, hash);
- hash_for_each_possible(pkgl_dat->package_to_appid, hash_cur, hlist, hash, h_n) {
+ hash_for_each_possible(pkgl_dat->package_to_appid, hash_cur, hlist, hash) {
if (!strcasecmp(key, hash_cur->key)) {
hash_cur->value = value;
return 0;
static int insert_int_to_null(struct packagelist_data *pkgl_dat, void *key, int value) {
struct hashtable_entry *hash_cur;
struct hashtable_entry *new_entry;
- struct hlist_node *h_n;
//printk(KERN_INFO "sdcardfs: %s: %d: %d\n", __func__, (int)key, value);
hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist,
- (unsigned int)key, h_n) {
+ (unsigned int)key) {
if (key == hash_cur->key) {
hash_cur->value = value;
return 0;
static void remove_all_hashentrys(struct packagelist_data *pkgl_dat)
{
struct hashtable_entry *hash_cur;
- struct hlist_node *h_n;
struct hlist_node *h_t;
int i;
- hash_for_each_safe(pkgl_dat->package_to_appid, i, h_t, hash_cur, hlist, h_n)
+ hash_for_each_safe(pkgl_dat->package_to_appid, i, h_t, hash_cur, hlist)
remove_str_to_int(hash_cur);
- hash_for_each_safe(pkgl_dat->appid_with_rw, i, h_t, hash_cur, hlist, h_n)
- remove_int_to_null(hash_cur);
+ hash_for_each_safe(pkgl_dat->appid_with_rw, i, h_t, hash_cur, hlist)
+ remove_int_to_null(hash_cur);
hash_init(pkgl_dat->package_to_appid);
hash_init(pkgl_dat->appid_with_rw);