forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_stub.go
267 lines (233 loc) · 7.37 KB
/
block_stub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// +build !linux,!darwin,!windows
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
//
package ghw
import (
"runtime"
"github.com/pkg/errors"
)
func (ctx *context) blockFillInfo(info *BlockInfo) error {
return errors.New("blockFillInfo not implemented on " + runtime.GOOS)
}
// DiskPhysicalBlockSizeBytes has been deprecated in 0.2. Please use the
// Disk.PhysicalBlockSizeBytes attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskPhysicalBlockSizeBytes(disk string) uint64 {
msg := `
The DiskPhysicalBlockSizeBytes() function has been DEPRECATED and will be
removed in the 1.0 release of ghw. Please use the Disk.PhysicalBlockSizeBytes
attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskPhysicalBlockSizeBytes(disk)
}
func (ctx *context) diskPhysicalBlockSizeBytes(disk string) uint64 {
return 0
}
// DiskSizeBytes has been deprecated in 0.2. Please use the Disk.SizeBytes
// attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskSizeBytes(disk string) uint64 {
msg := `
The DiskSizeBytes() function has been DEPRECATED and will be
removed in the 1.0 release of ghw. Please use the Disk.SizeBytes attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskSizeBytes(disk)
}
func (ctx *context) diskSizeBytes(disk string) uint64 {
return 0
}
// DiskNUMANodeID has been deprecated in 0.2. Please use the Disk.NUMANodeID
// attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskNUMANodeID(disk string) int {
msg := `
The DiskNUMANodeID() function has been DEPRECATED and will be
removed in the 1.0 release of ghw. Please use the Disk.NUMANodeID attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskNUMANodeID(disk)
}
func (ctx *context) diskNUMANodeID(disk string) int {
return -1
}
// DiskVendor has been deprecated in 0.2. Please use the Disk.Vendor attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskVendor(disk string) string {
msg := `
The DiskVendor() function has been DEPRECATED and will be
removed in the 1.0 release of ghw. Please use the Disk.Vendor attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskVendor(disk)
}
func (ctx *context) diskVendor(disk string) string {
return UNKNOWN
}
// DiskModel has been deprecated in 0.2. Please use the Disk.Model attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskModel(disk string) string {
msg := `
The DiskModel() function has been DEPRECATED and will be removed in the 1.0
release of ghw. Please use the Disk.Model attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskModel(disk)
}
func (ctx *context) diskModel(disk string) string {
return UNKNOWN
}
// DiskSerialNumber has been deprecated in 0.2. Please use the Disk.SerialNumber attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskSerialNumber(disk string) string {
msg := `
The DiskSerialNumber() function has been DEPRECATED and will be removed in the
1.0 release of ghw. Please use the Disk.SerialNumber attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskSerialNumber(disk)
}
func (ctx *context) diskSerialNumber(disk string) string {
return UNKNOWN
}
// DiskBusPath has been deprecated in 0.2. Please use the Disk.BusPath attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskBusPath(disk string) string {
msg := `
The DiskBusPath() function has been DEPRECATED and will be removed in the 1.0
release of ghw. Please use the Disk.BusPath attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskBusPath(disk)
}
func (ctx *context) diskBusPath(disk string) string {
return UNKNOWN
}
// DiskWWN has been deprecated in 0.2. Please use the Disk.WWN attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskWWN(disk string) string {
msg := `
The DiskWWN() function has been DEPRECATED and will be removed in the 1.0
release of ghw. Please use the Disk.WWN attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskWWN(disk)
}
func (ctx *context) diskWWN(disk string) string {
return UNKNOWN
}
// DiskPartitions has been deprecated in 0.2. Please use the Disk.Partitions attribute.
// TODO(jaypipes): Remove in 1.0.
func DiskPartitions(disk string) []*Partition {
msg := `
The DiskPartitions() function has been DEPRECATED and will be removed in the
1.0 release of ghw. Please use the Disk.Partitions attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.diskPartitions(disk)
}
func (ctx *context) diskPartitions(disk string) []*Partition {
return nil
}
// Disks has been deprecated in 0.2. Please use the BlockInfo.Disks attribute.
// TODO(jaypipes): Remove in 1.0.
func Disks() []*Disk {
msg := `
The Disks() function has been DEPRECATED and will be removed in the
1.0 release of ghw. Please use the BlockInfo.Disks attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.disks()
}
func (ctx *context) disks() []*Disk {
return nil
}
// PartitionSizeBytes has been deprecated in 0.2. Please use the
// Partition.SizeBytes attribute. TODO(jaypipes): Remove in 1.0.
func PartitionSizeBytes(part string) uint64 {
msg := `
The PartitionSizeBytes() function has been DEPRECATED and will be removed in
the 1.0 release of ghw. Please use the Partition.SizeBytes attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.partitionSizeBytes(part)
}
func (ctx *context) partitionSizeBytes(part string) uint64 {
return 0
}
// PartitionInfo has been deprecated in 0.2. Please use the Partition struct.
// TODO(jaypipes): Remove in 1.0.
func PartitionInfo(part string) (string, string, bool) {
msg := `
The PartitionInfo() function has been DEPRECATED and will be removed in
the 1.0 release of ghw. Please use the Partition struct.
`
warn(msg)
ctx := contextFromEnv()
return ctx.partitionInfo(part)
}
// Given a full or short partition name, returns the mount point, the type of
// the partition and whether it's readonly
func (ctx *context) partitionInfo(part string) (string, string, bool) {
// full name, short name, read-only
return "", "", true
}
// PartitionMountPoint has been deprecated in 0.2. Please use the
// Partition.MountPoint attribute. TODO(jaypipes): Remove in 1.0.
func PartitionMountPoint(part string) string {
msg := `
The PartitionMountPoint() function has been DEPRECATED and will be removed in
the 1.0 release of ghw. Please use the Partition.MountPoint attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.partitionMountPoint(part)
}
func (ctx *context) partitionMountPoint(part string) string {
mp, _, _ := ctx.partitionInfo(part)
return mp
}
// PartitionType has been deprecated in 0.2. Please use the
// Partition.Type attribute. TODO(jaypipes): Remove in 1.0.
func PartitionType(part string) string {
msg := `
The PartitionType() function has been DEPRECATED and will be removed in
the 1.0 release of ghw. Please use the Partition.Type attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.partitionType(part)
}
func (ctx *context) partitionType(part string) string {
_, pt, _ := ctx.partitionInfo(part)
return pt
}
// PartitionIsReadOnly has been deprecated in 0.2. Please use the
// Partition.IsReadOnly attribute. TODO(jaypipes): Remove in 1.0.
func PartitionIsReadOnly(part string) bool {
msg := `
The PartitionIsReadOnly() function has been DEPRECATED and will be removed in
the 1.0 release of ghw. Please use the Partition.IsReadOnly attribute.
`
warn(msg)
ctx := contextFromEnv()
return ctx.partitionIsReadOnly(part)
}
func (ctx *context) partitionIsReadOnly(part string) bool {
_, _, ro := ctx.partitionInfo(part)
return ro
}