From fc0947aa04fddb933f1a346ec239a6fbff385a9a Mon Sep 17 00:00:00 2001 From: henrygd Date: Mon, 3 Nov 2025 17:42:08 -0500 Subject: [PATCH] fix windows extra disk backslash issue (#1361) --- agent/disk.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/disk.go b/agent/disk.go index 6cd5dcc4..88567979 100644 --- a/agent/disk.go +++ b/agent/disk.go @@ -31,6 +31,7 @@ func (a *Agent) initializeDiskInfo() { filesystem, _ := GetEnv("FILESYSTEM") efPath := "/extra-filesystems" hasRoot := false + isWindows := runtime.GOOS == "windows" partitions, err := disk.Partitions(false) if err != nil { @@ -38,6 +39,13 @@ func (a *Agent) initializeDiskInfo() { } slog.Debug("Disk", "partitions", partitions) + // trim trailing backslash for Windows devices (#1361) + if isWindows { + for i, p := range partitions { + partitions[i].Device = strings.TrimSuffix(p.Device, "\\") + } + } + // ioContext := context.WithValue(a.sensorsContext, // common.EnvKey, common.EnvMap{common.HostProcEnvKey: "/tmp/testproc"}, // ) @@ -52,7 +60,7 @@ func (a *Agent) initializeDiskInfo() { // Helper function to add a filesystem to fsStats if it doesn't exist addFsStat := func(device, mountpoint string, root bool, customName ...string) { var key string - if runtime.GOOS == "windows" { + if isWindows { key = device } else { key = filepath.Base(device)