Index: uspace/srv/fs/ext4fs/ext4fs.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs.c	(revision 7eb033ce26d136253e30c087e3f152a1089e3fed)
+++ uspace/srv/fs/ext4fs/ext4fs.c	(revision 1fff583923015985de7fe1104a1e764f95fd076d)
@@ -53,4 +53,8 @@
 };
 
+/**
+ * Entry point of ext4fs server.
+ * Initialize data structures and IPC, then accepts connections in server mode.
+ */
 int main(int argc, char **argv)
 {
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 7eb033ce26d136253e30c087e3f152a1089e3fed)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 1fff583923015985de7fe1104a1e764f95fd076d)
@@ -55,4 +55,7 @@
 #define OPEN_NODES_BUCKETS 256
 
+/**
+ * Type for holding an instance of mounted partition.
+ */
 typedef struct ext4fs_instance {
 	link_t link;
@@ -62,4 +65,7 @@
 } ext4fs_instance_t;
 
+/**
+ * Type for wrapping common fs_node and add some useful pointers.
+ */
 typedef struct ext4fs_node {
 	ext4fs_instance_t *instance;
@@ -70,7 +76,5 @@
 } ext4fs_node_t;
 
-/*
- * Forward declarations of auxiliary functions
- */
+// Forward declarations of auxiliary functions
 
 static int ext4fs_read_directory(ipc_callid_t, aoff64_t, size_t,
@@ -83,7 +87,6 @@
 static int ext4fs_node_put_core(ext4fs_node_t *);
 
-/*
- * Forward declarations of EXT4 libfs operations.
- */
+// Forward declarations of EXT4 libfs operations.
+
 static int ext4fs_root_get(fs_node_t **, service_id_t);
 static int ext4fs_match(fs_node_t **, fs_node_t *, const char *);
@@ -103,7 +106,6 @@
 static service_id_t ext4fs_service_get(fs_node_t *node);
 
-/*
- * Static variables
- */
+// Static variables
+
 static LIST_INITIALIZE(instance_list);
 static FIBRIL_MUTEX_INITIALIZE(instance_list_mutex);
@@ -118,4 +120,8 @@
 }
 
+/** Compare given item with values in hash table.
+ *
+ * @return	bool result of compare operation
+ */
 static int open_nodes_compare(unsigned long key[], hash_count_t keys,
     link_t *item)
@@ -134,4 +140,7 @@
 }
 
+/** Empty callback to correct hash table initialization.
+ *
+ */
 static void open_nodes_remove_cb(link_t *link)
 {
@@ -146,4 +155,10 @@
 
 
+/** Basic initialization of the driver.
+ *
+ * There is only needed to create hash table for storing open nodes.
+ *
+ * @return	error code
+ */
 int ext4fs_global_init(void)
 {
@@ -155,5 +170,10 @@
 }
 
-
+/* Finalization of the driver.
+ *
+ * There is only needed to destroy hash table.
+ *
+ * @return	error code
+ */
 int ext4fs_global_fini(void)
 {
@@ -167,4 +187,10 @@
  */
 
+/** Get instance from internal table by service_id.
+ *
+ * @param service_id	device identifier
+ * @param inst		output instance if successful operation
+ * @return		error code
+ */
 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst)
 {
@@ -192,4 +218,10 @@
 
 
+/** Get root node of filesystem specified by service_id.
+ * 
+ * @param rfn		output pointer to loaded node
+ * @param service_id	device to load root node from
+ * @return		error code
+ */
 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id)
 {
@@ -197,5 +229,13 @@
 }
 
-
+/** Check if specified name (component) matches with any directory entry.
+ * 
+ * If match is found, load and return matching node.
+ *
+ * @param rfn		output pointer to node if operation successful
+ * @param pfn		parent directory node
+ * @param component	name to check directory for
+ * @return 		error code
+ */
 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
 {
@@ -235,5 +275,13 @@
 }
 
-
+/** Get node specified by index
+ *
+ * It's wrapper for node_put_core operation
+ *
+ * @param rfn		output pointer to loaded node if operation successful
+ * @param service_id	device identifier
+ * @param index		node index (here i-node number)
+ * @return		error code
+ */
 int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
 {
@@ -249,5 +297,11 @@
 }
 
-
+/** Main function for getting node from the filesystem. 
+ *
+ * @param rfn		output point to loaded node if operation successful
+ * @param inst		instance of filesystem
+ * @param index		index of node (i-node number)
+ * @return 		error code
+ */
 int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst,
 		fs_index_t index)
