Skip to content

Commit 9e0e39d

Browse files
committed
feat: Add callback to handle when a client has called IOCTL_DO_IT
1 parent fd4d4b1 commit 9e0e39d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/client/nbd.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ var (
2323
)
2424

2525
type Options struct {
26-
ExportName string
27-
BlockSize uint32
26+
ExportName string
27+
BlockSize uint32
28+
OnConnected func()
2829
}
2930

3031
func negotiateNewstyle(conn net.Conn) error {
@@ -51,8 +52,9 @@ func negotiateNewstyle(conn net.Conn) error {
5152
func Connect(conn net.Conn, device *os.File, options *Options) error {
5253
if options == nil {
5354
options = &Options{
54-
ExportName: "default",
55-
BlockSize: 0,
55+
ExportName: "default",
56+
BlockSize: 0,
57+
OnConnected: func() {},
5658
}
5759
}
5860

@@ -196,6 +198,10 @@ n:
196198
return err
197199
}
198200

201+
if options.OnConnected != nil {
202+
options.OnConnected()
203+
}
204+
199205
if _, _, err := syscall.Syscall(
200206
syscall.SYS_IOCTL,
201207
device.Fd(),

0 commit comments

Comments
 (0)