mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 08:55:43 +03:00
* Move task directory destroy logic from alloc_dir to task_dir * Update errors to wrap error cause * Use constants for file permissions * Make multierror handling consistent. * Make helpers for directory creation * Move mount dir unlink to task_dir Unlink method * Make constant for file mode 710 Co-authored-by: Tim Gross <tgross@hashicorp.com> Co-authored-by: Michael Schurter <mschurter@hashicorp.com>
30 lines
645 B
Go
30 lines
645 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package allocdir
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// linkDir hardlinks src to dst. The src and dst must be on the same filesystem.
|
|
func linkDir(src, dst string) error {
|
|
return syscall.Link(src, dst)
|
|
}
|
|
|
|
// unlinkDir removes a directory link.
|
|
func unlinkDir(dir string) error {
|
|
return syscall.Unlink(dir)
|
|
}
|
|
|
|
// createSecretDir creates the secrets dir folder at the given path
|
|
func createSecretDir(dir string) error {
|
|
return os.MkdirAll(dir, fileMode777)
|
|
}
|
|
|
|
// removeSecretDir removes the secrets dir folder
|
|
func removeSecretDir(dir string) error {
|
|
return os.RemoveAll(dir)
|
|
}
|