Skip to content

[disk][process][freebsd]: remove binary.go from common - #1907

Merged
shirou merged 1 commit into
masterfrom
feat/remove_binary_go_file
Aug 28, 2025
Merged

[disk][process][freebsd]: remove binary.go from common#1907
shirou merged 1 commit into
masterfrom
feat/remove_binary_go_file

Conversation

@shirou

@shirou shirou commented Aug 26, 2025

Copy link
Copy Markdown
Owner

This PR fixes #1898.

Background

The FreeBSD devstat struct is generated from the C devstat structure using Go’s cgo tool. However, this results in a field defined as ID *byte (a pointer to byte).
When using binary.Read on a struct that contains pointer fields, it returns an "invalid type" error.
For that reason, we previously modified binary.go to handle reflect.Ptr and kept that modified version in the repository.

Approach in this PR

That said, I don’t think maintaining code from the standard library is a good practice. In this PR, I’ve manually changed *byte to [sizeofPtr]byte. Since sizeofPtr varies depending on the architecture, this ensures that the struct has a consistent byte size across architectures and allows binary.Read to work properly. Thus, we can remove binary.go from this repository.

@shirou
shirou merged commit b1b09bc into master Aug 28, 2025
50 checks passed
@shirou
shirou deleted the feat/remove_binary_go_file branch August 28, 2025 21:46
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Sep 3, 2025
Patch a bug in gopsutil used by telegraf, thas was fixed upstreams but
has not yet been released. This copies the patch from gopsutil's PR
1907. [1]

Link:	shirou/gopsutil#1907 [1]
PR:	289207
camachat pushed a commit to camachat/freebsd-ports that referenced this pull request Jul 22, 2026
Patch a bug in gopsutil used by telegraf, thas was fixed upstreams but
has not yet been released. This copies the patch from gopsutil's PR
1907. [1]

Link:	shirou/gopsutil#1907 [1]
PR:	289207
camachat pushed a commit to camachat/freebsd-ports that referenced this pull request Jul 24, 2026
Patch a bug in gopsutil used by telegraf, thas was fixed upstreams but
has not yet been released. This copies the patch from gopsutil's PR
1907. [1]

Link:	shirou/gopsutil#1907 [1]
PR:	289207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic in process.ProcessesWithContext on freebsd

1 participant