99 "os"
1010
1111 "github.com/lima-vm/lima/pkg/limayaml"
12- "github.com/lima-vm/lima/pkg/localpathutil"
1312 "github.com/lima-vm/sshocker/pkg/reversesshfs"
1413 "github.com/sirupsen/logrus"
1514)
@@ -35,16 +34,7 @@ func (a *HostAgent) setupMounts() ([]*mount, error) {
3534}
3635
3736func (a * HostAgent ) setupMount (m limayaml.Mount ) (* mount , error ) {
38- location , err := localpathutil .Expand (m .Location )
39- if err != nil {
40- return nil , err
41- }
42-
43- mountPoint , err := localpathutil .Expand (* m .MountPoint )
44- if err != nil {
45- return nil , err
46- }
47- if err := os .MkdirAll (location , 0o755 ); err != nil {
37+ if err := os .MkdirAll (m .Location , 0o755 ); err != nil {
4838 return nil , err
4939 }
5040 // NOTE: allow_other requires "user_allow_other" in /etc/fuse.conf
@@ -55,35 +45,35 @@ func (a *HostAgent) setupMount(m limayaml.Mount) (*mount, error) {
5545 if * m .SSHFS .FollowSymlinks {
5646 sshfsOptions += ",follow_symlinks"
5747 }
58- logrus .Infof ("Mounting %q on %q" , location , mountPoint )
48+ logrus .Infof ("Mounting %q on %q" , m . Location , * m . MountPoint )
5949
6050 rsf := & reversesshfs.ReverseSSHFS {
6151 Driver : * m .SSHFS .SFTPDriver ,
6252 SSHConfig : a .sshConfig ,
63- LocalPath : location ,
53+ LocalPath : m . Location ,
6454 Host : "127.0.0.1" ,
6555 Port : a .sshLocalPort ,
66- RemotePath : mountPoint ,
56+ RemotePath : * m . MountPoint ,
6757 Readonly : ! (* m .Writable ),
6858 SSHFSAdditionalArgs : []string {"-o" , sshfsOptions },
6959 }
7060 if err := rsf .Prepare (); err != nil {
71- return nil , fmt .Errorf ("failed to prepare reverse sshfs for %q on %q: %w" , location , mountPoint , err )
61+ return nil , fmt .Errorf ("failed to prepare reverse sshfs for %q on %q: %w" , m . Location , * m . MountPoint , err )
7262 }
7363 if err := rsf .Start (); err != nil {
74- logrus .WithError (err ).Warnf ("failed to mount reverse sshfs for %q on %q, retrying with `-o nonempty`" , location , mountPoint )
64+ logrus .WithError (err ).Warnf ("failed to mount reverse sshfs for %q on %q, retrying with `-o nonempty`" , m . Location , * m . MountPoint )
7565 // NOTE: nonempty is not supported for libfuse3: https://github.com/canonical/multipass/issues/1381
7666 rsf .SSHFSAdditionalArgs = []string {"-o" , "nonempty" }
7767 if err := rsf .Start (); err != nil {
78- return nil , fmt .Errorf ("failed to mount reverse sshfs for %q on %q: %w" , location , mountPoint , err )
68+ return nil , fmt .Errorf ("failed to mount reverse sshfs for %q on %q: %w" , m . Location , * m . MountPoint , err )
7969 }
8070 }
8171
8272 res := & mount {
8373 close : func () error {
84- logrus .Infof ("Unmounting %q" , location )
85- if closeErr := rsf .Close (); closeErr != nil {
86- return fmt .Errorf ("failed to unmount reverse sshfs for %q on %q: %w" , location , mountPoint , err )
74+ logrus .Infof ("Unmounting %q" , m . Location )
75+ if err := rsf .Close (); err != nil {
76+ return fmt .Errorf ("failed to unmount reverse sshfs for %q on %q: %w" , m . Location , * m . MountPoint , err )
8777 }
8878 return nil
8979 },
0 commit comments