/
alias.go
41 lines (33 loc) · 1.03 KB
/
alias.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2016 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
//
//go:build !windows
// +build !windows
package libfuse
import (
"os"
"bazil.org/fuse"
"bazil.org/fuse/fs"
"golang.org/x/net/context"
)
// Alias represents an alias. A use case for it is a top-level folder accessed
// through its non-canonical name.
type Alias struct {
// The real path this alias points to. In case of TLF alias, this is the
// canonical name for the folder.
realPath string
inode uint64
}
var _ fs.Node = (*Alias)(nil)
// Attr implements the fs.Node interface for Alias.
func (*Alias) Attr(ctx context.Context, a *fuse.Attr) error {
a.Mode = os.ModeSymlink | 0777
// Aliases can't be moved, so let bazil generate an inode.
return nil
}
var _ fs.NodeReadlinker = (*Alias)(nil)
// Readlink implements the fs.NodeReadlinker interface for Alias.
func (a *Alias) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
return a.realPath, nil
}