/*
  FUSE-ioctl: ioctl support for FUSE
  Copyright (C) 2008       SUSE Linux Products GmbH
  Copyright (C) 2008       Tejun Heo <teheo@suse.de>

  This program can be distributed under the terms of the GNU GPLv2.
  See the file GPL2.txt.
*/

/** @file
 * @tableofcontents
 *
 * Header file to share definitions between the ioctl example file
 * systems (ioctl.c, ioctl_ll.c, cuse.c) and their test programs
 * (ioctl_client.c, ioctl_ll_client.c, cuse_client.c).
 *
 * Restricted ioctls (FIOC_GET_SIZE, FIOC_SET_SIZE):
 *   Use _IOR/_IOW encoding - kernel handles data transfer automatically.
 *
 * Unrestricted ioctls (FIOC_READ, FIOC_WRITE):
 *   Use _IO encoding - require fuse_reply_ioctl_retry() in low-level API.
 *   Only work with CUSE (fuse kernel restriction).
 *
 * \include ioctl.h
 */

#include <sys/types.h>
#include <sys/uio.h>
#include <sys/ioctl.h>

enum {
	FIOC_GET_SIZE	= _IOR('E', 0, size_t),
	FIOC_SET_SIZE	= _IOW('E', 1, size_t),

	/*
	 * The following two ioctls don't follow usual encoding rules
	 * and transfer variable amount of data.
	 */
	FIOC_READ	= _IO('E', 2),
	FIOC_WRITE	= _IO('E', 3),
};

struct fioc_rw_arg {
	off_t		offset;
	void		*buf;
	size_t		size;
	size_t		prev_size;	/* out param for previous total size */
	size_t		new_size;	/* out param for new total size */
};