@@ -274,4 +328,5 @@
 	}
 
+	// Prepare new enode
 	enode = malloc(sizeof(ext4fs_node_t));
 	if (enode == NULL) {
@@ -288,4 +343,5 @@
 	fs_node_initialize(fs_node);
 
+	// Load inode from filesystem
 	ext4_inode_ref_t *inode_ref;
 	rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref);
@@ -297,4 +353,5 @@
 	}
 
+	// Initialize enode
 	enode->inode_ref = inode_ref;
 	enode->instance = inst;
@@ -314,5 +371,9 @@
 }
 
-
+/** Put previously loaded node.
+ *
+ * @param enode		node to put back
+ * @return		error code
+ */
 int ext4fs_node_put_core(ext4fs_node_t *enode)
 {
@@ -327,4 +388,5 @@
 	enode->instance->open_nodes_count--;
 
+	// Put inode back in filesystem
 	rc = ext4_filesystem_put_inode_ref(enode->inode_ref);
 	if (rc != EOK) {
@@ -332,4 +394,5 @@
 	}
 
+	// Destroy data structure
 	free(enode->fs_node);
 	free(enode);
@@ -339,4 +402,11 @@
 
 
+/** Open node.
+ *
+ * This operation is stateless in this driver.
+ *
+ * @param fn 	node to open
+ * @return	error code (EOK)
+ */
 int ext4fs_node_open(fs_node_t *fn)
 {
@@ -345,4 +415,12 @@
 }
 
+
+/** Put previously loaded node.
+ *
+ * It's wrapper for node_put_core operation
+ *
+ * @param fn 	node to put back
+ * @return 	error code
+ */
 int ext4fs_node_put(fs_node_t *fn)
 {
@@ -368,8 +446,16 @@
 
 
+/** Create new node in filesystem.
+ *
+ * @param rfn		output pointer to newly created node if successful
+ * @param service_id	device identifier, where the filesystem is
+ * @param flags		flags for specification of new node parameters
+ * @return		error code
+ */
 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
 {
 	int rc;
 
+	// Allocate node structures
 	ext4fs_node_t *enode;
 	enode = malloc(sizeof(ext4fs_node_t));
@@ -385,4 +471,5 @@
 	}
 
+	// Load instance
 	ext4fs_instance_t *inst;
 	rc = ext4fs_instance_get(service_id, &inst);
@@ -393,4 +480,5 @@
 	}
 
+	// Allocate new i-node in filesystem
 	ext4_inode_ref_t *inode_ref;
 	rc = ext4_filesystem_alloc_inode(inst->filesystem, &inode_ref, flags);
@@ -401,4 +489,5 @@
 	}
 
+	// Do some interconnections in references
 	enode->inode_ref = inode_ref;
 	enode->instance = inst;
@@ -428,8 +517,14 @@
 
 
+/** Destroy existing node.
+ *
+ * @param fs	node to destroy
+ * @return	error code
+ */
 int ext4fs_destroy_node(fs_node_t *fn)
 {
 	int rc;
 
+	// If directory, check for children
 	bool has_children;
 	rc = ext4fs_has_children(&has_children, fn);
@@ -448,4 +543,5 @@
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
 
+	// Release data blocks
 	rc = ext4_filesystem_truncate_inode(inode_ref, 0);
 	if (rc != EOK) {
@@ -454,4 +550,5 @@
 	}
 
+	// Handle orphans
 	uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock);
 	if (rev_level > 0) {
@@ -459,5 +556,5 @@
 	}
 
-	// TODO set real deletion time
+	// TODO set real deletion time when it will be supported
 //	time_t now = time(NULL);
 	time_t now = ext4_inode_get_change_inode_time(inode_ref->inode);
@@ -465,4 +562,5 @@
 	inode_ref->dirty = true;
 
