Steve Lord wrote:
On Fri, 2002-10-04 at 13:21, Joe Bacom wrote:
> As I said in my earlier message, I make extensive use of extended attributes
> and I need to monitor how much metadata I have stored on disk.
[snip]
> Basically: how much metadata (in bytes, kb, or mb) do I have sitting on the
> disk.
Here's two more approaches, they are slow in that they are per-file
operations, but
they will give you the data I think you're looking for. If you want filesystem
totals,
then the techniques Steve gave are probably better than this (certainly faster).
Assuming that the data files you are working with do not have holes (ie: not
sparse),
you can use this on each file: (stat.st_blocks - (stat.st_size/512))
That number will include all the metadata associated with a file, not just the
extended
attributes, but it will be close.
If the data files have holes, the operation to list the attributes of a file
will give
you the size (in bytes) of each attribute. Adding those numbers will not
include the
extra bytes needed to store those attributes, but it will get you close. You
can even
cache the results by creating a new attribute that contains a timestamp and the
total
size. If I remember correctly, doing any mods to attributes updates the
"ctime" for
the inode, so you should be able to compare that timestamp against the "ctime"
of the
inode and only recalculate if the attributes have changed.
I hope this helps...
Thanks,
Curtis
--
Curtis Anderson Dir. of S/W and Dev. curtis@xxxxxxx
|