changeset 123:bcfa54a2555a

common: finish rpc protocol based on spec Signed-off-by: Joshua Kahn <josh@joshuak.net> Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josephsipek.net>
author Joshua Kahn <josh@joshuak.net>
date Sat, 17 Oct 2015 22:11:36 -0400
parents 52772d293239
children fc5fdc73997d
files src/common/CMakeLists.txt src/common/attr.c src/common/include/nomad/attr.h src/common/rpc_fs.x
diffstat 4 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/common/CMakeLists.txt	Sat Oct 17 20:39:42 2015 -0400
+++ b/src/common/CMakeLists.txt	Sat Oct 17 22:11:36 2015 -0400
@@ -1,5 +1,6 @@
 #
 # Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+# Copyright (c) 2015 Joshua Kahn <josh@joshuak.net>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +25,7 @@
 
 add_library(nomad_common SHARED
 	assfail.c
+	attr.c
 	connsvc.c
 	mutex.c
 	node.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/common/attr.c	Sat Oct 17 22:11:36 2015 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Joshua Kahn <josh@joshuak.net>
+ *
+ * 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>
+
+bool_t xdr_nattr(XDR *xdrs, struct nattr *attr)
+{
+	if (!xdr_uint16_t(xdrs, &attr->mode))
+		return FALSE;
+	if (!xdr_uint32_t(xdrs, &attr->nlink))
+		return FALSE;
+	if (!xdr_uint64_t(xdrs, &attr->size))
+		return FALSE;
+	if (!xdr_uint64_t(xdrs, &attr->atime))
+		return FALSE;
+	if (!xdr_uint64_t(xdrs, &attr->btime))
+		return FALSE;
+	if (!xdr_uint64_t(xdrs, &attr->ctime))
+		return FALSE;
+	if (!xdr_uint64_t(xdrs, &attr->mtime))
+		return FALSE;
+	return TRUE;
+}
--- a/src/common/include/nomad/attr.h	Sat Oct 17 20:39:42 2015 -0400
+++ b/src/common/include/nomad/attr.h	Sat Oct 17 22:11:36 2015 -0400
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015 Joshua Kahn <josh@joshuak.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +25,7 @@
 #define __NOMAD_ATTR_H
 
 #include <stdint.h>
+#include <rpc/rpc.h>
 
 /* object attributes */
 
@@ -65,4 +67,6 @@
 	/* XXX: group */
 };
 
+bool_t xdr_nattr(XDR *xdrs, struct nattr *attr);
+
 #endif
--- a/src/common/rpc_fs.x	Sat Oct 17 20:39:42 2015 -0400
+++ b/src/common/rpc_fs.x	Sat Oct 17 22:11:36 2015 -0400
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  * Copyright (c) 2015 Holly Sipek
+ * Copyright (c) 2015 Joshua Kahn <josh@joshuak.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -39,3 +40,35 @@
 struct rpc_login_res {
 	struct nobjhndl	root;
 };
+
+struct rpc_stat_req {
+	struct nobjhndl	obj;
+};
+
+struct rpc_stat_res {
+	struct nattr	attributes;
+};
+
+struct rpc_lookup_req {
+	struct nobjhndl	parent;
+	string		path<>;
+};
+
+struct rpc_lookup_res {
+	struct nobjhndl	child;
+};
+
+struct rpc_create_req {
+	struct nobjhndl	parent;
+	string		path<>;
+	uint16_t	mode; /* see NATTR_* in common/include/nomad/atrr.h */
+};
+
+struct rpc_create_res {
+	struct nobjhndl	obj;
+};
+
+struct rpc_remove_req {
+	struct nobjhndl	parent;
+	string		path<>;
+};