From: Michael Vrable Date: Thu, 12 Nov 2009 22:43:21 +0000 (-0800) Subject: Extra logging, begin defining BlueSky-specific error codes. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=f6697c903221f4f95972b7618f84cf86ff1e6bc0;p=bluesky.git Extra logging, begin defining BlueSky-specific error codes. --- diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index dbb69bb..fc30075 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -17,6 +17,14 @@ extern "C" { #endif +/* BlueSky status and error codes. Various frontends should translate these to + * the appropriate error code for whatever protocol they implement. */ +typedef enum { + BSTATUS_OK = 0, /* No error */ + BSTATUS_IOERR, /* I/O error of some form */ + BSTATUS_NOENT, /* File does not exist */ +} BlueSkyStatus; + void bluesky_init(void); gchar *bluesky_lowercase(const gchar *s); diff --git a/bluesky/file.c b/bluesky/file.c index 75768d1..ccb45e4 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "bluesky-private.h" @@ -55,6 +56,8 @@ void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size) if (size == inode->size) return; + g_print("Truncating file to %"PRIi64" bytes\n", size); + uint64_t blocks = (size + BLUESKY_BLOCK_SIZE - 1) / BLUESKY_BLOCK_SIZE; if (blocks > inode->blocks->len) { @@ -98,6 +101,8 @@ void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size) void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, const char *data, gint len) { + g_print("Write %d bytes at offset %"PRIi64"\n", len, offset); + g_return_if_fail(inode->type == BLUESKY_REGULAR); g_return_if_fail(offset < inode->size); g_return_if_fail(len <= inode->size - offset); @@ -128,6 +133,11 @@ void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, char *buf, gint len) { + g_print("Read %d bytes at offset %"PRIi64"\n", len, offset); + + if (len == 0 && offset <= inode->size) + return; + g_return_if_fail(inode->type == BLUESKY_REGULAR); g_return_if_fail(offset < inode->size); g_return_if_fail(len <= inode->size - offset);