Index: uspace/srv/fs/udf/udf_file.c
===================================================================
--- uspace/srv/fs/udf/udf_file.c	(revision b7fd2a02e4161f4edd38548e7f8456b8021549be)
+++ uspace/srv/fs/udf/udf_file.c	(revision f1380b76772fb5d1aa03637b5e57bd9b929fea61)
@@ -65,17 +65,17 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	udf_ext_ad_t *exd = (udf_ext_ad_t *) block->data;
 	uint32_t start = node->instance->partitions[
 	    FLE16(exd->extent_location.partition_num)].start +
 	    FLE32(exd->extent_location.lblock_num);
-	
+
 	log_msg(LOG_DEFAULT, LVL_DEBUG,
 	    "Extended allocator: start=%d, block_num=%d, len=%d", start,
 	    FLE32(exd->extent_location.lblock_num), FLE32(exd->info_length));
-	
+
 	uint32_t len = FLE32(exd->info_length);
 	block_put(block);
-	
+
 	return udf_read_allocation_sequence(node, NULL, icb_flag, start, len);
 }
@@ -97,10 +97,10 @@
 {
 	node->alloc_size = 0;
-	
+
 	switch (icb_flag) {
 	case UDF_SHORT_AD:
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
 		    "ICB: sequence of allocation descriptors - icbflag = short_ad_t");
-		
+
 		/*
 		 * Identify number of current partition. Virtual partition
@@ -110,5 +110,5 @@
 		size_t pd_num = (size_t) -1;
 		size_t min_start = 0;
-		
+
 		for (size_t i = 0; i < node->instance->partition_cnt; i++) {
 			if ((node->index >= node->instance->partitions[i].start) &&
@@ -121,8 +121,8 @@
 			}
 		}
-		
+
 		if (pd_num == (size_t) -1)
 			return ENOENT;
-		
+
 		/*
 		 * According to doc, in this we should stop our loop if pass
@@ -133,13 +133,13 @@
 		 * which we check inside of loop.
 		 */
-		
+
 		while (true) {
 			udf_short_ad_t *short_d =
 			    (udf_short_ad_t *) (af + start_alloc +
 			    node->alloc_size * sizeof(udf_short_ad_t));
-			
+
 			if (FLE32(short_d->length) == 0)
 				break;
-			
+
 			/*
 			 * ECMA 167 4/12 - next sequence of allocation descriptors
@@ -152,5 +152,5 @@
 				break;
 			}
-			
+
 			node->allocators = realloc(node->allocators,
 			    (node->alloc_size + 1) * sizeof(udf_allocator_t));
@@ -161,23 +161,23 @@
 			node->alloc_size++;
 		}
-		
+
 		node->allocators = realloc(node->allocators,
 		    node->alloc_size * sizeof(udf_allocator_t));
 		break;
-		
+
 	case UDF_LONG_AD:
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
 		    "ICB: sequence of allocation descriptors - icbflag = long_ad_t");
-		
+
 		while (true) {
 			udf_long_ad_t *long_d =
 			    (udf_long_ad_t *) (af + start_alloc +
 			    node->alloc_size * sizeof(udf_long_ad_t));
-			
+
 			if (FLE32(long_d->length) == 0)
 				break;
-			
+
 			uint32_t pos_long_ad = udf_long_ad_to_pos(node->instance, long_d);
-			
+
 			/*
 			 * ECMA 167 4/12 - next sequence of allocation descriptors
@@ -188,5 +188,5 @@
 				break;
 			}
-			
+
 			node->allocators = realloc(node->allocators,
 			    (node->alloc_size + 1) * sizeof(udf_allocator_t));
@@ -194,30 +194,30 @@
 			    EXT_LENGTH(FLE32(long_d->length));
 			node->allocators[node->alloc_size].position = pos_long_ad;
-			
+
 			node->alloc_size++;
 		}
-		
+
 		node->allocators = realloc(node->allocators,
 		    node->alloc_size * sizeof(udf_allocator_t));
 		break;
-		
+
 	case UDF_EXTENDED_AD:
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
 		    "ICB: sequence of allocation descriptors - icbflag = extended_ad_t");
 		break;
-		
+
 	case UDF_DATA_AD:
 		log_msg(LOG_DEFAULT, LVL_DEBUG,
 		    "ICB: sequence of allocation descriptors - icbflag = 3, node contains data itself");
-		
+
 		node->data = malloc(node->data_size);
 		if (!node->data)
 			return ENOMEM;
-		
+
 		memcpy(node->data, (af + start_alloc), node->data_size);
 		node->alloc_size = 0;
 		break;
 	}
-	
+
 	return EOK;
 }
@@ -237,5 +237,5 @@
 	while (true) {
 		fs_index_t pos = node->index;
-		
+
 		block_t *block = NULL;
 		errno_t rc = block_get(&block, node->instance->service_id, pos,
@@ -243,5 +243,5 @@
 		if (rc != EOK)
 			return rc;
-		
+
 		udf_descriptor_tag_t *data = (udf_descriptor_tag_t *) block->data;
 		if (data->checksum != udf_tag_checksum((uint8_t *) data)) {
@@ -249,10 +249,10 @@
 			return EINVAL;
 		}
-		
+
 		/* One sector size descriptors */
 		switch (FLE16(data->id)) {
 		case UDF_FILE_ENTRY:
 			log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: File entry descriptor found");
-			
+
 			udf_file_entry_descriptor_t *file =
 			    (udf_file_entry_descriptor_t *) block->data;
@@ -260,13 +260,13 @@
 			node->data_size = FLE64(file->info_lenght);
 			node->type = (file->icbtag.file_type == UDF_ICBTYPE_DIR) ? NODE_DIR : NODE_FILE;
-			
+
 			rc = udf_read_allocation_sequence(node, (uint8_t *) file, icb_flag,
 			    FLE32(file->ea_lenght) + UDF_FE_OFFSET, FLE32(file->ad_lenght));
 			block_put(block);
 			return rc;
-			
+
 		case UDF_EFILE_ENTRY:
 			log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: Extended file entry descriptor found");
-			
+
 			udf_extended_file_entry_descriptor_t *efile =
 			    (udf_extended_file_entry_descriptor_t *) block->data;
@@ -274,10 +274,10 @@
 			node->data_size = FLE64(efile->info_lenght);
 			node->type = (efile->icbtag.file_type == UDF_ICBTYPE_DIR) ? NODE_DIR : NODE_FILE;
-			
+
 			rc = udf_read_allocation_sequence(node, (uint8_t *) efile, icb_flag,
 			    FLE32(efile->ea_lenght) + UDF_EFE_OFFSET, FLE32(efile->ad_lenght));
 			block_put(block);
 			return rc;
-			
+
 		case UDF_ICB_TERMINAL:
 			log_msg(LOG_DEFAULT, LVL_DEBUG, "ICB: Terminal entry descriptor found");
@@ -285,12 +285,12 @@
 			return EOK;
 		}
-		
+
 		pos++;
-		
+
 		rc = block_put(block);
 		if (rc != EOK)
 			return rc;
 	}
-	
+
 	return EOK;
 }
