NAME

Linux::Ext2::FileAttributes - Access to Ext2/3 filesystem extended attributes

SYNOPSIS

use Linux::Ext2::FileAttributes;

my $logfile    = '/var/log/notreal';
my $unchanging = '/etc/motd';

# set immutable flag on $unchanging
set_immutable( $unchanging );

# set append flag on $logfile
set_append_only( $logfile );

# check if a file is immutable
print "[$unchanging] is immutable\n" if is_immutable( $unchanging );

DESCRIPTION

Linux::Ext2::FileAttributes provides access to the Ext2 and Ext3 filesystem extended attributes from within perl.

This module is pure perl and doesn't require or use the external chattr or lsattr binaries which can save a lot of load when doing filesystem traversal and modification

FUNCTIONS

By default this module exports: is_immutable clear_immutable set_immutable is_append_only clear_append_only set_append_only

set_immutable

This function takes a filename and attempts to set its immutable flag.

If this flag is set on a file, even root cannot change the files content without first removing the flag.

is_immutable

This function takes a filename and returns true if the immutable flag is set and false if it isn't.

clear_immutable

This function takes a filename and removes the immutable flag if it is present.

set_append_only

This function takes a filename and attempts to set its appendable flag.

If this flag is set on a file then its contents can be added to but not removed unless the flag is first removed.

is_append_only

This function takes a filename and returns true if the immutable flag is set and false if it isn't.

clear_append_only

This function takes a filename and removes the appendable flag if it is present.

DEPENDENCIES

Linux::Ext2::FileAttributes has no external dependencies.

TESTS

As Linux::Ext2::FileAttributes is something of a niche module, which requires an Ext2/Ext3 file system and root powers to run, I've placed some test longer scripts in the examples directory to both show how to us it and provide another set of tests for detecting regressions.

SEE ALSO

Filesys::Ext2 provides a different interface to some of the same information. That module wraps the command line tools (lsattr and chattr) rather than speaking directly to the ioctl.

http://search.cpan.org/~jpierce/Filesys-Ext2-0.20/Ext2.pm

Native Ext2 commands:

chattr, lsattr

LICENCE AND COPYRIGHT

Copyright (C) 2008 Dean Wilson. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Dean Wilson <dean.wilson@gmail.com>

ACKNOWLEDGEMENTS

Richard Clamp did the heavy lifting on this module and taught me a fair chunk about using ioctls in perl while doing it. The cool stuff's his. The errors are mine.