Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Add flag for removable block devices #3

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type StorageDevice struct {
Model string `json:"model,omitempty"`
Serial string `json:"serial,omitempty"`
Size uint `json:"size,omitempty"` // device size in GB
Removable bool `json:"removable"`
}

func getSerial(name, fullpath string) (serial string) {
Expand Down Expand Up @@ -99,6 +100,9 @@ func (si *SysInfo) getStorageInfo() {
size, _ := strconv.ParseUint(slurpFile(path.Join(fullpath, "size")), 10, 64)
device.Size = uint(size) / 1953125 // GiB

removable, _ := strconv.ParseBool(slurpFile(path.Join(fullpath, "removable")))
device.Removable = removable

si.Storage = append(si.Storage, device)
}
}
Loading