/* * Returns a bitmap of valid interface numbers. */ uintptr_t security_check(struct pd *pd, uintptr_t ref) { cap_t cap; struct clist *clist; struct clist_node *clists; int i; uintptr_t interfaces = 0; cap_t *p; if (pd == NULL) { return 0; } cap.ref.obj = ref; for (clists = pd->clists.first; clists->next != pd->clists.first; clists = clists->next) { clist = clists->data.clist; p = bsearch(&cap, clist->cap, clist->used, sizeof(cap_t), refcmp); if (p == NULL) { continue; } i = p - clist->cap; /* Find the first matching cap in the list. */ for (; i > 0; i--) { if (refcmp(&ref, &clist->cap[i - 1]) != 0) { break; } } /* Add in all the rights in this list. */ for (; i < clist->used; i++) { if (refcmp(&ref, &clist->cap[i]) != 0) { break; } if ((clist->cap[i].ref.obj & IID_MASK) == MASTER_IID) { interfaces |= ~0UL; break; } interfaces |= (1UL << (clist->cap[i].ref.obj & IID_MASK)); } } #ifdef ENABLE_CAPS return interfaces; #else return ~0UL; #endif }
void dotest(int nrows, int ncols, int *xys) { BITMAT *inp = bitmat(nrows, ncols); BITMAT *exp = bitmat(ncols, nrows); for (; *xys >= 0; xys += 2) { bitmat_set(inp, xys[0] % nrows, xys[1] % ncols, 1); bitmat_set(exp, xys[1] % ncols, xys[0] % nrows, 1); } BITMAT *act = bitmat_trans(inp); int rc = refcmp(bitmat_ref(act), bitmat_ref(exp)); ok(!rc, "trans %d x %d", nrows, ncols); if (rc) { puts("expected:"); prbm(exp); puts("actual:"); prbm(act); } bitmat_destroy(inp); bitmat_destroy(exp); bitmat_destroy(act); }