fusefrontend: Improve documentation of mkdirWithIv and WriteDirIV
As requested in https://github.com/rfjakob/gocryptfs/pull/179
This commit is contained in:
parent
e97c23e083
commit
9bcde0c09e
|
@ -24,6 +24,9 @@ import (
|
||||||
|
|
||||||
const dsStoreName = ".DS_Store"
|
const dsStoreName = ".DS_Store"
|
||||||
|
|
||||||
|
// mkdirWithIv - create a new directory and corresponding diriv file. dirfd
|
||||||
|
// should be a handle to the parent directory, cName is the name of the new
|
||||||
|
// directory and mode specifies the access permissions to use.
|
||||||
func (fs *FS) mkdirWithIv(dirfd *os.File, cName string, mode uint32) error {
|
func (fs *FS) mkdirWithIv(dirfd *os.File, cName string, mode uint32) error {
|
||||||
// Between the creation of the directory and the creation of gocryptfs.diriv
|
// Between the creation of the directory and the creation of gocryptfs.diriv
|
||||||
// the directory is inconsistent. Take the lock to prevent other readers
|
// the directory is inconsistent. Take the lock to prevent other readers
|
||||||
|
|
|
@ -3,6 +3,7 @@ package nametransform
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -73,10 +74,16 @@ func fdReadDirIV(fd *os.File) (iv []byte, err error) {
|
||||||
return iv, nil
|
return iv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteDirIV - create diriv file inside "dir" (absolute ciphertext path)
|
// WriteDirIV - create diriv file inside of the specified directory. If dirfd
|
||||||
// This function is exported because it is used from pathfs_frontend, main,
|
// is nil "dir" should be the absolute path to the directory. If dirfd != nil
|
||||||
// and also the automated tests.
|
// "dir" should be a path (without slashes) relative to the directory
|
||||||
|
// described by "dirfd". This function is exported because it is used from
|
||||||
|
// pathfs_frontend, main, and also the automated tests.
|
||||||
func WriteDirIV(dirfd *os.File, dir string) error {
|
func WriteDirIV(dirfd *os.File, dir string) error {
|
||||||
|
// For relative paths we do not expect that "dir" contains slashes
|
||||||
|
if dirfd != nil && strings.Contains(dir, "/") {
|
||||||
|
log.Panicf("WriteDirIV: Relative path should not contain slashes: %v", dir)
|
||||||
|
}
|
||||||
iv := cryptocore.RandBytes(DirIVLen)
|
iv := cryptocore.RandBytes(DirIVLen)
|
||||||
file := filepath.Join(dir, DirIVFilename)
|
file := filepath.Join(dir, DirIVFilename)
|
||||||
// 0400 permissions: gocryptfs.diriv should never be modified after creation.
|
// 0400 permissions: gocryptfs.diriv should never be modified after creation.
|
||||||
|
|
Loading…
Reference in New Issue