unvac, vacfs: allow literal vac scores in addition to file names

This commit is contained in:
Russ Cox 2008-06-14 13:41:07 -04:00
parent 405d555fe4
commit 70c9f86c10

View file

@ -49,17 +49,23 @@ vacfsopen(VtConn *z, char *file, int mode, int ncache)
{
int fd;
uchar score[VtScoreSize];
fd = open(file, OREAD);
if(fd < 0)
return nil;
if(readscore(fd, score) < 0){
char *prefix;
if(vtparsescore(file, &prefix, score) >= 0){
if(strcmp(prefix, "vac") != 0){
werrstr("not a vac file");
return nil;
}
}else{
fd = open(file, OREAD);
if(fd < 0)
return nil;
if(readscore(fd, score) < 0){
close(fd);
return nil;
}
close(fd);
return nil;
}
close(fd);
return vacfsopenscore(z, score, mode, ncache);
}