[Melbourne-pm] IO::File with Capture for Quota
daniel at rimspace.net
Wed Oct 15 21:04:31 PDT 2008
Toby Corkindale <toby.corkindale at strategicdata.com.au> writes:
>> I am writing a module at the moment to capture IO::File open to allow
>> me to work out the difference in file size at the start and end of an
>> 1) Is there anyway of getting from a file handle:
>> - That it is a file on disk, rather than Socket or Pipe
>> - The filename of that file
> fstat() works upon filehandles directly, avoiding the needing to keep
> the filename around.
Moreover, it avoids the exploit that a user can create a file with two
hard links, open with your tool, then replace the link used as the open
name with a small file, fooling your quota code.
fstat() also allows you to query the nature of the file, and will inform
you of "is it a regular file" or, you know, something else.
>> 2) What else would you change - in functions, calls and purpose to
>> make this a useful CPAN module
> The name of the module implies that it is meant to be performing quota
> management, but the actual action seems to be more like performing a
> generic call-back upon close..
*nod* With additional hooks you could make this a generic mechanism for
implementing file policy, ala IO::AtomicFile, or non-standard stores
such as a user-space HSM implementation.
That would require significantly more hooks, though, and would probably
be harder for many people than just subclassing the module directly.
Are you sure that your needs wouldn't be better served with using
Module::Replace (or the open-coded equivalent) to inject your code into
the target module?
> If you're actually looking to enforce quotas, wouldn't you need to
> check the data written at every write, rather than upon close?
Not necessarily, in their use. In general, this has sufficient weak
spots that it would be hard to say it was generically useful to a wide
range of environments, I suspect.
More information about the Melbourne-pm