blob: 4f3dcd7767f85d980ab13dd9e528f9857e15d130 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001[PATCH] fix the empty file writting
2
Andrew Geissler6aa7eec2023-03-03 12:41:14 -06003Upstream-Status: Pending
Patrick Williamsb48b7b42016-08-17 15:04:38 -05004
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