From 3e3e7af1a49273a5e49d50565b3b079a2ab19142 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 7 May 2020 23:42:12 +1000 Subject: shell: Always use explicit large file API There are some remaining stat/readdir calls in dash that may lead to spurious EOVERFLOW errors on 32-bit platforms. This patch changes them (as well as open(2)) to use the explicit large file API. Reported-by: Tatsuki Sugiura Signed-off-by: Herbert Xu --- src/bltin/test.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/bltin') diff --git a/src/bltin/test.c b/src/bltin/test.c index b7188df..c7fc479 100644 --- a/src/bltin/test.c +++ b/src/bltin/test.c @@ -473,17 +473,17 @@ static int isoperand(char **tp) static int newerf (const char *f1, const char *f2) { - struct stat b1, b2; + struct stat64 b1, b2; #ifdef HAVE_ST_MTIM - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && + return (stat64(f1, &b1) == 0 && + stat64(f2, &b2) == 0 && ( b1.st_mtim.tv_sec > b2.st_mtim.tv_sec || (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec ))) ); #else - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && + return (stat64(f1, &b1) == 0 && + stat64(f2, &b2) == 0 && b1.st_mtime > b2.st_mtime); #endif } @@ -491,17 +491,17 @@ newerf (const char *f1, const char *f2) static int olderf (const char *f1, const char *f2) { - struct stat b1, b2; + struct stat64 b1, b2; #ifdef HAVE_ST_MTIM - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && + return (stat64(f1, &b1) == 0 && + stat64(f2, &b2) == 0 && (b1.st_mtim.tv_sec < b2.st_mtim.tv_sec || (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec < b2.st_mtim.tv_nsec ))) ); #else - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && + return (stat64(f1, &b1) == 0 && + stat64(f2, &b2) == 0 && b1.st_mtime < b2.st_mtime); #endif } @@ -509,10 +509,10 @@ olderf (const char *f1, const char *f2) static int equalf (const char *f1, const char *f2) { - struct stat b1, b2; + struct stat64 b1, b2; - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && + return (stat64(f1, &b1) == 0 && + stat64(f2, &b2) == 0 && b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino); } -- cgit 1.4.1