summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/tftp-hpa/files/fix-writing-emtpy-file.patch
blob: 0b235361c570234cc26213035482338c45f3a51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 1ce974f1cf6afbc528c941a8cdf0817a3fd7c5a7 Mon Sep 17 00:00:00 2001
From: "Roy.Li" <rongqing.li@windriver.com>
Date: Mon, 30 Mar 2026 22:37:22 +0800
Subject: [PATCH] fix the empty file writting

With the feature that checking the disk filled up, the return
value of function write_behind was checked and used to detect
the disk status. While for empty file, without data being
written, this function will return -1 thus the disk filled up
error was miss-raised.

make write_behind to return 0 if written file is empty, to fix
the this bug.

Upstream-Status: Pending

Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
 common/tftpsubs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/tftpsubs.c b/common/tftpsubs.c
index b4ea3f2..30e749a 100644
--- a/common/tftpsubs.c
+++ b/common/tftpsubs.c
@@ -198,9 +198,12 @@ int write_behind(FILE * file, int convert)
     nextone = !nextone;         /* incr for next time */
     buf = dp->th_data;
 
-    if (count <= 0)
+    if (count < 0)
         return -1;              /* nak logic? */
 
+    if (count == 0)
+        return 0;
+
     if (convert == 0)
         return write(fileno(file), buf, count);
 
-- 
2.34.1