# Copyright 2021 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <sys/param.h>
include <sys/ioctl.h>
include <sys/fcntl.h>

include <sys/disklabel.h>
include <dev/vndioctl.h>

resource fd_vnd[fd]

openat$vnd(fd const[AT_FDCWD], file ptr[in, string["/dev/rvnd0c"]], flags flags[open_flags], mode const[0]) fd_vnd

ioctl$VNDIOCGET(fd fd_vnd, cmd const[VNDIOCGET], arg ptr[inout, vnd_user])
ioctl$VNDIOCSET(fd fd_vnd, cmd const[VNDIOCSET], arg ptr[inout, vnd_ioctl])
ioctl$VNDIOCCLR(fd fd_vnd, cmd const[VNDIOCCLR], arg ptr[in, vnd_ioctl])

vnd_ioctl {
	vnd_file	ptr[in, filename]
	vnd_secsize	int64[0:4096]
	vnd_nsectors	int64
	vnd_ntracks	int64
	vnd_size	int64
	vnd_key		ptr[in, array[int8]]
	vnd_keylen	len[vnd_key, int32]
	vnd_type	flags[vnd_disk_types, int16]
}

vnd_disk_types = DTYPE_VND, DTYPE_SCSI, DTYPE_FLOPPY, DTYPE_ATAPI, DTYPE_RDROOT

vnd_user {
	vnufile		string[filename, VNDNLEN]
	vnu_unit	int32
	vnu_dev		int32
	vnu_ino		int64
}
