view src/common/rpc_fs.x @ 1281:fe84110a0b10

common: extend LINK to include more args and a return value These should have been part of the RPC from the beginning. Since nothing implements LINK yet, we can modify it without dealing with protocol version issues. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Dec 2022 16:32:57 -0500
parents 4105b14950bc
children
line wrap: on
line source

/*
 * Copyright (c) 2015-2020,2022 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
 * Copyright (c) 2015 Holly Sipek
 * Copyright (c) 2015 Joshua Kahn <josh@joshuak.net>
 * Copyright (c) 2016 Steve Dougherty
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

%#include <nomad/types.h>
%#include <nomad/config.h>
%
%#ifndef HAVE_XDR_UINT8_T
%#define xdr_uint8_t(x, v)	xdr_u_char((x), (v))
%#endif

#define HANDLE(n)	uint32_t	n

%/***** HANDSHAKE ******/
struct rpc_handshake_req {
	uint32_t	vers;
};

%/***** RPC header *****/
struct rpc_header_req {
	uint16_t	opcode;
};

struct rpc_header_res {
	uint32_t	err;
};

%/***** LOGIN *****/
struct rpc_login_req {
	string		conn<>;
	struct xuuid	volid;
};

struct rpc_login_res {
	struct noid	root;
};

%/***** GETATTR *****/
struct rpc_getattr_req {
	HANDLE(handle);
};

struct rpc_getattr_res {
	struct nattr	attr;
};

%/***** LOOKUP *****/
struct rpc_lookup_req {
	HANDLE(parent);
	struct noid	desired;
	string		name<>;
};

struct rpc_lookup_res {
	struct noid	child;
	uint8_t		type; /* see NDIRENT_TYPE_* in common/include/nomad/atrr.h */
};

%/***** CREATE *****/
struct rpc_create_req {
	HANDLE(parent);
	string		name<>;
	uint32_t	owner;
	uint32_t	group;
	uint16_t	mode; /* see NATTR_* in common/include/nomad/atrr.h */
	uint64_t	dev; /* only used for block/character devices */
};

struct rpc_create_res {
	struct noid	oid;
};

%/***** LINK *****/
struct rpc_link_req {
	HANDLE(parent);
	string		name<>;
	string		target_name<>; /* symlink only */
	HANDLE(target_handle); /* hardlink only */
	uint32_t	owner;
	uint32_t	group;
	uint16_t	mode;
	bool		symlink;
};

struct rpc_link_res {
	struct noid	oid;
};

%/***** UNLINK *****/
struct rpc_unlink_req {
	HANDLE(parent);
	string		name<>;
	struct noid	desired;
	bool		rmdir;
};

%/***** OPEN *****/
struct rpc_open_req {
	struct noid	oid;
	uint64_t	ino;
	struct nvclock	clock;
};

struct rpc_open_res {
	HANDLE(handle);
};

%/***** CLOSE *****/
struct rpc_close_req {
	HANDLE(handle);
};

%/***** READ *****/
struct rpc_read_req {
	HANDLE(handle);
	uint64_t offset;
	/*
	 * 32-bit length is ok because rpcgen doesn't know how to send more
	 * than 4GB anyway.  Furthermore, the object store has a 31-bit
	 * length limitation on 32-bit systems.
	 */
	uint32_t length;
};

struct rpc_read_res {
	/* length is sent as part of data */
	opaque data<4294967295>;
};

%/***** WRITE *****/
struct rpc_write_req {
	HANDLE(handle);
	uint64_t offset;
	/* length is sent as part of data */
	opaque data<4294967295>;
};

%/***** SETATTR *****/
struct rpc_setattr_req {
	HANDLE(handle);
	struct nattr attr;
	bool mode_is_valid;
	bool size_is_valid;
	bool atime_is_valid;
	bool btime_is_valid;
	bool ctime_is_valid;
	bool mtime_is_valid;
	bool owner_is_valid;
	bool group_is_valid;
};

struct rpc_setattr_res {
	struct nattr attr;
};

%/***** GETDENT *****/
struct rpc_getdent_req {
	HANDLE(parent);
	uint64_t offset;
};

struct rpc_getdent_res {
	struct ndirent ent;
};

%/***** OBJ_INFO *****/
struct obj_info {
	struct nvclock	clock;
};

struct rpc_obj_info_req {
	struct noid oid;
};

struct rpc_obj_info_res {
	struct obj_info info<>;
};

%/***** VDEV_IMPORT *****/
struct rpc_vdev_import_req {
	string type<>;
	string path<>;
	bool create;
};

struct rpc_vdev_import_res {
	struct xuuid uuid;
};

%/***** VDEV_LIST *****/
struct vdev_info {
	struct xuuid uuid;
	string type<>;
	string path<>;
	uint64_t size;
	uint64_t used;
	uint32_t nvols;
	uint32_t state;
};

struct rpc_vdev_list_res {
	struct vdev_info vdevs<>;
};

%/***** VOL_CREATE *****/
struct rpc_vol_create_req {
	struct xuuid vdevid;
	struct xuuid volid;
};

struct rpc_vol_create_res {
	struct xuuid volid;
};

%/***** VOL_LIST *****/
struct vol_info {
	struct xuuid vdevid;
	struct xuuid volid;
};

struct rpc_vol_list_req {
	struct xuuid vdevid;
};

struct rpc_vol_list_res {
	struct vol_info vols<>;
};