Index: uspace/srv/fs/exfat/exfat_ops.c
===================================================================
--- uspace/srv/fs/exfat/exfat_ops.c	(revision 6f60727c6bfa4c5b79c2867d244cd66f3108ae4c)
+++ uspace/srv/fs/exfat/exfat_ops.c	(revision e090244cef809d716b5ae82565ed1b14ad6dca26)
@@ -68,5 +68,5 @@
 
 /** List of cached free FAT nodes. */
-static LIST_INITIALIZE(ffn_head);
+static LIST_INITIALIZE(ffn_list);
 
 /*
@@ -90,5 +90,4 @@
 static aoff64_t exfat_size_get(fs_node_t *);
 static unsigned exfat_lnkcnt_get(fs_node_t *);
-static char exfat_plb_get_char(unsigned);
 static bool exfat_is_directory(fs_node_t *);
 static bool exfat_is_file(fs_node_t *node);
@@ -124,5 +123,4 @@
 static int exfat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
 {
-	link_t *lnk;
 	exfat_node_t *nodep;
 	int rc;
@@ -136,5 +134,5 @@
 restart:
 	fibril_mutex_lock(&ffn_mutex);
-	for (lnk = ffn_head.next; lnk != &ffn_head; lnk = lnk->next) {
+	list_foreach(ffn_list, lnk) {
 		nodep = list_get_instance(lnk, exfat_node_t, ffn_link);
 		if (!fibril_mutex_trylock(&nodep->lock)) {
@@ -173,5 +171,5 @@
 		free(nodep);
 
-		/* Need to restart because we changed the ffn_head list. */
+		/* Need to restart because we changed the ffn_list. */
 		goto restart;
 	}
@@ -188,8 +186,9 @@
 
 	fibril_mutex_lock(&ffn_mutex);
-	if (!list_empty(&ffn_head)) {
+	if (!list_empty(&ffn_list)) {
 		/* Try to use a cached free node structure. */
 		exfat_idx_t *idxp_tmp;
-		nodep = list_get_instance(ffn_head.next, exfat_node_t, ffn_link);
+		nodep = list_get_instance(list_first(&ffn_list), exfat_node_t,
+		    ffn_link);
 		if (!fibril_mutex_trylock(&nodep->lock))
 			goto skip_cache;
@@ -483,5 +482,5 @@
 		if (nodep->idx) {
 			fibril_mutex_lock(&ffn_mutex);
-			list_append(&nodep->ffn_link, &ffn_head);
+			list_append(&nodep->ffn_link, &ffn_list);
 			fibril_mutex_unlock(&ffn_mutex);
 		} else {
@@ -588,9 +587,4 @@
 {
 	return EXFAT_NODE(fn)->lnkcnt;
-}
-
-char exfat_plb_get_char(unsigned pos)
-{
-	return exfat_reg.plb_ro[pos % PLB_SIZE];
 }
 
@@ -626,5 +620,4 @@
 	.size_get = exfat_size_get,
 	.lnkcnt_get = exfat_lnkcnt_get,
-	.plb_get_char = exfat_plb_get_char,
 	.is_directory = exfat_is_directory,
 	.is_file = exfat_is_file,
@@ -634,5 +627,5 @@
 
 /*
- * VFS operations.
+ * VFS_OUT operations.
  */
 
@@ -664,19 +657,12 @@
 }
 
-void exfat_mounted(ipc_callid_t rid, ipc_call_t *request)
-{
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+static int
+exfat_mounted(devmap_handle_t devmap_handle, const char *opts, fs_index_t *index,
+    aoff64_t *size, unsigned *linkcnt)
+{
+	int rc;
 	exfat_node_t *rootp=NULL, *bitmapp=NULL, *uctablep=NULL;
 	enum cache_mode cmode;
 	exfat_bs_t *bs;
-
-	/* Accept the mount options */
-	char *opts;
-	int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
-
-	if (rc != EOK) {
-		async_answer_0(rid, rc);
-		return;
-	}
 
 	/* Check for option enabling write through. */
@@ -686,12 +672,8 @@
 		cmode = CACHE_MODE_WB;
 
-	free(opts);
-
 	/* initialize libblock */
-	rc = block_init(devmap_handle, BS_SIZE);
-	if (rc != EOK) {
-		async_answer_0(rid, rc);
-		return;
-	}
+	rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE);
+	if (rc != EOK)
+		return rc;
 
 	/* prepare the boot block */
@@ -699,6 +681,5 @@
 	if (rc != EOK) {
 		block_fini(devmap_handle);
-		async_answer_0(rid, rc);
-		return;
+		return rc;
 	}
 
@@ -710,6 +691,5 @@
 	if (rc != EOK) {
 		block_fini(devmap_handle);
-		async_answer_0(rid, rc);
-		return;
+		return rc;
 	}
 
@@ -719,6 +699,5 @@
 		(void) block_cache_fini(devmap_handle);
 		block_fini(devmap_handle);
-		async_answer_0(rid, rc);
-		return;
+		return rc;
 	}
 
@@ -727,6 +706,5 @@
 		(void) block_cache_fini(devmap_handle);
 		block_fini(devmap_handle);
-		async_answer_0(rid, rc);
-		return;
+		return rc;
 	}
 
@@ -738,6 +716,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOMEM);
-		return;
+		return ENOMEM;
 	}
 	assert(rootp->idx->index == EXFAT_ROOT_IDX);
