diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-12 17:53:05 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-12 17:53:05 -0600 |
commit | eb4e0bc7dd140b356a62071bf8e0427fc0cee816 (patch) | |
tree | c71d7daf1dfccf7e261c2fe22d7d5a0bd55bf34d /lib9p/include | |
parent | 7508de2e4ec10baf46c7cde6e7774051ac19e95a (diff) |
get read working correctly
Diffstat (limited to 'lib9p/include')
-rw-r--r-- | lib9p/include/lib9p/9p.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 2511e3d..e7ddb15 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -56,6 +56,17 @@ static bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) { return ctx->err_msg[0]; } +/** Assert that a `struct lib9p_stat` object looks valid. */ +static inline void lib9p_assert_stat(struct lib9p_stat stat) { + assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) ); + assert( ((bool)(stat.file_mode & LIB9P_DM_APPEND )) == ((bool)(stat.file_qid.type & LIB9P_QT_APPEND )) ); + assert( ((bool)(stat.file_mode & LIB9P_DM_EXCL )) == ((bool)(stat.file_qid.type & LIB9P_QT_EXCL )) ); + assert( ((bool)(stat.file_mode & _LIB9P_DM_PLAN9_MOUNT)) == ((bool)(stat.file_qid.type & _LIB9P_QT_PLAN9_MOUNT)) ); + assert( ((bool)(stat.file_mode & LIB9P_DM_AUTH )) == ((bool)(stat.file_qid.type & LIB9P_QT_AUTH )) ); + assert( ((bool)(stat.file_mode & LIB9P_DM_TMP )) == ((bool)(stat.file_qid.type & LIB9P_QT_TMP )) ); + assert( (stat.file_size == 0) || !(stat.file_mode & LIB9P_DM_DIR) ); +} + /** Write an static error into ctx, return -1. */ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg); /** Write a printf-style error into ctx, return -1. */ |