@@ -107,30 +107,32 @@ func Init(nodePath string) error {
107
107
}
108
108
109
109
type VDev struct {
110
- IsLog uint64 `nvlist:"is_log"`
111
- SpaceMapObjectNumber uint64 `nvlist:"DTL,omitempty"`
112
- AlignmentShift uint64 `nvlist:"ashift,omitempty"`
113
- AllocatableCapacity uint64 `nvlist:"asize,omitempty"`
114
- GUID uint64 `nvlist:"guid,omitempty"`
115
- ID uint64 `nvlist:"id,omitempty"`
116
- Path string `nvlist:"path"`
117
- Type string `nvlist:"type"`
118
- Children []VDev `nvlist:"children,omitempty"`
119
- L2CacheChildren []VDev `nvlist:"l2cache,omitempty"`
120
- SparesChildren []VDev `nvlist:"spares,omitempty"`
110
+ IsLog uint64 `nvlist:"is_log"`
111
+ DTL uint64 `nvlist:"DTL,omitempty"`
112
+ AlignmentShift uint64 `nvlist:"ashift,omitempty"`
113
+ AllocatableCapacity uint64 `nvlist:"asize,omitempty"`
114
+ GUID uint64 `nvlist:"guid,omitempty"`
115
+ ID uint64 `nvlist:"id,omitempty"`
116
+ Path string `nvlist:"path"`
117
+ Type string `nvlist:"type"`
118
+ Children []VDev `nvlist:"children,omitempty"`
119
+ L2CacheChildren []VDev `nvlist:"l2cache,omitempty"`
120
+ SparesChildren []VDev `nvlist:"spares,omitempty"`
121
121
}
122
122
123
123
type PoolConfig struct {
124
- NumberOfChildren uint64 `nvlist:"vdev_children"`
125
- VDevTree * VDev `nvlist:"vdev_tree"`
126
- Errata uint64 `nvlist:"errata,omitempty"`
127
- HostID uint64 `nvlist:"hostid,omitempty"`
128
- Hostname string `nvlist:"hostname,omitempty"`
124
+ Version uint64 `nvlist:"version,omitempty"`
129
125
Name string `nvlist:"name,omitempty"`
130
- GUID uint64 `nvlist:"pool_guid,omitempty"`
131
126
State uint64 `nvlist:"state,omitempty"`
132
127
TXG uint64 `nvlist:"txg,omitempty"`
133
- Version uint64 `nvlist:"version,omitempty"`
128
+ GUID uint64 `nvlist:"pool_guid,omitempty"`
129
+ Errata uint64 `nvlist:"errata,omitempty"`
130
+ Hostname string `nvlist:"hostname,omitempty"`
131
+ NumberOfChildren uint64 `nvlist:"vdev_children"`
132
+ VDevTree * VDev `nvlist:"vdev_tree"`
133
+ HostID uint64 `nvlist:"hostid,omitempty"`
134
+ // Delta: -hostid, +top_guid, +guid, +features_for_read
135
+ FeaturesForRead map [string ]bool `nvlist:"features_for_read"`
134
136
}
135
137
136
138
func delimitedBufToString (buf []byte ) string {
@@ -200,6 +202,30 @@ func PoolConfigs() (map[string]interface{}, error) {
200
202
return res , err
201
203
}
202
204
205
+ // PoolImport imports a pool
206
+ func PoolImport (name string , config map [string ]interface {}, props map [string ]interface {}) (map [string ]interface {}, error ) {
207
+ cmd := & Cmd {}
208
+ cmd .Guid = config ["pool_guid" ].(uint64 )
209
+ outConfig := make (map [string ]interface {})
210
+ err := NvlistIoctl (zfsHandle .Fd (), ZFS_IOC_POOL_IMPORT , name , cmd , props , outConfig , config )
211
+ if cmd .Cookie != 0 {
212
+ return nil , unix .Errno (cmd .Cookie )
213
+ }
214
+ return outConfig , err
215
+ }
216
+
217
+ // PoolExport exports a pool
218
+ func PoolExport (name string , force , hardForce bool ) error {
219
+ cmd := & Cmd {}
220
+ if force {
221
+ cmd .Cookie = 1
222
+ }
223
+ if hardForce {
224
+ cmd .Guid = 1
225
+ }
226
+ return NvlistIoctl (zfsHandle .Fd (), ZFS_IOC_POOL_EXPORT , name , cmd , nil , nil , nil )
227
+ }
228
+
203
229
// Promote replaces a ZFS filesystem with a clone of itself.
204
230
func Promote (name string ) (conflictingSnapshot string , err error ) {
205
231
cmd := & Cmd {}
0 commit comments