mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 22:15:51 +00:00
abab0d4197
- Restyles tailfs -> tailFS - Defines interfaces for main TailFS types - Moves implemenatation of TailFS into tailfsimpl package Updates tailscale/corp#16827 Signed-off-by: Percy Wegmann <percy@tailscale.com>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package compositefs
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"tailscale.com/tailfs/tailfsimpl/shared"
|
|
)
|
|
|
|
// Mkdir implements webdav.Filesystem. The root of this file system is
|
|
// read-only, so any attempts to make directories within the root will fail
|
|
// with os.ErrPermission. Attempts to make directories within one of the child
|
|
// filesystems will be handled by the respective child.
|
|
func (cfs *CompositeFileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error {
|
|
if shared.IsRoot(name) {
|
|
// root directory already exists, consider this okay
|
|
return nil
|
|
}
|
|
|
|
pathInfo, err := cfs.pathInfoFor(name)
|
|
if pathInfo.refersToChild {
|
|
// children can't be made
|
|
if pathInfo.child != nil {
|
|
// since child already exists, consider this okay
|
|
return nil
|
|
}
|
|
// since child doesn't exist, return permission error
|
|
return os.ErrPermission
|
|
}
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return pathInfo.child.FS.Mkdir(ctx, pathInfo.pathOnChild, perm)
|
|
}
|