linux/include/uapi/linux/nbd.h

/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
/*
 * 1999 Copyright (C) Pavel Machek, [email protected]. This code is GPL.
 * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne)
 *            Made nbd_end_request() use the io_request_lock
 * 2001 Copyright (C) Steven Whitehouse
 *            New nbd_end_request() for compatibility with new linux block
 *            layer code.
 * 2003/06/24 Louis D. Langholtz <[email protected]>
 *            Removed unneeded blksize_bits field from nbd_device struct.
 *            Cleanup PARANOIA usage & code.
 * 2004/02/19 Paul Clements
 *            Removed PARANOIA, plus various cleanup and comments
 * 2023 Copyright Red Hat
 *            Link to userspace extensions, favor cookie over handle.
 */

#ifndef _UAPILINUX_NBD_H
#define _UAPILINUX_NBD_H

#include <linux/types.h>

#define NBD_SET_SOCK
#define NBD_SET_BLKSIZE
#define NBD_SET_SIZE
#define NBD_DO_IT
#define NBD_CLEAR_SOCK
#define NBD_CLEAR_QUE
#define NBD_PRINT_DEBUG
#define NBD_SET_SIZE_BLOCKS
#define NBD_DISCONNECT
#define NBD_SET_TIMEOUT
#define NBD_SET_FLAGS

/*
 * See also https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md
 * for additional userspace extensions not yet utilized in the kernel module.
 */

enum {};

/* values for flags field, these are server interaction specific. */
#define NBD_FLAG_HAS_FLAGS
#define NBD_FLAG_READ_ONLY
#define NBD_FLAG_SEND_FLUSH
#define NBD_FLAG_SEND_FUA
/* there is a gap here to match userspace */
#define NBD_FLAG_SEND_TRIM
#define NBD_FLAG_CAN_MULTI_CONN

/* values for cmd flags in the upper 16 bits of request type */
#define NBD_CMD_FLAG_FUA

/* These are client behavior specific flags. */
#define NBD_CFLAG_DESTROY_ON_DISCONNECT
#define NBD_CFLAG_DISCONNECT_ON_CLOSE

/* userspace doesn't need the nbd_device structure */

/* These are sent over the network in the request/reply magic fields */

#define NBD_REQUEST_MAGIC
#define NBD_REPLY_MAGIC
/* Do *not* use magics: 0x12560953 0x96744668. */
/* magic 0x668e33ef for structured reply not supported by kernel yet */

/*
 * This is the packet used for communication between client and
 * server. All data are in network byte order.
 */
struct nbd_request {} __attribute__((packed));

/*
 * This is the reply packet that nbd-server sends back to the client after
 * it has completed an I/O request (or an error occurs).
 */
struct nbd_reply {};
#endif /* _UAPILINUX_NBD_H */