From 7f71d529b83c31635b99451a7b431fb455c5a93c Mon Sep 17 00:00:00 2001 From: Bipin B Narayan Date: Thu, 16 Jan 2025 17:09:25 +0530 Subject: [PATCH 1/2] Storage: add new field `removable` Denotes if a block device is removable or not. --- storage.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage.go b/storage.go index eaee7a7..7911589 100644 --- a/storage.go +++ b/storage.go @@ -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,omitempty"` } func getSerial(name, fullpath string) (serial string) { @@ -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) } } From 7aa39ac9c249240af580df09668e77c04a09c4fd Mon Sep 17 00:00:00 2001 From: Bipin B Narayan Date: Thu, 16 Jan 2025 17:27:59 +0530 Subject: [PATCH 2/2] Storage: do not omit `removable` field if false --- storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage.go b/storage.go index 7911589..4d88a8e 100644 --- a/storage.go +++ b/storage.go @@ -20,7 +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,omitempty"` + Removable bool `json:"removable"` } func getSerial(name, fullpath string) (serial string) {