Skip to content

Commit 5547228

Browse files
committed
Add support for mount export for fuse-nfs
It wants to list the exported file systems, for mount. But currently the nullauth ignores the dirpath anyway. Signed-off-by: Anders F Björklund <[email protected]>
1 parent 7070f5a commit 5547228

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type Handler interface {
2020

2121
// Optional methods - generic helpers or trivial implementations can be sufficient depending on use case.
2222

23+
// List of all exported file systems.
24+
Export(context.Context) []Export
25+
2326
// Fill in information about a file system's free space.
2427
FSStat(context.Context, billy.Filesystem, *FSStat) error
2528

helpers/nullauthhandler.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ func (h *NullAuthHandler) Change(fs billy.Filesystem) billy.Change {
3434
return nil
3535
}
3636

37+
// List of all exported file systems.
38+
func (h *NullAuthHandler) Export(context.Context) []nfs.Export {
39+
return []nfs.Export{{Dir: []byte("/mount")}}
40+
}
41+
3742
// FSStat provides information about a filesystem.
3843
func (h *NullAuthHandler) FSStat(ctx context.Context, f billy.Filesystem, s *nfs.FSStat) error {
3944
return nil

mount.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func init() {
1515
_ = RegisterMessageHandler(mountServiceID, uint32(MountProcNull), onMountNull)
1616
_ = RegisterMessageHandler(mountServiceID, uint32(MountProcMount), onMount)
1717
_ = RegisterMessageHandler(mountServiceID, uint32(MountProcUmnt), onUMount)
18+
_ = RegisterMessageHandler(mountServiceID, uint32(MountProcExport), onMountExport)
1819
}
1920

2021
func onMountNull(ctx context.Context, w *response, userHandle Handler) error {
@@ -56,3 +57,18 @@ func onUMount(ctx context.Context, w *response, userHandle Handler) error {
5657

5758
return w.writeHeader(ResponseCodeSuccess)
5859
}
60+
61+
func onMountExport(ctx context.Context, w *response, userHandle Handler) error {
62+
exports := userHandle.Export(ctx)
63+
64+
if err := w.writeHeader(ResponseCodeSuccess); err != nil {
65+
return err
66+
}
67+
68+
writer := bytes.NewBuffer([]byte{})
69+
70+
if err := xdr.Write(writer, exports); err != nil {
71+
return err
72+
}
73+
return w.Write(writer.Bytes())
74+
}

mountinterface.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,16 @@ type MountResponse struct {
8888
FileHandle
8989
AuthFlavors []int
9090
}
91+
92+
// Group contains a group node, with information about the allowed access group.
93+
type Group struct {
94+
Name []byte
95+
Next []Group
96+
}
97+
98+
// Export contains an export node, with information about an exported filesystem.
99+
type Export struct {
100+
Dir []byte
101+
Groups []Group
102+
Next []Export
103+
}

0 commit comments

Comments
 (0)