From 1ee76343c6154616b6c9df55d046ca92897f12c4 Mon Sep 17 00:00:00 2001 From: jay Date: Sun, 27 May 2007 11:04:23 +0000 Subject: [PATCH] If a system has no st_blocks member in struct stat, we assume files have a sparseness of 1.0 --- ChangeLog | 2 ++ find/find.1 | 3 ++- find/pred.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2f565c4..d62db65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * find/pred.c (mode_to_filetype): Don't use S_IFSOCK on systems which lack that macro. POSIX systems are allowed to lack sockets (it's an XSI extension). + (file_sparseness): If struct stat lacks st_blocks, assume all + files have a spearseness of 1.0. * import-gnulib.config (modules): Import fchdir inorder to fix an undefined-symbol error for fchdir on BeOS. diff --git a/find/find.1 b/find/find.1 index 90e4710..84af404 100644 --- a/find/find.1 +++ b/find/find.1 @@ -939,7 +939,8 @@ certain length is system-dependent. However, normally sparse files will have values less than 1.0, and files which use indirect blocks may have a value which is greater than 1.0. The value used for BLOCKSIZE is system-dependent, but is usually 512 bytes. If the file -size is zero, the value printed is undefined. +size is zero, the value printed is undefined. On systems which lack +support for st_blocks, a file's sparseness is assumed to be 1.0. .IP %t File's last modification time in the format returned by the C `ctime' function. diff --git a/find/pred.c b/find/pred.c index b3598b8..ab5536a 100644 --- a/find/pred.c +++ b/find/pred.c @@ -626,6 +626,7 @@ mode_to_filetype(mode_t m) static double file_sparseness(const struct stat *p) { +#if defined(HAVE_STRUCT_STAT_ST_BLOCKS) if (0 == p->st_size) { if (0 == p->st_blocks) @@ -638,6 +639,9 @@ file_sparseness(const struct stat *p) double blklen = file_blocksize(p) * (double)p->st_blocks; return blklen / p->st_size; } +#else + return 1.0; +#endif } -- 2.11.4.GIT