-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexists.go
61 lines (54 loc) · 1 KB
/
exists.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
package main
import (
"fmt"
"gozfs/nv"
"os"
)
func exists(name string) error {
l := nv.List{
Pairs: []nv.Pair{
{Value: "zfs_exists"},
{Value: uint64(0)},
},
}
l.Pairs[0].EncodedSize = 0x28
l.Pairs[0].DecodedSize = 0x28
l.Pairs[0].Name = "cmd"
l.Pairs[0].NElements = 1
l.Pairs[0].Type = nv.STRING
l.Pairs[1].EncodedSize = 0x24
l.Pairs[1].DecodedSize = 0x20
l.Pairs[1].Name = "version"
l.Pairs[0].NElements = 1
l.Pairs[1].Type = nv.UINT64
fmt.Println(l)
lbytes, err := nv.Encode(l)
if err != nil {
panic(err)
}
f, err := os.Create("exists.list.in")
if err != nil {
panic(err)
}
fmt.Fprint(f, lbytes)
f.Close()
var exists = struct {
Command string `nv:"cmd"`
Version uint64 `nv:"version"`
}{
Command: "zfs_exists",
Version: 0,
}
sbytes, err := nv.Encode(exists)
if err != nil {
panic(err)
}
f, err = os.Create("exists.struct.in")
if err != nil {
panic(err)
}
fmt.Fprint(f, sbytes)
f.Close()
fmt.Println("name:", name)
return ioctl(zfs, name, sbytes, nil)
}