Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | [PATCH] fix the empty file writting |
| 2 | |
| 3 | Upstream-Status: pending |
| 4 | |
| 5 | With the feature that checking the disk filled up, the return |
| 6 | value of function write_behind was checked and used to detect |
| 7 | the disk status. While for empty file, without data being |
| 8 | written, this function will return -1 thus the disk filled up |
| 9 | error was miss-raised. |
| 10 | |
| 11 | make write_behind to return 0 if written file is empty, to fix |
| 12 | the this bug. |
| 13 | |
| 14 | Signed-off-by: Roy.Li <rongqing.li@windriver.com> |
| 15 | --- |
| 16 | common/tftpsubs.c | 5 ++++- |
| 17 | 1 file changed, 4 insertions(+), 1 deletion(-) |
| 18 | |
| 19 | diff --git a/common/tftpsubs.c b/common/tftpsubs.c |
| 20 | index 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 | -- |
| 38 | 1.9.1 |
| 39 | |