v2api: Node: make Path() public

Helpful for fsck.
This commit is contained in:
Jakob Unterwurzacher 2020-07-18 23:06:22 +02:00
parent 7eae35e2d3
commit 6b7ff09373
2 changed files with 7 additions and 7 deletions

View File

@ -22,9 +22,9 @@ type Node struct {
fs.Inode fs.Inode
} }
// path returns the relative plaintext path of this node // Path returns the relative plaintext path of this node
func (n *Node) path() string { func (n *Node) Path() string {
return n.Path(n.Root()) return n.Inode.Path(n.Root())
} }
// rootNode returns the Root Node of the filesystem. // rootNode returns the Root Node of the filesystem.
@ -40,7 +40,7 @@ func (n *Node) rootNode() *RootNode {
// a child of this node. // a child of this node.
// If `child` is empty, the (dirfd, cName) pair refers to this node itself. // If `child` is empty, the (dirfd, cName) pair refers to this node itself.
func (n *Node) prepareAtSyscall(child string) (dirfd int, cName string, errno syscall.Errno) { func (n *Node) prepareAtSyscall(child string) (dirfd int, cName string, errno syscall.Errno) {
p := n.path() p := n.Path()
if child != "" { if child != "" {
p = filepath.Join(p, child) p = filepath.Join(p, child)
} }

View File

@ -55,7 +55,7 @@ func (n *Node) mkdirWithIv(dirfd int, cName string, mode uint32, caller *fuse.Ca
// Symlink-safe through use of Mkdirat(). // Symlink-safe through use of Mkdirat().
func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) { func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
rn := n.rootNode() rn := n.rootNode()
newPath := filepath.Join(n.path(), name) newPath := filepath.Join(n.Path(), name)
if rn.isFiltered(newPath) { if rn.isFiltered(newPath) {
return nil, syscall.EPERM return nil, syscall.EPERM
} }
@ -147,7 +147,7 @@ func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.En
// ReadDirIVAt(). // ReadDirIVAt().
func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) { func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
rn := n.rootNode() rn := n.rootNode()
p := n.path() p := n.Path()
dirName := filepath.Base(p) dirName := filepath.Base(p)
parentDirFd, cDirName, err := rn.openBackingDir(p) parentDirFd, cDirName, err := rn.openBackingDir(p)
if err != nil { if err != nil {
@ -232,7 +232,7 @@ func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
// Symlink-safe through Unlinkat() + AT_REMOVEDIR. // Symlink-safe through Unlinkat() + AT_REMOVEDIR.
func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno) { func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno) {
rn := n.rootNode() rn := n.rootNode()
p := filepath.Join(n.path(), name) p := filepath.Join(n.Path(), name)
parentDirFd, cName, err := rn.openBackingDir(p) parentDirFd, cName, err := rn.openBackingDir(p)
if err != nil { if err != nil {
return fs.ToErrno(err) return fs.ToErrno(err)