[PATCH v1 2/5] makedumpfile: Add tools for reading and writing from block table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function added in this patch, is used for writing and reading value
from the char array in struct Block.

Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
Signed-off-by: Zhou Wenjian <zhouwj-fnst at cn.fujitsu.com>
---
 makedumpfile.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 2feda01..a4cb9b6 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5708,6 +5708,29 @@ calculate_entry_size(void){
 	return entry_size;
 }
 
+void
+write_value_into_block_table(char *block_inner, unsigned long long content)
+{
+	char temp;
+	int i=0;
+	while (i++ < block->entry_size) {
+		temp = content & 0xff;
+		content = content >> BITPERBYTE;
+		*block_inner++ = temp;
+	}
+}
+unsigned long long
+read_value_from_block_table(char *block_inner)
+{
+	unsigned long long ret = 0;
+	int i;
+	for (i = block->entry_size; i > 0; i--) {
+		ret = ret << BITPERBYTE;
+		ret += *(block_inner + i - 1) & 0xff;
+	}
+	return ret;
+}
+
 mdf_pfn_t
 get_num_dumpable(void)
 {
-- 
1.7.1




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux