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