Lines Matching refs:p

180 static int perm_destroy(void *key, void *datum, void *p)  in perm_destroy()  argument
187 static int common_destroy(void *key, void *datum, void *p) in common_destroy() argument
214 static int cls_destroy(void *key, void *datum, void *p) in cls_destroy() argument
256 static int role_destroy(void *key, void *datum, void *p) in role_destroy() argument
270 static int type_destroy(void *key, void *datum, void *p) in type_destroy() argument
277 static int user_destroy(void *key, void *datum, void *p) in user_destroy() argument
293 static int sens_destroy(void *key, void *datum, void *p) in sens_destroy() argument
308 static int cat_destroy(void *key, void *datum, void *p) in cat_destroy() argument
326 static int filenametr_destroy(void *key, void *datum, void *p) in filenametr_destroy() argument
343 static int range_tr_destroy(void *key, void *datum, void *p) in range_tr_destroy() argument
355 static int role_tr_destroy(void *key, void *datum, void *p) in role_tr_destroy() argument
378 static int roles_init(struct policydb *p) in roles_init() argument
389 role->value = ++p->p_roles.nprim; in roles_init()
398 rc = symtab_insert(&p->p_roles, key, role); in roles_init()
448 struct policydb *p, struct filename_trans_key *key) in policydb_filenametr_search() argument
450 return hashtab_search(&p->filename_trans, key, filenametr_key_params); in policydb_filenametr_search()
484 struct mls_range *policydb_rangetr_search(struct policydb *p, in policydb_rangetr_search() argument
487 return hashtab_search(&p->range_tr, key, rangetr_key_params); in policydb_rangetr_search()
518 struct role_trans_datum *policydb_roletr_search(struct policydb *p, in policydb_roletr_search() argument
521 return hashtab_search(&p->role_tr, key, roletr_key_params); in policydb_roletr_search()
527 static void policydb_init(struct policydb *p) in policydb_init() argument
529 memset(p, 0, sizeof(*p)); in policydb_init()
531 avtab_init(&p->te_avtab); in policydb_init()
532 cond_policydb_init(p); in policydb_init()
534 ebitmap_init(&p->filename_trans_ttypes); in policydb_init()
535 ebitmap_init(&p->policycaps); in policydb_init()
536 ebitmap_init(&p->permissive_map); in policydb_init()
551 struct policydb *p; in common_index() local
555 p = datap; in common_index()
556 if (!comdatum->value || comdatum->value > p->p_commons.nprim) in common_index()
559 p->sym_val_to_name[SYM_COMMONS][comdatum->value - 1] = key; in common_index()
566 struct policydb *p; in class_index() local
570 p = datap; in class_index()
571 if (!cladatum->value || cladatum->value > p->p_classes.nprim) in class_index()
574 p->sym_val_to_name[SYM_CLASSES][cladatum->value - 1] = key; in class_index()
575 p->class_val_to_struct[cladatum->value - 1] = cladatum; in class_index()
581 struct policydb *p; in role_index() local
585 p = datap; in role_index()
587 || role->value > p->p_roles.nprim in role_index()
588 || role->bounds > p->p_roles.nprim) in role_index()
591 p->sym_val_to_name[SYM_ROLES][role->value - 1] = key; in role_index()
592 p->role_val_to_struct[role->value - 1] = role; in role_index()
598 struct policydb *p; in type_index() local
602 p = datap; in type_index()
606 || typdatum->value > p->p_types.nprim in type_index()
607 || typdatum->bounds > p->p_types.nprim) in type_index()
609 p->sym_val_to_name[SYM_TYPES][typdatum->value - 1] = key; in type_index()
610 p->type_val_to_struct[typdatum->value - 1] = typdatum; in type_index()
618 struct policydb *p; in user_index() local
622 p = datap; in user_index()
624 || usrdatum->value > p->p_users.nprim in user_index()
625 || usrdatum->bounds > p->p_users.nprim) in user_index()
628 p->sym_val_to_name[SYM_USERS][usrdatum->value - 1] = key; in user_index()
629 p->user_val_to_struct[usrdatum->value - 1] = usrdatum; in user_index()
635 struct policydb *p; in sens_index() local
639 p = datap; in sens_index()
643 levdatum->level->sens > p->p_levels.nprim) in sens_index()
646 p->sym_val_to_name[SYM_LEVELS][levdatum->level->sens - 1] = key; in sens_index()
654 struct policydb *p; in cat_index() local
658 p = datap; in cat_index()
661 if (!catdatum->value || catdatum->value > p->p_cats.nprim) in cat_index()
664 p->sym_val_to_name[SYM_CATS][catdatum->value - 1] = key; in cat_index()
715 static int policydb_index(struct policydb *p) in policydb_index() argument
719 if (p->mls_enabled) in policydb_index()
721 p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, in policydb_index()
722 p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); in policydb_index()
725 p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, in policydb_index()
726 p->p_bools.nprim); in policydb_index()
729 p->p_classes.nprim, p->te_avtab.nel); in policydb_index()
731 avtab_hash_eval(&p->te_avtab, "rules"); in policydb_index()
732 symtab_hash_eval(p->symtab); in policydb_index()
734 p->class_val_to_struct = kcalloc(p->p_classes.nprim, in policydb_index()
735 sizeof(*p->class_val_to_struct), in policydb_index()
737 if (!p->class_val_to_struct) in policydb_index()
740 p->role_val_to_struct = kcalloc(p->p_roles.nprim, in policydb_index()
741 sizeof(*p->role_val_to_struct), in policydb_index()
743 if (!p->role_val_to_struct) in policydb_index()
746 p->user_val_to_struct = kcalloc(p->p_users.nprim, in policydb_index()
747 sizeof(*p->user_val_to_struct), in policydb_index()
749 if (!p->user_val_to_struct) in policydb_index()
752 p->type_val_to_struct = kvcalloc(p->p_types.nprim, in policydb_index()
753 sizeof(*p->type_val_to_struct), in policydb_index()
755 if (!p->type_val_to_struct) in policydb_index()
758 rc = cond_init_bool_indexes(p); in policydb_index()
763 p->sym_val_to_name[i] = kvcalloc(p->symtab[i].nprim, in policydb_index()
766 if (!p->sym_val_to_name[i]) in policydb_index()
769 rc = hashtab_map(&p->symtab[i].table, index_f[i], p); in policydb_index()
781 void policydb_destroy(struct policydb *p) in policydb_destroy() argument
790 hashtab_map(&p->symtab[i].table, destroy_f[i], NULL); in policydb_destroy()
791 hashtab_destroy(&p->symtab[i].table); in policydb_destroy()
795 kvfree(p->sym_val_to_name[i]); in policydb_destroy()
797 kfree(p->class_val_to_struct); in policydb_destroy()
798 kfree(p->role_val_to_struct); in policydb_destroy()
799 kfree(p->user_val_to_struct); in policydb_destroy()
800 kvfree(p->type_val_to_struct); in policydb_destroy()
802 avtab_destroy(&p->te_avtab); in policydb_destroy()
806 c = p->ocontexts[i]; in policydb_destroy()
812 p->ocontexts[i] = NULL; in policydb_destroy()
815 g = p->genfs; in policydb_destroy()
829 p->genfs = NULL; in policydb_destroy()
831 cond_policydb_destroy(p); in policydb_destroy()
833 hashtab_map(&p->role_tr, role_tr_destroy, NULL); in policydb_destroy()
834 hashtab_destroy(&p->role_tr); in policydb_destroy()
836 for (ra = p->role_allow; ra; ra = ra->next) { in policydb_destroy()
843 hashtab_map(&p->filename_trans, filenametr_destroy, NULL); in policydb_destroy()
844 hashtab_destroy(&p->filename_trans); in policydb_destroy()
846 hashtab_map(&p->range_tr, range_tr_destroy, NULL); in policydb_destroy()
847 hashtab_destroy(&p->range_tr); in policydb_destroy()
849 if (p->type_attr_map_array) { in policydb_destroy()
850 for (i = 0; i < p->p_types.nprim; i++) in policydb_destroy()
851 ebitmap_destroy(&p->type_attr_map_array[i]); in policydb_destroy()
852 kvfree(p->type_attr_map_array); in policydb_destroy()
855 ebitmap_destroy(&p->filename_trans_ttypes); in policydb_destroy()
856 ebitmap_destroy(&p->policycaps); in policydb_destroy()
857 ebitmap_destroy(&p->permissive_map); in policydb_destroy()
864 int policydb_load_isids(struct policydb *p, struct sidtab *s) in policydb_load_isids() argument
875 head = p->ocontexts[OCON_ISID]; in policydb_load_isids()
901 int policydb_class_isvalid(struct policydb *p, unsigned int class) in policydb_class_isvalid() argument
903 if (!class || class > p->p_classes.nprim) in policydb_class_isvalid()
908 int policydb_role_isvalid(struct policydb *p, unsigned int role) in policydb_role_isvalid() argument
910 if (!role || role > p->p_roles.nprim) in policydb_role_isvalid()
915 int policydb_type_isvalid(struct policydb *p, unsigned int type) in policydb_type_isvalid() argument
917 if (!type || type > p->p_types.nprim) in policydb_type_isvalid()
926 int policydb_context_isvalid(struct policydb *p, struct context *c) in policydb_context_isvalid() argument
931 if (!c->role || c->role > p->p_roles.nprim) in policydb_context_isvalid()
934 if (!c->user || c->user > p->p_users.nprim) in policydb_context_isvalid()
937 if (!c->type || c->type > p->p_types.nprim) in policydb_context_isvalid()
944 role = p->role_val_to_struct[c->role - 1]; in policydb_context_isvalid()
952 usrdatum = p->user_val_to_struct[c->user - 1]; in policydb_context_isvalid()
961 if (!mls_context_isvalid(p, c)) in policydb_context_isvalid()
1031 struct policydb *p, in context_read_and_validate() argument
1045 if (p->policyvers >= POLICYDB_VERSION_MLS) { in context_read_and_validate()
1054 if (!policydb_context_isvalid(p, c)) { in context_read_and_validate()
1093 static int perm_read(struct policydb *p, struct symtab *s, void *fp) in perm_read() argument
1126 static int common_read(struct policydb *p, struct symtab *s, void *fp) in common_read() argument
1156 rc = perm_read(p, &comdatum->permissions, fp); in common_read()
1195 static int read_cons_helper(struct policydb *p, in read_cons_helper() argument
1265 if (p->policyvers >= in read_cons_helper()
1290 static int class_read(struct policydb *p, struct symtab *s, void *fp) in class_read() argument
1328 cladatum->comdatum = symtab_search(&p->p_commons, in class_read()
1337 rc = perm_read(p, &cladatum->permissions, fp); in class_read()
1342 rc = read_cons_helper(p, &cladatum->constraints, ncons, 0, fp); in class_read()
1346 if (p->policyvers >= POLICYDB_VERSION_VALIDATETRANS) { in class_read()
1352 rc = read_cons_helper(p, &cladatum->validatetrans, in class_read()
1358 if (p->policyvers >= POLICYDB_VERSION_NEW_OBJECT_DEFAULTS) { in class_read()
1368 if (p->policyvers >= POLICYDB_VERSION_DEFAULT_TYPE) { in class_read()
1385 static int role_read(struct policydb *p, struct symtab *s, void *fp) in role_read() argument
1398 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_read()
1407 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_read()
1442 static int type_read(struct policydb *p, struct symtab *s, void *fp) in type_read() argument
1455 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in type_read()
1464 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) { in type_read()
1517 static int user_read(struct policydb *p, struct symtab *s, void *fp) in user_read() argument
1530 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_read()
1539 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_read()
1550 if (p->policyvers >= POLICYDB_VERSION_MLS) { in user_read()
1568 static int sens_read(struct policydb *p, struct symtab *s, void *fp) in sens_read() argument
1609 static int cat_read(struct policydb *p, struct symtab *s, void *fp) in cat_read() argument
1642 static int (*const read_f[SYM_NUM]) (struct policydb *p,
1657 struct policydb *p = datap; in user_bounds_sanity_check() local
1672 upper = p->user_val_to_struct[upper->bounds - 1]; in user_bounds_sanity_check()
1679 sym_name(p, SYM_USERS, user->value - 1), in user_bounds_sanity_check()
1680 sym_name(p, SYM_ROLES, bit), in user_bounds_sanity_check()
1681 sym_name(p, SYM_USERS, upper->value - 1)); in user_bounds_sanity_check()
1693 struct policydb *p = datap; in role_bounds_sanity_check() local
1708 upper = p->role_val_to_struct[upper->bounds - 1]; in role_bounds_sanity_check()
1715 sym_name(p, SYM_ROLES, role->value - 1), in role_bounds_sanity_check()
1716 sym_name(p, SYM_TYPES, bit), in role_bounds_sanity_check()
1717 sym_name(p, SYM_ROLES, upper->value - 1)); in role_bounds_sanity_check()
1729 struct policydb *p = datap; in type_bounds_sanity_check() local
1741 upper = p->type_val_to_struct[upper->bounds - 1]; in type_bounds_sanity_check()
1748 sym_name(p, SYM_TYPES, upper->value - 1)); in type_bounds_sanity_check()
1756 static int policydb_bounds_sanity_check(struct policydb *p) in policydb_bounds_sanity_check() argument
1760 if (p->policyvers < POLICYDB_VERSION_BOUNDARY) in policydb_bounds_sanity_check()
1763 rc = hashtab_map(&p->p_users.table, user_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1767 rc = hashtab_map(&p->p_roles.table, role_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1771 rc = hashtab_map(&p->p_types.table, type_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1778 u16 string_to_security_class(struct policydb *p, const char *name) in string_to_security_class() argument
1782 cladatum = symtab_search(&p->p_classes, name); in string_to_security_class()
1789 u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) in string_to_av_perm() argument
1795 if (!tclass || tclass > p->p_classes.nprim) in string_to_av_perm()
1798 cladatum = p->class_val_to_struct[tclass-1]; in string_to_av_perm()
1810 static int range_read(struct policydb *p, void *fp) in range_read() argument
1818 if (p->policyvers < POLICYDB_VERSION_MLS) in range_read()
1827 rc = hashtab_init(&p->range_tr, nel); in range_read()
1843 if (p->policyvers >= POLICYDB_VERSION_RANGETRANS) { in range_read()
1849 rt->target_class = p->process_class; in range_read()
1852 if (!policydb_type_isvalid(p, rt->source_type) || in range_read()
1853 !policydb_type_isvalid(p, rt->target_type) || in range_read()
1854 !policydb_class_isvalid(p, rt->target_class)) in range_read()
1867 if (!mls_range_isvalid(p, r)) { in range_read()
1872 rc = hashtab_insert(&p->range_tr, rt, r, rangetr_key_params); in range_read()
1879 hash_eval(&p->range_tr, "rangetr"); in range_read()
1887 static int filename_trans_read_helper_compat(struct policydb *p, void *fp) in filename_trans_read_helper_compat() argument
1919 datum = policydb_filenametr_search(p, &key); in filename_trans_read_helper_compat()
1949 rc = hashtab_insert(&p->filename_trans, ft, datum, in filename_trans_read_helper_compat()
1955 rc = ebitmap_set_bit(&p->filename_trans_ttypes, in filename_trans_read_helper_compat()
1971 static int filename_trans_read_helper(struct policydb *p, void *fp) in filename_trans_read_helper() argument
2038 rc = hashtab_insert(&p->filename_trans, ft, first, in filename_trans_read_helper()
2045 return ebitmap_set_bit(&p->filename_trans_ttypes, ttype, 1); in filename_trans_read_helper()
2060 static int filename_trans_read(struct policydb *p, void *fp) in filename_trans_read() argument
2066 if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS) in filename_trans_read()
2074 if (p->policyvers < POLICYDB_VERSION_COMP_FTRANS) { in filename_trans_read()
2075 p->compat_filename_trans_count = nel; in filename_trans_read()
2077 rc = hashtab_init(&p->filename_trans, (1 << 11)); in filename_trans_read()
2082 rc = filename_trans_read_helper_compat(p, fp); in filename_trans_read()
2087 rc = hashtab_init(&p->filename_trans, nel); in filename_trans_read()
2092 rc = filename_trans_read_helper(p, fp); in filename_trans_read()
2097 hash_eval(&p->filename_trans, "filenametr"); in filename_trans_read()
2101 static int genfs_read(struct policydb *p, void *fp) in genfs_read() argument
2131 for (genfs_p = NULL, genfs = p->genfs; genfs; in genfs_read()
2146 p->genfs = newgenfs; in genfs_read()
2175 rc = context_read_and_validate(&newc->context[0], p, fp); in genfs_read()
2214 static int ocontext_read(struct policydb *p, const struct policydb_compat_info *info, in ocontext_read() argument
2240 p->ocontexts[i] = c; in ocontext_read()
2250 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2269 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2272 rc = context_read_and_validate(&c->context[1], p, fp); in ocontext_read()
2283 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2293 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2315 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2329 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2360 p, in ocontext_read()
2387 p, in ocontext_read()
2405 int policydb_read(struct policydb *p, void *fp) in policydb_read() argument
2417 policydb_init(p); in policydb_read()
2474 p->policyvers = le32_to_cpu(buf[0]); in policydb_read()
2475 if (p->policyvers < POLICYDB_VERSION_MIN || in policydb_read()
2476 p->policyvers > POLICYDB_VERSION_MAX) { in policydb_read()
2484 p->mls_enabled = 1; in policydb_read()
2487 if (p->policyvers < POLICYDB_VERSION_MLS) { in policydb_read()
2490 p->policyvers); in policydb_read()
2494 p->reject_unknown = !!(le32_to_cpu(buf[1]) & REJECT_UNKNOWN); in policydb_read()
2495 p->allow_unknown = !!(le32_to_cpu(buf[1]) & ALLOW_UNKNOWN); in policydb_read()
2497 if (p->policyvers >= POLICYDB_VERSION_POLCAP) { in policydb_read()
2498 rc = ebitmap_read(&p->policycaps, fp); in policydb_read()
2503 if (p->policyvers >= POLICYDB_VERSION_PERMISSIVE) { in policydb_read()
2504 rc = ebitmap_read(&p->permissive_map, fp); in policydb_read()
2510 info = policydb_lookup_compat(p->policyvers); in policydb_read()
2513 "for version %d\n", p->policyvers); in policydb_read()
2534 rc = symtab_init(&p->symtab[i], nel); in policydb_read()
2539 rc = roles_init(p); in policydb_read()
2545 rc = read_f[i](p, &p->symtab[i], fp); in policydb_read()
2550 p->symtab[i].nprim = nprim; in policydb_read()
2554 p->process_class = string_to_security_class(p, "process"); in policydb_read()
2555 if (!p->process_class) { in policydb_read()
2560 rc = avtab_read(&p->te_avtab, fp, p); in policydb_read()
2564 if (p->policyvers >= POLICYDB_VERSION_BOOL) { in policydb_read()
2565 rc = cond_read_list(p, fp); in policydb_read()
2575 rc = hashtab_init(&p->role_tr, nel); in policydb_read()
2596 if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { in policydb_read()
2602 rtk->tclass = p->process_class; in policydb_read()
2605 if (!policydb_role_isvalid(p, rtk->role) || in policydb_read()
2606 !policydb_type_isvalid(p, rtk->type) || in policydb_read()
2607 !policydb_class_isvalid(p, rtk->tclass) || in policydb_read()
2608 !policydb_role_isvalid(p, rtd->new_role)) in policydb_read()
2611 rc = hashtab_insert(&p->role_tr, rtk, rtd, roletr_key_params); in policydb_read()
2632 p->role_allow = ra; in policydb_read()
2640 if (!policydb_role_isvalid(p, ra->role) || in policydb_read()
2641 !policydb_role_isvalid(p, ra->new_role)) in policydb_read()
2646 rc = filename_trans_read(p, fp); in policydb_read()
2650 rc = policydb_index(p); in policydb_read()
2655 perm = string_to_av_perm(p, p->process_class, "transition"); in policydb_read()
2660 p->process_trans_perms = perm; in policydb_read()
2661 perm = string_to_av_perm(p, p->process_class, "dyntransition"); in policydb_read()
2666 p->process_trans_perms |= perm; in policydb_read()
2668 rc = ocontext_read(p, info, fp); in policydb_read()
2672 rc = genfs_read(p, fp); in policydb_read()
2676 rc = range_read(p, fp); in policydb_read()
2681 p->type_attr_map_array = kvcalloc(p->p_types.nprim, in policydb_read()
2682 sizeof(*p->type_attr_map_array), in policydb_read()
2684 if (!p->type_attr_map_array) in policydb_read()
2688 for (i = 0; i < p->p_types.nprim; i++) in policydb_read()
2689 ebitmap_init(&p->type_attr_map_array[i]); in policydb_read()
2691 for (i = 0; i < p->p_types.nprim; i++) { in policydb_read()
2692 struct ebitmap *e = &p->type_attr_map_array[i]; in policydb_read()
2694 if (p->policyvers >= POLICYDB_VERSION_AVTAB) { in policydb_read()
2705 rc = policydb_bounds_sanity_check(p); in policydb_read()
2715 policydb_destroy(p); in policydb_read()
2838 struct policydb *p = pd->p; in role_trans_write_one() local
2848 if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { in role_trans_write_one()
2857 static int role_trans_write(struct policydb *p, void *fp) in role_trans_write() argument
2859 struct policy_data pd = { .p = p, .fp = fp }; in role_trans_write()
2863 buf[0] = cpu_to_le32(p->role_tr.nel); in role_trans_write()
2868 return hashtab_map(&p->role_tr, role_trans_write_one, &pd); in role_trans_write()
2899 static int context_write(struct policydb *p, struct context *c, in context_write() argument
2996 static int write_cons_helper(struct policydb *p, struct constraint_node *node, in write_cons_helper() argument
3027 if (p->policyvers >= in write_cons_helper()
3049 struct policydb *p = pd->p; in class_write() local
3090 rc = write_cons_helper(p, cladatum->constraints, fp); in class_write()
3104 rc = write_cons_helper(p, cladatum->validatetrans, fp); in class_write()
3108 if (p->policyvers >= POLICYDB_VERSION_NEW_OBJECT_DEFAULTS) { in class_write()
3118 if (p->policyvers >= POLICYDB_VERSION_DEFAULT_TYPE) { in class_write()
3134 struct policydb *p = pd->p; in role_write() local
3143 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_write()
3172 struct policydb *p = pd->p; in type_write() local
3182 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) { in type_write()
3213 struct policydb *p = pd->p; in user_write() local
3223 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_write()
3260 static int ocontext_write(struct policydb *p, const struct policydb_compat_info *info, in ocontext_write() argument
3272 for (c = p->ocontexts[i]; c; c = c->next) in ocontext_write()
3278 for (c = p->ocontexts[i]; c; c = c->next) { in ocontext_write()
3285 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3299 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3302 rc = context_write(p, &c->context[1], fp); in ocontext_write()
3313 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3323 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3337 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3349 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3367 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3381 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3391 static int genfs_write(struct policydb *p, void *fp) in genfs_write() argument
3400 for (genfs = p->genfs; genfs; genfs = genfs->next) in genfs_write()
3406 for (genfs = p->genfs; genfs; genfs = genfs->next) { in genfs_write()
3435 rc = context_write(p, &c->context[0], fp); in genfs_write()
3450 struct policydb *p = pd->p; in range_write_helper() local
3458 if (p->policyvers >= POLICYDB_VERSION_RANGETRANS) { in range_write_helper()
3471 static int range_write(struct policydb *p, void *fp) in range_write() argument
3477 pd.p = p; in range_write()
3480 buf[0] = cpu_to_le32(p->range_tr.nel); in range_write()
3486 rc = hashtab_map(&p->range_tr, range_write_helper, &pd); in range_write()
3579 static int filename_trans_write(struct policydb *p, void *fp) in filename_trans_write() argument
3584 if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS) in filename_trans_write()
3587 if (p->policyvers < POLICYDB_VERSION_COMP_FTRANS) { in filename_trans_write()
3588 buf[0] = cpu_to_le32(p->compat_filename_trans_count); in filename_trans_write()
3593 rc = hashtab_map(&p->filename_trans, in filename_trans_write()
3596 buf[0] = cpu_to_le32(p->filename_trans.nel); in filename_trans_write()
3601 rc = hashtab_map(&p->filename_trans, filename_write_helper, fp); in filename_trans_write()
3611 int policydb_write(struct policydb *p, void *fp) in policydb_write() argument
3626 if (p->policyvers < POLICYDB_VERSION_AVTAB) { in policydb_write()
3628 " Because it is less than version %d\n", p->policyvers, in policydb_write()
3634 if (p->mls_enabled) in policydb_write()
3637 if (p->reject_unknown) in policydb_write()
3639 if (p->allow_unknown) in policydb_write()
3654 info = policydb_lookup_compat(p->policyvers); in policydb_write()
3657 "version %d\n", p->policyvers); in policydb_write()
3661 buf[0] = cpu_to_le32(p->policyvers); in policydb_write()
3670 if (p->policyvers >= POLICYDB_VERSION_POLCAP) { in policydb_write()
3671 rc = ebitmap_write(&p->policycaps, fp); in policydb_write()
3676 if (p->policyvers >= POLICYDB_VERSION_PERMISSIVE) { in policydb_write()
3677 rc = ebitmap_write(&p->permissive_map, fp); in policydb_write()
3687 pd.p = p; in policydb_write()
3689 buf[0] = cpu_to_le32(p->symtab[i].nprim); in policydb_write()
3690 buf[1] = cpu_to_le32(p->symtab[i].table.nel); in policydb_write()
3695 rc = hashtab_map(&p->symtab[i].table, write_f[i], &pd); in policydb_write()
3700 rc = avtab_write(p, &p->te_avtab, fp); in policydb_write()
3704 rc = cond_write_list(p, fp); in policydb_write()
3708 rc = role_trans_write(p, fp); in policydb_write()
3712 rc = role_allow_write(p->role_allow, fp); in policydb_write()
3716 rc = filename_trans_write(p, fp); in policydb_write()
3720 rc = ocontext_write(p, info, fp); in policydb_write()
3724 rc = genfs_write(p, fp); in policydb_write()
3728 rc = range_write(p, fp); in policydb_write()
3732 for (i = 0; i < p->p_types.nprim; i++) { in policydb_write()
3733 struct ebitmap *e = &p->type_attr_map_array[i]; in policydb_write()