+	// Free inode
 	rc = ext4_filesystem_free_inode(inode_ref);
 	if (rc != EOK) {
@@ -476,4 +574,11 @@
 
 
+/** Link the specfied node to directory.
+ *
+ * @param pfn		parent node to link in
+ * @param cfn		node to be linked
+ * @param name		name which will be assigned to directory entry
+ * @return		error code
+ */
 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
 {
@@ -510,4 +615,5 @@
 		}
 
+		// Initialize directory index if necessary
 //		if (ext4_superblock_has_feature_compatible(
 //				fs->superblock, EXT4_FEATURE_COMPAT_DIR_INDEX)) {
@@ -540,4 +646,11 @@
 
 
+/** Unlink node from specified directory.
+ *
+ * @param pfn		parent node to delete node from
+ * @param cfn		child node to be unlinked from directory
+ * @param name		name of entry that will be removed
+ * @return		error code
+ */
 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *name)
 {
@@ -606,4 +719,12 @@
 
 
+/** Check if specified node has children.
+ * 
+ * For files is response allways false and check is executed only for directories.
+ *
+ * @param has_children		output value for response
+ * @param fn			node to check
+ * @return 			error code
+ */
 int ext4fs_has_children(bool *has_children, fs_node_t *fn)
 {
@@ -613,4 +734,5 @@
 	ext4_filesystem_t *fs = enode->instance->filesystem;
 
+	// Check if node is directory
 	if (!ext4_inode_is_type(fs->superblock, enode->inode_ref->inode,
 	    EXT4_INODE_MODE_DIRECTORY)) {
@@ -655,4 +777,9 @@
 
 
+/** Unpack index number from node.
+ *	
+ * @param fn	node to load index from
+ * @return	index number of i-node
+ */
 fs_index_t ext4fs_index_get(fs_node_t *fn)
 {
@@ -662,4 +789,9 @@
 
 
+/** Get real size of file / directory.
+ *
+ * @param fn	node to get size of
+ * @return 	real size of node
+ */
 aoff64_t ext4fs_size_get(fs_node_t *fn)
 {
@@ -670,4 +802,9 @@
 
 
+/** Get number of links to specified node.
+ *
+ * @param fn	node to get links to
+ * @return	number of links
+ */
 unsigned ext4fs_lnkcnt_get(fs_node_t *fn)
 {
@@ -688,4 +825,9 @@
 
 
+/** Check if node is directory.
+ *
+ * @param fn	node to check
+ * @return 	result of check
+ */
 bool ext4fs_is_directory(fs_node_t *fn)
 {
@@ -697,4 +839,9 @@
 
 
+/** Check if node is regular file.
+ *
+ * @param fn	node to check
+ * @return	result of check
+ */
 bool ext4fs_is_file(fs_node_t *fn)
 {
@@ -705,5 +852,9 @@
 }
 
-
+/** Extract device identifier from node.
+ *
+ * @param node	node to extract id from
+ * @return 	id of device, where is the filesystem
+ */
 service_id_t ext4fs_service_get(fs_node_t *fn)
 {
@@ -739,4 +890,15 @@
  */
 
+/** Mount operation. 
+ *
+ * Try to mount specified filesystem from device.
+ * 
+ * @param service_id	identifier of device
+ * @param opts		mount options
+ * @param index		TODO
+ * @param size		TODO
+ * @param lnkcnt	TODO
+ * @return		error code
+ */
 static int ext4fs_mounted(service_id_t service_id, const char *opts,
    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
@@ -816,5 +978,11 @@
 }
 
-
+/** Unmount operation.
+ *
+ * Correctly release the filesystem.
+ *
+ * @param service_id	device to be unmounted
+ * @return 		error code
+ */
 static int ext4fs_unmounted(service_id_t service_id)
 {
@@ -845,4 +1013,12 @@
 
 
+/** Read bytes from node.
+ *
+ * @param service_id	device to read data from
+ * @param index		number of node to read from
+ * @param pos		position where the read should be started
+ * @param rbytes	output value, where the real size was returned
+ * @return 		error code
+ */
 static int ext4fs_read(service_id_t service_id, fs_index_t index,
 		aoff64_t pos, size_t *rbytes)
@@ -867,4 +1043,5 @@
 	}
 
+	// Load i-node
 	ext4_inode_ref_t *inode_ref;
 	rc = ext4_filesystem_get_inode_ref(inst->filesystem, index, &inode_ref);
@@ -874,4 +1051,5 @@
 	}
 
+	// Read from i-node by type
 	if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode,
 			EXT4_INODE_MODE_FILE)) {
@@ -893,4 +1071,10 @@
 }
 
+/** Check if filename is dot or dotdot (reserved names).
+ *
+ * @param name		name to check
+ * @param name_size	length of string name
+ * @return 		result of the check
+ */
 bool ext4fs_is_dots(const uint8_t *name, size_t name_size)
 {
@@ -906,4 +1090,14 @@
 }
 
+/** Read data from directory.
+ *
+ * @param callid	IPC id of call (for communication)
+ * @param pos		position to start reading from
+ * @param size		how many bytes to read
+ * @param inst		filesystem instance
+ * @param inode_ref	node to read data from
+ * @param rbytes	output value to return real number of bytes was read
+ * @return 		error code
+ */
 int ext4fs_read_directory(ipc_callid_t callid, aoff64_t pos, size_t size,
     ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
@@ -977,4 +1171,5 @@
 	}
 
+	// Prepare return values
 	if (found) {
 		*rbytes = next - pos;
@@ -986,4 +1181,15 @@
 }
 
+
+/** Read data from file.
+ *
+ * @param callid        IPC id of call (for communication)
+ * @param pos           position to start reading from
+ * @param size          how many bytes to read
+ * @param inst          filesystem instance
+ * @param inode_ref     node to read data from
+ * @param rbytes        output value to return real number of bytes was read
+ * @return              error code
+ */
 int ext4fs_read_file(ipc_callid_t callid, aoff64_t pos, size_t size,
     ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes)
@@ -1063,4 +1269,14 @@
 }
 
+
+/** Write bytes to file
+ *
+ * @param service_id	device identifier
+ * @param index		i-node number of file
+ * @param pos		position in file to start reading from
+ * @param wbytes	TODO
+ * @param nsize		TODO
+ * @return 		error code
+ */
 static int ext4fs_write(service_id_t service_id, fs_index_t index,
 		aoff64_t pos, size_t *wbytes, aoff64_t *nsize)
@@ -1100,4 +1316,5 @@
 	uint32_t fblock;
 
+	// Load inode
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
 	rc = ext4_filesystem_get_inode_data_block_index(inode_ref, iblock, &fblock);
@@ -1108,4 +1325,5 @@
 	}
 
+	// Check for sparse file
 	if (fblock == 0) {
 
@@ -1145,4 +1363,5 @@
 	}
 
+	// Load target block
 	block_t *write_block;
 	rc = block_get(&write_block, service_id, fblock, flags);
@@ -1171,4 +1390,5 @@
 	}
 
+	// Do some counting
 	uint32_t old_inode_size = ext4_inode_get_size(fs->superblock, inode_ref->inode);
 	if (pos + bytes > old_inode_size) {
@@ -1184,4 +1404,13 @@
 
 
+/** Truncate file.
+ *
+ * Only the direction to shorter file is supported.
+ *
+ * @param service_id	device identifier
+ * @param index		index if node to truncated
+ * @param new_size	new size of file
+ * @return		error code
+ */
 static int ext4fs_truncate(service_id_t service_id, fs_index_t index,
 		aoff64_t new_size)
@@ -1205,4 +1434,10 @@
 
 
+/** Close file.
+ *'
+ * @param service_id	device identifier
+ * @param index		i-node number
+ * @return 		error code
+ */
 static int ext4fs_close(service_id_t service_id, fs_index_t index)
 {
@@ -1211,4 +1446,10 @@
 
 
+/** Destroy node specified by index.
+ *
+ * @param service_id	device identifier
+ * @param index		number of i-node to destroy
+ * @return		error code
+ */
 static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
 {
@@ -1225,5 +1466,9 @@
 }
 
-
+/** Enforce inode synchronization (write) to device. 
+ *
+ * @param service_id 	device identifier
+ * @param index		i-node number.
+ */
 static int ext4fs_sync(service_id_t service_id, fs_index_t index)
 {
@@ -1242,4 +1487,7 @@
 }
 
+/** VFS operations
+ *
+ */
 vfs_out_ops_t ext4fs_ops = {
 	.mounted = ext4fs_mounted,
