1[PATCH] fix the empty file writting
2
3Upstream-Status: Pending
4
5With the feature that checking the disk filled up, the return
6value of function write_behind was checked and used to detect
7the disk status. While for empty file, without data being
8written, this function will return -1 thus the disk filled up
9error was miss-raised.
10
11make write_behind to return 0 if written file is empty, to fix
12the this bug.
13
14Signed-off-by: Roy.Li <rongqing.li@windriver.com>
15---
16 common/tftpsubs.c | 5 ++++-
17 1 file changed, 4 insertions(+), 1 deletion(-)
18
19diff --git a/common/tftpsubs.c b/common/tftpsubs.c
20index b4ea3f2..9f6cafc 100644
21--- a/common/tftpsubs.c
22+++ b/common/tftpsubs.c
23@@ -198,9 +198,12 @@ int write_behind(FILE * file, int convert)
24     nextone = !nextone;         /* incr for next time */
25     buf = dp->th_data;
26
27-    if (count <= 0)
28+    if (count < 0)
29         return -1;              /* nak logic? */
30
31+    if (count == 0)
32+        return 0;
33+
34     if (convert == 0)
35         return write(fileno(file), buf, count);
36
37--
381.9.1
39
40