-/*
- * Journal of label operations that occur before policies are loaded.
- */
-struct mac_label_journal_list_t mac_label_journal_list;
-
-int
-mac_label_journal_add (struct label *l, int type)
-{
- struct mac_label_journal *mlj;
-
- if (mac_label_journal_find(l))
- return (0);
-
- MALLOC(mlj, struct mac_label_journal *,
- sizeof(struct mac_label_journal), M_MACTEMP, M_WAITOK);
- mlj->l = l;
- mlj->type = type;
- TAILQ_INSERT_TAIL(&mac_label_journal_list, mlj, link);
-
- return (0);
-}
-
-int
-mac_label_journal_remove (struct label *l)
-{
- struct mac_label_journal *mlj;
-
- mlj = mac_label_journal_find(l);
- if (mlj == NULL)
- return (-1);
-
- TAILQ_REMOVE(&mac_label_journal_list, mlj, link);
- FREE(mlj, M_MACTEMP);
- return (0);
-}
-
-struct mac_label_journal *
-mac_label_journal_find (struct label *l)
-{
- struct mac_label_journal *mlj;
-
- TAILQ_FOREACH(mlj, &mac_label_journal_list, link) {
- if (l == mlj->l)
- return (mlj);
- }
-
- return (NULL);
-}
-
-int
-mac_label_journal (struct label *l, int op, ...)
-{
- struct mac_label_journal *mlj;
- va_list ap;
-
- mlj = mac_label_journal_find(l);
- if (mlj == NULL) {
- printf("%s(): Label not in list!\n", __func__);
- return (-1);
- }
-
- if (op == MLJ_PORT_OP_UPDATE) {
- va_start(ap, op);
- mlj->kotype = va_arg(ap, int);
- va_end(ap);
- }
-
- mlj->ops |= op;
- return (0);
-}
-
-/*
- * The assumption during replay is that the system is totally
- * serialized and no additional tasks/ports will be created.
- */
-void
-mac_label_journal_replay (void)
-{
- struct mac_label_journal *mlj;
-
- TAILQ_FOREACH(mlj, &mac_label_journal_list, link) {
- switch (mlj->type) {
- case MLJ_TYPE_PORT:
- if (mlj->ops & MLJ_PORT_OP_INIT)
- MAC_PERFORM(port_label_init, mlj->l);
- if (mlj->ops & MLJ_PORT_OP_CREATE_K)
- MAC_PERFORM(port_label_associate_kernel, mlj->l, 0);
- if (mlj->ops & MLJ_PORT_OP_UPDATE)
- MAC_PERFORM(port_label_update_kobject, mlj->l,
- mlj->kotype);
- break;
- case MLJ_TYPE_TASK:
- if (mlj->ops & MLJ_TASK_OP_INIT)
- MAC_PERFORM(task_label_init, mlj->l);
-#if 0
- /* Not enough context to replay. */
- if (mlj->ops & MLJ_TASK_OP_CREATE_K)
- ;
-#endif
- break;
- default:
- break;
- }
- }
-
- /* Free list */
- while (!TAILQ_EMPTY(&mac_label_journal_list)) {
- mlj = TAILQ_FIRST(&mac_label_journal_list);
- TAILQ_REMOVE(&mac_label_journal_list, mlj, link);
- FREE(mlj, M_MACTEMP);
- }
- return;
-}
-