fix(nfs): move fsid=N inside client parentheses in /etc/exports

exportfs parses 'path host(flags) fsid=N' as a separate fsid= token
without host or options, causing 'No options for path fsid=N' errors.
The correct format puts fsid=N inside the host parentheses:
  /path host(flags,fsid=N)

Changes:
- clientFlags(c, fsid) now appends fsid=N at the end
- buildExportFlags(e, fsid) same
- buildExportLine removed buildExportSuffix call; fsid is now per-client
- Removed now-unused buildExportSuffix function

Version: 0.5.3
This commit is contained in:
2026-07-06 12:20:35 -04:00
parent d380cad36d
commit 3e290164c5
3 changed files with 17 additions and 19 deletions
+6 -6
View File
@@ -24,7 +24,7 @@ func TestBuildExportLine(t *testing.T) {
FSID: 1,
Advanced: "{}",
},
lines: []string{`/srv/nfs/shared 192.168.1.100(rw,sync,root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide) fsid=1`},
lines: []string{`/srv/nfs/shared 192.168.1.100(rw,sync,root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide,fsid=1)`},
},
{
name: "multiple hosts different options",
@@ -42,7 +42,7 @@ func TestBuildExportLine(t *testing.T) {
Advanced: "{}",
},
lines: []string{
`/srv/nfs/shared 192.168.1.0/24(rw,sync,root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide,crossmnt) 10.0.0.5(ro,async,no_root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide) fsid=2`,
`/srv/nfs/shared 192.168.1.0/24(rw,sync,root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide,crossmnt,fsid=2) 10.0.0.5(ro,async,no_root_squash,no_subtree_check,no_all_squash,insecure,no_wdelay,nohide,fsid=2)`,
},
},
{
@@ -57,7 +57,7 @@ func TestBuildExportLine(t *testing.T) {
FSID: 3,
Advanced: "{}",
},
lines: []string{`/srv/nfs/public *(ro,sync,root_squash,no_subtree_check) fsid=3`},
lines: []string{`/srv/nfs/public *(ro,sync,root_squash,no_subtree_check,fsid=3)`},
},
{
name: "advanced options per host",
@@ -74,7 +74,7 @@ func TestBuildExportLine(t *testing.T) {
Advanced: "{}",
},
lines: []string{
`/srv/nfs/secure 192.168.1.0/24(rw,sync,root_squash,no_subtree_check,all_squash,secure,wdelay,hide,crossmnt) fsid=4`,
`/srv/nfs/secure 192.168.1.0/24(rw,sync,root_squash,no_subtree_check,all_squash,secure,wdelay,hide,crossmnt,fsid=4)`,
},
},
}
@@ -101,8 +101,8 @@ func TestClientFlags(t *testing.T) {
SubtreeCheck: true,
Advanced: db.NFSAdvanced{AllSquash: true, Secure: true},
}
flags := clientFlags(c)
if flags != "ro,async,no_root_squash,subtree_check,all_squash,secure,no_wdelay,nohide" {
flags := clientFlags(c, 42)
if flags != "ro,async,no_root_squash,subtree_check,all_squash,secure,no_wdelay,nohide,fsid=42" {
t.Errorf("clientFlags() = %q, unexpected flags", flags)
}
}