HarryWei / cloudxy

Automatically exported from code.google.com/p/cloudxy
6 stars 3 forks source link

[BUG]unit-test for hlfs_take_snapshot get the incorrect results #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
0. mkdir /tmp/testenv && mkdir /tmp/unittest
1. cd snapshot/build && cmake ../src && ./build_local.sh
2. cd ../src/snapshot/unittest/build/  &&  cmake ..
3. ./test
4. cd /tmp/testenv/testfs && cat snapshot.txt

[NOTE]This is in our snapshot branch, so you must download its all sources.

What is the expected output? What do you see instead?
expected output
================
+snapshot0#18446744071634696256#8240#
+ #18446744071634696300#16660#
++#18446744071634696345#25080#
+##@#18446744071634696380#33500#
+..#18446744071634696424#41920#
+ **#18446744071634696469#50340#
+1234#18446744071634696524#58760#

see instead
============
+snapshot#18446744071634696256#8240#
+#18446744071634696300#16660#
+#18446744071634696345#25080#
+###18446744071634696380#33500#
+.#18446744071634696424#41920#
+ *#18446744071634696469#50340#
+123#18446744071634696524#58760#

Please use labels and text to provide additional information.
Please see the snapshot branch for details.

Original issue reported on code.google.com by harryxi...@gmail.com on 28 Dec 2011 at 11:17

GoogleCodeExporter commented 9 years ago
Index: src/snapshot/hlfs_take_snapshot.c
===================================================================
--- src/snapshot/hlfs_take_snapshot.c   (版本 255)
+++ src/snapshot/hlfs_take_snapshot.c   (版本 256)
@@ -11,6 +11,7 @@
 #include "snapshot.h"
 #include "storage_helper.h"
 #include "hlfs_log.h"
+#include "misc.h"

 int hlfs_take_snapshot(struct hlfs_ctrl *ctrl, const char *ssname)
 {
@@ -25,7 +26,7 @@
        return -1;
    }
    cp->timestamp = get_current_time();
-   g_strlcpy(cp->sname,ssname,strlen(ssname));
+   g_strlcpy(cp->sname,ssname,HLFS_FILE_NAME_MAX);
    cp->inode_addr = ctrl->imap_entry.inode_addr;
     g_mutex_lock (ctrl->hlfs_access_mutex);
    ret = dump_snapshot(ctrl->storage,SNAPSHOT_FILE,cp);

Original comment by harryxi...@gmail.com on 28 Dec 2011 at 12:04