@@ -756,6 +733,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
+		return ENOTSUP;
 	}
 	rootp->size = BPS(bs) * SPC(bs) * clusters;
@@ -771,6 +747,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
+		return ENOTSUP;
 	}
 
@@ -782,6 +757,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
+		return ENOTSUP;
 	}
 
@@ -793,6 +767,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOMEM);
-		return;
+		return ENOMEM;
 	}
 	assert(bitmapp->idx->index == EXFAT_BITMAP_IDX);
@@ -815,6 +788,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
+		return ENOTSUP;
 	}
 
@@ -826,6 +798,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
+		return ENOTSUP;
 	}
 
@@ -838,6 +809,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOMEM);
-		return;
+		return ENOMEM;
 	}
 	assert(uctablep->idx->index == EXFAT_UCTABLE_IDX);
@@ -860,6 +830,5 @@
 		block_fini(devmap_handle);
 		exfat_idx_fini_by_devmap_handle(devmap_handle);
-		async_answer_0(rid, ENOMEM);
-		return;
+		return ENOMEM;
 	}
 
@@ -867,15 +836,13 @@
 	printf("Root dir size: %lld\n", rootp->size);
 
-	async_answer_3(rid, EOK, rootp->idx->index, rootp->size, rootp->lnkcnt);
-}
-
-void exfat_mount(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_mount(&exfat_libfs_ops, exfat_reg.fs_handle, rid, request);
-}
-
-void exfat_unmounted(ipc_callid_t rid, ipc_call_t *request)
-{
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	*index = rootp->idx->index;
+	*size = rootp->size;
+	*linkcnt = rootp->lnkcnt;
+	
+	return EOK;
+}
+
+static int exfat_unmounted(devmap_handle_t devmap_handle)
+{
 	fs_node_t *fn;
 	exfat_node_t *nodep;
@@ -883,8 +850,6 @@
 
 	rc = exfat_root_get(&fn, devmap_handle);
-	if (rc != EOK) {
-		async_answer_0(rid, rc);
-		return;
-	}
+	if (rc != EOK)
+		return rc;
 	nodep = EXFAT_NODE(fn);
 
@@ -895,6 +860,5 @@
 	if (nodep->refcnt != 2) {
 		(void) exfat_node_put(fn);
-		async_answer_0(rid, EBUSY);
-		return;
+		return EBUSY;
 	}
 
@@ -915,10 +879,5 @@
 	block_fini(devmap_handle);
 
-	async_answer_0(rid, EOK);
-}
-
-void exfat_unmount(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_unmount(&exfat_libfs_ops, rid, request);
+	return EOK;
 }
 
@@ -942,15 +901,8 @@
 */
 
-void exfat_lookup(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_lookup(&exfat_libfs_ops, exfat_reg.fs_handle, rid, request);
-}
-
-void exfat_read(ipc_callid_t rid, ipc_call_t *request)
-{
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	aoff64_t pos =
-	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+static int
+exfat_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
+    size_t *rbytes)
+{
 	fs_node_t *fn;
 	exfat_node_t *nodep;
@@ -961,12 +913,8 @@
 
 	rc = exfat_node_get(&fn, devmap_handle, index);
-	if (rc != EOK) {
-		async_answer_0(rid, rc);
-		return;
-	}
-	if (!fn) {
-		async_answer_0(rid, ENOENT);
-		return;
-	}
+	if (rc != EOK)
+		return rc;
+	if (!fn)
+		return ENOENT;
 	nodep = EXFAT_NODE(fn);
 
@@ -976,6 +924,5 @@
 		exfat_node_put(fn);
 		async_answer_0(callid, EINVAL);
-		async_answer_0(rid, EINVAL);
-		return;
+		return EINVAL;
 	}
 
@@ -1000,6 +947,5 @@
 				exfat_node_put(fn);
 				async_answer_0(callid, rc);
-				async_answer_0(rid, rc);
-				return;
+				return rc;
 			}
 			(void) async_data_read_finalize(callid,
@@ -1008,6 +954,5 @@
 			if (rc != EOK) {
 				exfat_node_put(fn);
-				async_answer_0(rid, rc);
-				return;
+				return rc;
 			}
 		}
@@ -1015,6 +960,5 @@
 		if (nodep->type != EXFAT_DIRECTORY) {
 			async_answer_0(callid, ENOTSUP);
-			async_answer_0(rid, ENOTSUP);
-			return;
+			return ENOTSUP;
 		}
 			
@@ -1043,6 +987,5 @@
 		(void) exfat_node_put(fn);
 		async_answer_0(callid, rc);
-		async_answer_0(rid, rc);
-		return;
+		return rc;
 
 miss:
@@ -1052,6 +995,6 @@
 		rc = exfat_node_put(fn);
 		async_answer_0(callid, rc != EOK ? rc : ENOENT);
-		async_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
-		return;
+		*rbytes = 0;
+		return rc != EOK ? rc : ENOENT;
 
 hit:
@@ -1065,37 +1008,21 @@
 
 	rc = exfat_node_put(fn);
-	async_answer_1(rid, rc, (sysarg_t)bytes);
-}
-
-void exfat_close(ipc_callid_t rid, ipc_call_t *request)
-{
-	async_answer_0(rid, EOK);
-}
-
-void exfat_open_node(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_open_node(&exfat_libfs_ops, exfat_reg.fs_handle, rid, request);
-}
-
-void exfat_stat(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_stat(&exfat_libfs_ops, exfat_reg.fs_handle, rid, request);
-}
-
-void exfat_sync(ipc_callid_t rid, ipc_call_t *request)
-{
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-
+	*rbytes = bytes;
+	return rc;
+}
+
+static int exfat_close(devmap_handle_t devmap_handle, fs_index_t index)
+{
+	return EOK;
+}
+
+static int exfat_sync(devmap_handle_t devmap_handle, fs_index_t index)
+{
 	fs_node_t *fn;
 	int rc = exfat_node_get(&fn, devmap_handle, index);
-	if (rc != EOK) {
-		async_answer_0(rid, rc);
-		return;
-	}
-	if (!fn) {
-		async_answer_0(rid, ENOENT);
-		return;
-	}
+	if (rc != EOK)
+		return rc;
+	if (!fn)
+		return ENOENT;
 
 	exfat_node_t *nodep = EXFAT_NODE(fn);
@@ -1105,6 +1032,38 @@
 
 	exfat_node_put(fn);
-	async_answer_0(rid, rc);
-}
+	return rc;
+}
+
+static int
+exfat_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
+    size_t *wbytes, aoff64_t *nsize)
+{
+	/* TODO */
+	return EOK;
+}
+
+static int
+exfat_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size)
+{
+	/* TODO */
+	return EOK;
+}
+static int exfat_destroy(devmap_handle_t devmap_handle, fs_index_t index)
+{
+	/* TODO */
+	return EOK;
+}
+
+vfs_out_ops_t exfat_ops = {
+	.mounted = exfat_mounted,
+	.unmounted = exfat_unmounted,
+	.read = exfat_read,
+	.write = exfat_write,
+	.truncate = exfat_truncate,
+	.close = exfat_close,
+	.destroy = exfat_destroy,
+	.sync = exfat_sync,
+};
+
 
 /**
