Skip to content

Commit b02a94e

Browse files
committed
fix: skip fuse check when kernel is WSL2
Signed-off-by: NaturalSelect <[email protected]>
1 parent a13b532 commit b02a94e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

internal/task/step/shell.go

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"os"
3030
"strings"
3131

32+
comm "github.com/opencurve/curveadm/internal/common"
3233
"github.com/opencurve/curveadm/internal/errno"
3334
"github.com/opencurve/curveadm/internal/task/context"
3435
"github.com/opencurve/curveadm/internal/utils"
@@ -475,6 +476,15 @@ func (s *UnixName) Execute(ctx *context.Context) error {
475476
}
476477

477478
func (s *ModInfo) Execute(ctx *context.Context) error {
479+
isWsl2, err := ctx.Module().Shell().IsWsl2()
480+
if err == nil && isWsl2 {
481+
// NOTE: FUSE is statically compiled into the WSL2 kernel
482+
// See also: https://github.com/microsoft/WSL/issues/17#issuecomment-759817472
483+
if s.Name == comm.KERNERL_MODULE_FUSE {
484+
*s.Success = true
485+
return nil
486+
}
487+
}
478488
cmd := ctx.Module().Shell().ModInfo(s.Name)
479489
out, err := cmd.Execute(s.ExecOptions)
480490
return PostHandle(s.Success, s.Out, out, err, errno.ERR_GET_KERNEL_MODULE_INFO_FAILED)

pkg/module/shell.go

+12
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ func (s *Shell) Execute(options ExecOptions) (string, error) {
112112
return execCommand(s.sshClient, s.tmpl, s.data, options)
113113
}
114114

115+
func (s *Shell) IsWsl2() (isWsl2 bool, err error) {
116+
cmd := s.Command("uname -a | grep \"WSL2\" | wc -l")
117+
out, err := cmd.Execute(ExecOptions{})
118+
if err != nil {
119+
return
120+
}
121+
if out != "" && out[0] == '1' {
122+
isWsl2 = true
123+
}
124+
return
125+
}
126+
115127
// text
116128
func (s *Shell) Sed(file ...string) *Shell {
117129
s.tmpl = template.Must(template.New("sed").Parse(TEMPLATE_SED))

0 commit comments

Comments
 (0)