@@ -323,5 +323,5 @@
 	size_t fid_sum = 0;
 	size_t n = 0;
-	
+
 	while (node->data_size - fid_sum >= MIN_FID_LEN) {
 		udf_descriptor_tag_t *desc =
@@ -333,8 +333,8 @@
 				return ENOENT;
 		}
-		
+
 		*fid = (udf_file_identifier_descriptor_t *)
 		    (node->data + fid_sum);
-		
+
 		/* According to ECMA 167 4/14.4.9 */
 		size_t padding = 4 * (((*fid)->lenght_file_id +
@@ -343,17 +343,17 @@
 		size_t size_fid = (*fid)->lenght_file_id +
 		    FLE16((*fid)->lenght_iu) + padding + 38;
-		
+
 		fid_sum += size_fid;
-		
+
 		/* aAcording to ECMA 167 4/8.6 */
 		if (((*fid)->lenght_file_id != 0) &&
 		    (((*fid)->file_characteristics & 4) == 0)) {
 			n++;
-			
+
 			if (n == pos + 1)
 				return EOK;
 		}
 	}
-	
+
 	return ENOENT;
 }
@@ -374,5 +374,5 @@
 	if (node->data == NULL)
 		return udf_get_fid_in_allocator(fid, block, node, pos);
-	
+
 	return udf_get_fid_in_data(fid, node, pos);
 }
