static void setuse(Sym *s, Sym *s0, Use *u) { Sym *s1; s1 = u->p->from.sym; if(u->ct == nil){ /* in data area */ for(u = s1->use; u != U; u = u->link) setuse(s1, s0, u); } else{ /* in text area */ setfpuse(u->p, s0, s); } }
/* detect BX O(R) which can be done as BL O(R) */ void fnptrs() { int i; Sym *s; Prog *p; Use *u; for(i=0; i<NHASH; i++){ for(s = hash[i]; s != S; s = s->link){ if(s->fnptr && (s->type == STEXT || s->type == SLEAF || s->type == SCONST)){ // print("%s : fnptr %d %d\n", s->name, s->thumb, s->foreign); } } } /* record use of syms */ for(p = firstp; p != P; p = p->link){ if(p->as == ATEXT) curtext = p; else{ fused(&p->from, p, curtext); fused(&p->to, p, curtext); } } for(p = datap; p != P; p = p->link) fused(&p->to, p, nil); /* now look for fn ptrs */ for(i=0; i<NHASH; i++){ for(s = hash[i]; s != S; s = s->link){ if(s->fnptr && (s->type == STEXT || s->type == SLEAF || s->type == SCONST)){ for(u = s->use; u != U; u = u->link){ if(!ckuse(s, s, u)) break; } if(u == U){ // can simplify for(u = s->use; u != U; u = u->link) setuse(s, s, u); } } } } /* now free Use structures */ }
/* * Do operations associated with quotas */ int ufs_quotactl(struct mount *mp, int cmds, uid_t uid, void *arg) { struct lwp *l = curlwp; #ifndef QUOTA (void) mp; (void) cmds; (void) uid; (void) arg; (void) l; return (EOPNOTSUPP); #else int cmd, type, error; if (uid == -1) uid = kauth_cred_getuid(l->l_cred); cmd = cmds >> SUBCMDSHIFT; switch (cmd) { case Q_SYNC: break; case Q_GETQUOTA: if (uid == kauth_cred_getuid(l->l_cred)) break; /* fall through */ default: if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, NULL)) != 0) return (error); } type = cmds & SUBCMDMASK; if ((u_int)type >= MAXQUOTAS) return (EINVAL); error = vfs_busy(mp, NULL); if (error != 0) return (error); mutex_enter(&mp->mnt_updating); switch (cmd) { case Q_QUOTAON: error = quotaon(l, mp, type, arg); break; case Q_QUOTAOFF: error = quotaoff(l, mp, type); break; case Q_SETQUOTA: error = setquota(mp, uid, type, arg); break; case Q_SETUSE: error = setuse(mp, uid, type, arg); break; case Q_GETQUOTA: error = getquota(mp, uid, type, arg); break; case Q_SYNC: error = qsync(mp); break; default: error = EINVAL; } mutex_exit(&mp->mnt_updating); vfs_unbusy(mp, false, NULL); return (error); #endif }