Port to zfs-0.7.x
Compatibility changes to work with libzfs 0.7.x, changes are not bacward compatible
This commit is contained in:
parent
4cd8ea7346
commit
c0f5b857fc
25
common.go
25
common.go
|
@ -144,7 +144,9 @@ const (
|
|||
// Pool properties. Enumerates available ZFS pool properties. Use it to access
|
||||
// pool properties either to read or set soecific property.
|
||||
const (
|
||||
PoolPropName Prop = iota
|
||||
PoolPropCont Prop = iota - 2
|
||||
PoolPropInval
|
||||
PoolPropName
|
||||
PoolPropSize
|
||||
PoolPropCapacity
|
||||
PoolPropAltroot
|
||||
|
@ -171,6 +173,8 @@ const (
|
|||
PoolPropLeaked
|
||||
PoolPropMaxBlockSize
|
||||
PoolPropTName
|
||||
PoolPropMaxNodeSize
|
||||
PoolPropMultiHost
|
||||
PoolNumProps
|
||||
)
|
||||
|
||||
|
@ -181,7 +185,9 @@ const (
|
|||
* the property table in module/zcommon/zfs_prop.c.
|
||||
*/
|
||||
const (
|
||||
DatasetPropType Prop = iota
|
||||
DatasetPropCont Prop = iota - 2
|
||||
DatasetPropBad
|
||||
DatasetPropType
|
||||
DatasetPropCreation
|
||||
DatasetPropUsed
|
||||
DatasetPropAvailable
|
||||
|
@ -207,7 +213,7 @@ const (
|
|||
DatasetPropSnapdir
|
||||
DatasetPropPrivate /* not exposed to user, temporary */
|
||||
DatasetPropAclinherit
|
||||
DatasetPropCreatetxg /* not exposed to the user */
|
||||
DatasetPropCreateTXG /* not exposed to the user */
|
||||
DatasetPropName /* not exposed to the user */
|
||||
DatasetPropCanmount
|
||||
DatasetPropIscsioptions /* not exposed to the user */
|
||||
|
@ -240,12 +246,14 @@ const (
|
|||
DatasetPropDedup
|
||||
DatasetPropMlslabel
|
||||
DatasetPropSync
|
||||
DatasetPropDnodeSize
|
||||
DatasetPropRefratio
|
||||
DatasetPropWritten
|
||||
DatasetPropClones
|
||||
DatasetPropLogicalused
|
||||
DatasetPropLogicalreferenced
|
||||
DatasetPropInconsistent /* not exposed to the user */
|
||||
DatasetPropVolmode
|
||||
DatasetPropFilesystemLimit
|
||||
DatasetPropSnapshotLimit
|
||||
DatasetPropFilesystemCount
|
||||
|
@ -259,6 +267,17 @@ const (
|
|||
DatasetPropRelatime
|
||||
DatasetPropRedundantMetadata
|
||||
DatasetPropOverlay
|
||||
DatasetPropPrevSnap
|
||||
DatasetPropReceiveResumeToken
|
||||
DatasetPropEncryption
|
||||
DatasetPropKeyLocation
|
||||
DatasetPropKeyFormat
|
||||
DatasetPropPBKDF2Salt
|
||||
DatasetPropPBKDF2Iters
|
||||
DatasetPropEncryptionRoot
|
||||
DatasetPropKeyGUID
|
||||
DatasetPropKeyStatus
|
||||
DatasetPropRemapTXG /* not exposed to the user */
|
||||
DatasetNumProps
|
||||
)
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ func (d *Dataset) Receive(inf *os.File, flags RecvFlags) (err error) {
|
|||
defer C.free(unsafe.Pointer(cflags))
|
||||
dest := C.CString(dpath)
|
||||
defer C.free(unsafe.Pointer(dest))
|
||||
ec := C.zfs_receive(C.libzfsHandle, dest, cflags, C.int(inf.Fd()), nil)
|
||||
ec := C.zfs_receive(C.libzfsHandle, dest, nil, cflags, C.int(inf.Fd()), nil)
|
||||
if ec != 0 {
|
||||
err = fmt.Errorf("ZFS receive of %s failed. %s", C.GoString(dest), LastError().Error())
|
||||
}
|
||||
|
|
12
zpool.c
12
zpool.c
|
@ -2,7 +2,11 @@
|
|||
* using libzfs from go language, and make go code shorter and more readable.
|
||||
*/
|
||||
|
||||
typedef unsigned long int rlim64_t;
|
||||
|
||||
#include <libzfs.h>
|
||||
#include <libzfs/sys/zfs_context.h>
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
@ -189,7 +193,7 @@ property_list_ptr read_zpool_property(zpool_list_ptr pool, int prop) {
|
|||
property_list_ptr list = new_property_list();
|
||||
|
||||
r = zpool_get_prop(pool->zph, prop,
|
||||
list->value, INT_MAX_VALUE, &source);
|
||||
list->value, INT_MAX_VALUE, &source, B_FALSE);
|
||||
if (r == 0) {
|
||||
// strcpy(list->name, zpool_prop_to_name(prop));
|
||||
zprop_source_tostr(list->source, source);
|
||||
|
@ -491,11 +495,15 @@ nvlist_ptr get_zpool_vdev_tree(nvlist_ptr nv) {
|
|||
|
||||
nvlist_ptr go_zpool_search_import(libzfs_handle_ptr zfsh, int paths, char **path, boolean_t do_scan) {
|
||||
importargs_t idata = { 0 };
|
||||
nvlist_ptr pools = NULL;
|
||||
idata.path = path;
|
||||
idata.paths = paths;
|
||||
// idata.scan = 0;
|
||||
|
||||
return zpool_search_import(zfsh, &idata);
|
||||
thread_init();
|
||||
pools = zpool_search_import(zfsh, &idata);
|
||||
thread_fini();
|
||||
return pools;
|
||||
}
|
||||
|
||||
|
||||
|
|
3
zpool.go
3
zpool.go
|
@ -1,5 +1,6 @@
|
|||
package zfs
|
||||
|
||||
// #cgo CFLAGS: -D__USE_LARGEFILE64=1
|
||||
// #include <stdlib.h>
|
||||
// #include <libzfs.h>
|
||||
// #include "common.h"
|
||||
|
@ -364,7 +365,7 @@ func poolSearchImport(q string, searchpaths []string, guid bool) (name string,
|
|||
C.strings_setat(cpaths, C.int(i), csPath)
|
||||
}
|
||||
|
||||
pools := C.zpool_find_import(C.libzfsHandle, C.int(numofp), cpaths)
|
||||
pools := C.go_zpool_search_import(C.libzfsHandle, C.int(numofp), cpaths, C.B_FALSE)
|
||||
defer C.nvlist_free(pools)
|
||||
|
||||
elem = C.nvlist_next_nvpair(pools, elem)
|
||||
|
|
|
@ -543,7 +543,7 @@ func TestPool_VDevTree(t *testing.T) {
|
|||
// TODO: Add test cases.
|
||||
{
|
||||
name: "test1",
|
||||
fields: fields{"NETSTOR"},
|
||||
fields: fields{"TESTPOOL"},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue