static Ctlr* newctlr(char *path) { Ctlr *c; if(ctlrlookup(path)) error(Eexist); if((c = malloc(sizeof *c)) == nil) error(Enomem); if(waserror()){ free(c); nexterror(); } c->c = namec(path, Aopen, ORDWR, 0); poperror(); kstrcpy(c->path, path, sizeof c->path); lock(&ctlrlock); if(head != nil) tail->next = c; else head = c; tail = c; unlock(&ctlrlock); return c; }
static SDev* loopprobew(DevConf *c) { char *p; p = strchr(c->type, '/'); if(p == nil || strlen(p) > Maxpath - 1) error(Ebadarg); p++; if(ctlrlookup(p)) error(Einuse); return probe(p, 0); }
static SDev* aoeprobew(DevConf *c) { char *p; p = strchr(c->type, '/'); if(p == nil || strlen(p) > Maxpath - 11) error(Ebadarg); if(p[1] == '#') p++; /* hack */ if(ctlrlookup(p)) error(Einuse); return aoeprobe(p, 0); }
static Ctlr* newctlr(char *path) { Ctlr *c; if(ctlrlookup(path)) error(Eexist); if((c = malloc(sizeof *c)) == nil) return 0; kstrcpy(c->path, path, sizeof c->path); lock(&ctlrlock); if(head != nil) tail->next = c; else head = c; tail = c; unlock(&ctlrlock); return c; }