@@ -392,11 +392,11 @@
 {
 	void *buf = malloc(node->instance->sector_size);
-	
+
 	// FIXME: Check for NULL return value
-	
+
 	size_t j = 0;
 	size_t n = 0;
 	size_t len = 0;
-	
+
 	while (j < node->alloc_size) {
 		size_t i = 0;
@@ -408,5 +408,5 @@
 				return rc;
 			}
-			
+
 			/*
 			 * Last item in allocator is a part of sector. We take
@@ -422,5 +422,5 @@
 				break;
 			}
-			
+
 			rc = udf_get_fid_in_sector(fid, block, node, pos, &n, &buf, &len);
 			if (rc == EOK) {
@@ -428,29 +428,29 @@
 				return EOK;
 			}
-			
+
 			if (rc == EINVAL) {
 				// FIXME: Memory leak
 				return ENOENT;
 			}
-			
+
 			if (rc == ENOENT) {
 				if (block) {
 					rc = block_put(*block);
 					*block = NULL;
-					
+
 					if (rc != EOK)
 						return rc;
 				}
 			}
-			
+
 			i++;
 		}
-		
+
 		j++;
 	}
-	
+
 	if (buf)
 		free(buf);
-	
+
 	return ENOENT;
 }
@@ -474,9 +474,9 @@
 {
 	void *fidbuf = malloc(node->instance->sector_size);
-	
+
 	// FIXME: Check for NULL return value
-	
+
 	bool buf_flag;
-	
+
 	if (*len > 0) {
 		memcpy(fidbuf, *buf, *len);
@@ -484,10 +484,10 @@
 	} else
 		buf_flag = false;
-	
+
 	size_t fid_sum = 0;
 	while (node->instance->sector_size - fid_sum > 0) {
 		if (node->instance->sector_size - fid_sum >= MIN_FID_LEN) {
 			void *fid_data;
-			
+
 			if (buf_flag) {
 				memcpy((fidbuf + *len), (*block)->data,
@@ -496,12 +496,12 @@
 			} else
 				fid_data = (*block)->data + fid_sum;
-			
+
 			udf_descriptor_tag_t *desc =
 			    (udf_descriptor_tag_t *) fid_data;
-			
+
 			if (desc->checksum != udf_tag_checksum((uint8_t *) desc)) {
 				if (fidbuf)
 					free(fidbuf);
-				
+
 				if (*buf) {
 					free(*buf);
@@ -509,10 +509,10 @@
 					*len = 0;
 				}
-				
+
 				return EINVAL;
 			}
-			
+
 			*fid = (udf_file_identifier_descriptor_t *) fid_data;
-			
+
 			/* According to ECMA 167 4/14.4.9 */
 			size_t padding = 4 * (((*fid)->lenght_file_id +
@@ -525,5 +525,5 @@
 			else
 				fid_sum += size_fid;
-			
+
 			/* According to ECMA 167 4/8.6 */
 			if (((*fid)->lenght_file_id != 0) &&
@@ -533,9 +533,9 @@
 					if (fidbuf)
 						free(fidbuf);
-					
+
 					return EOK;
 				}
 			}
-			
+
 			if (fidbuf) {
 				buf_flag = false;
@@ -543,5 +543,5 @@
 				fidbuf = NULL;
 			}
-			
+
 			if (*buf) {
 				free(*buf);
@@ -552,14 +552,14 @@
 			if (*buf)
 				free(*buf);
-			
+
 			*len = node->instance->sector_size - fid_sum;
 			*buf = malloc(*len);
 			buf_flag = false;
 			memcpy(*buf, ((*block)->data + fid_sum), *len);
-			
+
 			return ENOENT;
 		}
 	}
-	
+
 	return ENOENT;
 }
@@ -581,5 +581,5 @@
 	size_t i = 0;
 	size_t l = 0;
-	
+
 	while (i < node->alloc_size) {
 		if (pos >= l + node->allocators[i].length) {
@@ -589,8 +589,8 @@
 			break;
 	}
-	
+
 	size_t sector_cnt = ALL_UP(l, node->instance->sector_size);
 	size_t sector_num = pos / node->instance->sector_size;
-	
+
 	block_t *block = NULL;
 	errno_t rc = block_get(&block, node->instance->service_id,
@@ -601,12 +601,12 @@
 		return rc;
 	}
-	
+
 	size_t sector_pos = pos % node->instance->sector_size;
-	
+
 	if (sector_pos + len < node->instance->sector_size)
 		*read_len = len;
 	else
 		*read_len = node->instance->sector_size - sector_pos;
-	
+
 	if (ALL_UP(node->allocators[i].length, node->instance->sector_size) ==
 	    sector_num - sector_cnt + 1) {
@@ -618,5 +618,5 @@
 			*read_len = len;
 	}
-	
+
 	async_data_read_finalize(callid, block->data + sector_pos, *read_len);
 	return block_put(block);
