]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: accept pre-existing directories in nacl zip file
authorRuss Cox <rsc@golang.org>
Tue, 28 Oct 2014 00:45:16 +0000 (20:45 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 28 Oct 2014 00:45:16 +0000 (20:45 -0400)
NaCl creates /tmp. This lets the zip file populate it.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/159600043

src/syscall/fs_nacl.go

index 4abc9b81c92085b5991e256d0420c6c38e2e1a0e..6e6ce2ab7bc186bf6fe65c0893e7247a79a14d1f 100644 (file)
@@ -818,6 +818,12 @@ func create(name string, mode uint32, sec int64, data []byte) error {
        fs.mu.Unlock()
        f, err := fs.open(name, O_CREATE|O_EXCL, mode)
        if err != nil {
+               if mode&S_IFMT == S_IFDIR {
+                       ip, _, err := fs.namei(name, false)
+                       if err == nil && (ip.Mode&S_IFMT) == S_IFDIR {
+                               return nil // directory already exists
+                       }
+               }
                return err
        }
        ip := f.(*fsysFile).inode