bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] -sparse predicate


From: James Youngman
Subject: Re: [patch] -sparse predicate
Date: Sat, 11 Nov 2006 14:10:49 +0000

On 11/9/06, dean gaudet <address@hidden> wrote:
this patch adds a -sparse predicate which is true iff the object is a file
and the size is greater than the number of blocks * blocksize can
represent.

That's a good idea.    Thanks for contributing it.  Thanks also for
providing the patch.

 boolean
+pred_sparse (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+{
+  (void) pathname;
+  (void) pred_ptr;
+
+  return S_ISREG (stat_buf->st_mode)
+    && (stat_buf->st_size > stat_buf->st_blocks * stat_buf->st_blksize);
+}

Actually, the units in which st_blocks is measures are not st_blksize.
All that st_blksize tells you is a "preferred" IO request size for
efficient I/O.  See the RATIONALE section of
http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html

Anyway, that problem is easily fixed I think, since gnulib already has
a way of figuring out the system's block size.

I suspect that it may still not work properly with HPUX over NFS, but
that could be fixed by now on moden HPUX versions.   See
http://groups-beta.google.com/group/comp.unix.programmer/browse_thread/thread/eec69327d8110443/10d8317e22f9068f?hl=en

Thanks again for the contribution.   At a guess, I would say that it's
likely to make it into findutils 4.3.2.   It's unlikely to appear in
4.2.x because I'm pretty much trying to limit changes in those
releases to just bugfixes.

James.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]