void bluesky_string_unref(BlueSkyRCStr *string);
BlueSkyRCStr *bluesky_string_dup(BlueSkyRCStr *string);
+/* Cryptographic operations. */
+#define CRYPTO_BLOCK_SIZE 16 /* 128-bit AES */
+#define CRYPTO_KEY_SIZE 16
+
+void bluesky_crypt_init();
+void bluesky_crypt_random_bytes(guchar *buf, gint len);
+BlueSkyRCStr *bluesky_crypt_encrypt(BlueSkyRCStr *in, const uint8_t *key);
+BlueSkyRCStr *bluesky_crypt_decrypt(BlueSkyRCStr *in, const uint8_t *key);
+
/* File types. The numeric values are chosen to match with those used in
* NFSv3. */
typedef enum {
uint64_t next_inum; /* Next available inode for allocation */
struct S3Store *store;
+
+ uint8_t *encryption_key;
} BlueSkyFS;
/* Inode number of the root directory. */
/* In-memory representation of an inode within a Blue Sky server. This
* corresponds roughly with information that is committed to persistent
- * storage. */
+ * storage. Locking/refcounting rules:
+ * - To access or modify any data fields, the lock must be held. This
+ * includes file blocks.
+ * - One reference is held by the BlueSkyFS inode hash table. If that is the
+ * only reference (and the inode is unlocked), the inode is subject to
+ * dropping from the cache.
+ * - Any pending operations should hold extra references to the inode as
+ * appropriate to keep it available until the operation completes.
+ * */
typedef struct {
- gint refcnt; /* May be accessed atomically without lock */
GMutex *lock;
+ gint refcount;
BlueSkyFS *fs;