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