ref: 4ea3a16c31fb04f4df946b96a675133ee9589490
parent: ae0332732284dfd9d8503094d64669fa8939d137
parent: f9d32f7c16bc2762bd688ce88db273739a814b6c
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Dec 1 21:38:13 EST 2023
merge
--- a/cons.c
+++ b/cons.c
@@ -320,13 +320,14 @@
buf[n] = 0;
nf = tokenize(buf, f, nelem(f));
if(nf == 0 || strlen(f[0]) == 0)
- continue;
+ goto Next;
for(c = cmdtab; c->name != nil; c++){
ap = f;
na = nf;
if(strcmp(c->name, *ap) != 0)
continue;
- ap++; na--;
+ ap++;
+ na--;
if(c->sub != nil){
if(na == 0 || strcmp(c->sub, *ap) != 0)
continue;
@@ -344,6 +345,7 @@
fprint(fd, " %s", f[i]);
fprint(fd, "'\n");
}
+Next:
epochend(tid);
}
}
--- a/fs.c
+++ b/fs.c
@@ -453,19 +453,22 @@
ainc(&fs->snapmnt->ref);
return fs->snapmnt;
}
+
lock(&fs->mountlk);
- if(waserror()){
- unlock(&fs->mountlk);
- free(mnt);
- return nil;
- }
- for(mnt = fs->mounts; mnt != nil; mnt = mnt->next)
+ for(mnt = fs->mounts; mnt != nil; mnt = mnt->next){
if(strcmp(name, mnt->name) == 0){
ainc(&mnt->ref);
goto Out;
}
+ }
+
if((mnt = mallocz(sizeof(*mnt), 1)) == nil)
- goto Out;
+ error(Enomem);
+ if(waserror()){
+ unlock(&fs->mountlk);
+ free(mnt);
+ nexterror();
+ }
mnt->ref = 1;
snprint(mnt->name, sizeof(mnt->name), "%s", name);
if((t = opensnap(name, &mnt->mutable)) == nil)
@@ -474,10 +477,10 @@
mnt->root = t;
mnt->next = fs->mounts;
fs->mounts = mnt;
+ poperror();
Out:
unlock(&fs->mountlk);
- poperror();
return mnt;
}