51 |
/***** The structure for mount restrictions. *****/ |
/***** The structure for mount restrictions. *****/ |
52 |
|
|
53 |
struct mount_entry { |
struct mount_entry { |
54 |
struct list_head list; |
struct list1_head list; |
55 |
const struct path_info *dev_name; |
const struct path_info *dev_name; |
56 |
const struct path_info *dir_name; |
const struct path_info *dir_name; |
57 |
const struct path_info *fs_type; |
const struct path_info *fs_type; |
68 |
} |
} |
69 |
#endif |
#endif |
70 |
|
|
71 |
static LIST_HEAD(mount_list); |
static LIST1_HEAD(mount_list); |
72 |
|
|
73 |
static int AddMountACL(const char *dev_name, const char *dir_name, const char *fs_type, const unsigned long flags, const bool is_delete) |
static int AddMountACL(const char *dev_name, const char *dir_name, const char *fs_type, const unsigned long flags, const bool is_delete) |
74 |
{ |
{ |
86 |
if (!IsCorrectPath(dev_name, 0, 0, 0, __FUNCTION__) || !IsCorrectPath(dir_name, 1, 0, 1, __FUNCTION__)) return -EINVAL; |
if (!IsCorrectPath(dev_name, 0, 0, 0, __FUNCTION__) || !IsCorrectPath(dir_name, 1, 0, 1, __FUNCTION__)) return -EINVAL; |
87 |
if ((dev = SaveName(dev_name)) == NULL || (dir = SaveName(dir_name)) == NULL) return -ENOMEM; |
if ((dev = SaveName(dev_name)) == NULL || (dir = SaveName(dir_name)) == NULL) return -ENOMEM; |
88 |
mutex_lock(&lock); |
mutex_lock(&lock); |
89 |
list_for_each_entry(ptr, &mount_list, list) { |
list1_for_each_entry(ptr, &mount_list, list) { |
90 |
if (ptr->flags != flags || pathcmp(ptr->dev_name, dev) || pathcmp(ptr->dir_name, dir) || pathcmp(ptr->fs_type, fs)) continue; |
if (ptr->flags != flags || pathcmp(ptr->dev_name, dev) || pathcmp(ptr->dir_name, dir) || pathcmp(ptr->fs_type, fs)) continue; |
91 |
error = 0; |
error = 0; |
92 |
if (is_delete) { |
if (is_delete) { |
109 |
new_entry->dir_name = dir; |
new_entry->dir_name = dir; |
110 |
new_entry->fs_type = fs; |
new_entry->fs_type = fs; |
111 |
new_entry->flags = flags; |
new_entry->flags = flags; |
112 |
list_add_tail_mb(&new_entry->list, &mount_list); |
list1_add_tail_mb(&new_entry->list, &mount_list); |
113 |
error = 0; |
error = 0; |
114 |
ptr = new_entry; |
ptr = new_entry; |
115 |
update: |
update: |
230 |
error = -ENODEV; |
error = -ENODEV; |
231 |
goto cleanup; |
goto cleanup; |
232 |
} |
} |
233 |
list_for_each_entry(ptr, &mount_list, list) { |
list1_for_each_entry(ptr, &mount_list, list) { |
234 |
if (ptr->is_deleted) continue; |
if (ptr->is_deleted) continue; |
235 |
|
|
236 |
/* Compare options */ |
/* Compare options */ |
320 |
|
|
321 |
int ReadMountPolicy(struct io_buffer *head) |
int ReadMountPolicy(struct io_buffer *head) |
322 |
{ |
{ |
323 |
struct list_head *pos; |
struct list1_head *pos; |
324 |
list_for_each_cookie(pos, head->read_var2, &mount_list) { |
list1_for_each_cookie(pos, head->read_var2, &mount_list) { |
325 |
struct mount_entry *ptr; |
struct mount_entry *ptr; |
326 |
ptr = list_entry(pos, struct mount_entry, list); |
ptr = list1_entry(pos, struct mount_entry, list); |
327 |
if (ptr->is_deleted) continue; |
if (ptr->is_deleted) continue; |
328 |
if (io_printf(head, KEYWORD_ALLOW_MOUNT "%s %s %s 0x%lX\n", ptr->dev_name->name, ptr->dir_name->name, ptr->fs_type->name, ptr->flags)) return -ENOMEM; |
if (io_printf(head, KEYWORD_ALLOW_MOUNT "%s %s %s 0x%lX\n", ptr->dev_name->name, ptr->dir_name->name, ptr->fs_type->name, ptr->flags)) return -ENOMEM; |
329 |
} |
} |