summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.h29
-rw-r--r--lib9p/include/lib9p/srv.h26
2 files changed, 43 insertions, 12 deletions
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index c3c6a8b..1e1667d 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -113,7 +113,7 @@ void lib9p_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
* @param typ : the message type
* @param msg : the message to encode
*
- * @return ret_bytes : the buffer to encode to, must be at be at least lib9p_ctx_max_msg_size(ctx) bytes
+ * @return ret_bytes : the buffer to encode to, must be at be at least ctx->max_msg_size bytes
* @return whether there was an error (false=success, true=error)
*
* @errno LINUX_ERANGE: reply does not fit in ctx->max_msg_size
@@ -121,4 +121,31 @@ void lib9p_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
bool lib9p_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
uint8_t *ret_bytes);
+/**
+ * TODO
+ *
+ * @return ret_net_size: number of bytes consumed; <=net_size
+ * @return ret_host_size: number of bytes that lib9p_unmarshal_stat would take
+ * @return whether there was an error
+ */
+bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
+ uint32_t *ret_net_size, ssize_t *ret_host_size);
+
+/**
+ * TODO
+ *
+ * @return ret_obj : where to put the stat object itself
+ * @return ret_extra : where to put strings for the stat object
+ * @return consumed net_bytes
+ */
+uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes,
+ struct lib9p_stat *ret_obj, void *ret_extra);
+
+/**
+ * @return ret_bytes: the buffer to encode into
+ * @return the number of bytes written, or 0 if the stat object does not fit in max_net_size
+ */
+uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj,
+ uint8_t *ret_bytes);
+
#endif _LIB9P_9P_H_
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index 5df6b1a..7aca76c 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -57,17 +57,20 @@ struct lib9p_srv_file_vtable {
lib9p_dm_t perm, lib9p_o_t flags);
/* directories - once opened */
- size_t (*readdir)(struct lib9p_srv_ctx *, struct lib9p_srv_io_dir *,
- struct lib9p_stat *buf, size_t count,
- size_t offset);
+ size_t /* <- obj cnt */(*dread )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ uint8_t *buf,
+ uint32_t byte_count, /* <- num bytes */
+ size_t obj_offset); /* <- starting at this object */
/* non-directories - once opened */
- uint32_t (*pread )(struct lib9p_srv_ctx *, struct lib9p_srv_io_file *,
- void *buf, uint32_t count,
- uint64_t offset);
- uint32_t (*pwrite )(struct lib9p_srv_ctx *, struct lib9p_srv_io_file *,
- void *buf, uint32_t count,
- uint64_t offset);
+ uint32_t (*pread )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ void *buf,
+ uint32_t byte_count,
+ uint64_t byte_offset);
+ uint32_t (*pwrite )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ void *buf,
+ uint32_t byte_count,
+ uint64_t byte_offset);
};
/* objects you'll deal with ***************************************************/
@@ -83,8 +86,9 @@ struct lib9p_srv_file {
* ref type 2: ->_parent_dir of another file */
struct lib9p_srv_file *_refcount;
lib9p_o_t _io_flags;
- struct lib9p_qid _io_qid;
- uint32_t _io_unit;
+ bool _io_isdir;
+ size_t _io_dir_idx;
+ uint32_t _io_dir_off;
/* This is where your implementation data goes. */
char data[0];