tunvac, vacfs: allow literal vac scores in addition to file names - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 70c9f86c100042ce308bc53e63c72f36be5e7f86
parent 405d555fe44ab53be9887fd2765f05a4501cf756
Author: Russ Cox 
Date:   Sat, 14 Jun 2008 13:41:07 -0400

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

Diffstat:
  M src/cmd/vac/fs.c                    |      24 +++++++++++++++---------

1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/cmd/vac/fs.c b/src/cmd/vac/fs.c
t@@ -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);
 }