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