Skip to content

Commit 48ae4f3

Browse files
committed
update. fuse
1 parent 32ae274 commit 48ae4f3

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

internal/app/lsshfs/app.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ var (
3636

3737
const backgroundReadyTimeout = 15 * time.Second
3838

39+
func debugLogPath(mountpoint string) string {
40+
dir, err := mountfs.StateFilePath(mountpoint)
41+
if err != nil || strings.TrimSpace(dir) == "" {
42+
return ""
43+
}
44+
return strings.TrimSuffix(dir, filepath.Ext(dir)) + ".debug.log"
45+
}
46+
3947
func Lsshfs() (app *cli.App) {
4048
defConf := common.GetDefaultConfigPath()
4149

@@ -235,6 +243,13 @@ func spawnBackgroundProcess(selectedHost string, appendHostFlag bool) error {
235243

236244
cmd := exec.Command(exe, args...)
237245
cmd.Env = append(os.Environ(), "_LSSHFS_DAEMON=1")
246+
if os.Getenv("LSSHFS_DEBUG") == "1" {
247+
if len(args) > 0 {
248+
if logPath := debugLogPath(args[len(args)-1]); logPath != "" {
249+
cmd.Env = append(cmd.Env, "LSSHFS_DEBUG_LOG="+logPath, "GO_SSHLIB_DEBUG_LOG="+logPath)
250+
}
251+
}
252+
}
238253
if readyPath != "" {
239254
cmd.Env = append(cmd.Env, "_LSSHFS_READY_FILE="+readyPath)
240255
}
@@ -268,6 +283,11 @@ func spawnBackgroundProcess(selectedHost string, appendHostFlag bool) error {
268283
_ = rpipe.Close()
269284
if n > 0 {
270285
fmt.Fprintf(os.Stderr, "Mounted in background (pid %d)\n", pid)
286+
if os.Getenv("LSSHFS_DEBUG") == "1" && len(args) > 0 {
287+
if logPath := debugLogPath(args[len(args)-1]); logPath != "" {
288+
fmt.Fprintf(os.Stderr, "Debug log: %s\n", logPath)
289+
}
290+
}
271291
os.Exit(0)
272292
}
273293
return fmt.Errorf("background start failed")
@@ -278,6 +298,11 @@ func spawnBackgroundProcess(selectedHost string, appendHostFlag bool) error {
278298
}
279299

280300
fmt.Fprintf(os.Stderr, "Mounted in background (pid %d)\n", pid)
301+
if os.Getenv("LSSHFS_DEBUG") == "1" && len(args) > 0 {
302+
if logPath := debugLogPath(args[len(args)-1]); logPath != "" {
303+
fmt.Fprintf(os.Stderr, "Debug log: %s\n", logPath)
304+
}
305+
}
281306
os.Exit(0)
282307
return nil
283308
}

internal/lsshfs/runner.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ func (r *Runner) debugf(format string, args ...interface{}) {
6767
if !r.debugEnabled() {
6868
return
6969
}
70+
if path := os.Getenv("LSSHFS_DEBUG_LOG"); path != "" {
71+
if f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600); err == nil {
72+
_, _ = fmt.Fprintf(f, "DEBUG lsshfs: "+format+"\n", args...)
73+
_ = f.Close()
74+
return
75+
}
76+
}
7077
_, _ = fmt.Fprintf(r.Stderr, "DEBUG lsshfs: "+format+"\n", args...)
7178
}
7279

vendor/github.com/blacknon/go-sshlib/fuse_forward.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)