#include #include #include #include #include #include #include #include "vutil.h" #include "linux/inode.h" #if 0 // Patch to help compile this utility on unpatched kernel source #ifndef EXT2_IMMUTABLE_FILE_FL #define EXT2_IMMUTABLE_FILE_FL 0x00000010 #define EXT2_IMMUTABLE_LINK_FL24 0x00008000 #define EXT2_IMMUTABLE_LINK_FL 0x00010000 #endif #endif /* Get the extended attributes of a file */ static int getext2flags (const char *fname, unsigned &flags) { int ret = call_get_iattr (fname,&flags); if (ret == -1){ fprintf (stderr,"Can't get ext flags on file %s (%s)\n" ,fname,strerror(errno)); } return ret; } /* Set the extended attributes of a file */ static int setext2flags (const char *fname, bool setmode, long flags) { int ret = call_set_iattr (fname,setmode,flags); if (ret == -1){ fprintf (stderr,"Can't set ext flags on file %s (%s)\n" ,fname,strerror(errno)); } return ret; } int main (int argc, char *argv[]) { int ret = -1; if (argc <= 1){ fprintf (stderr ,"showattr [--noname] file ...\n" "\n" "Presents extended file attribute.\n" "\n" "setattr [--unset] [ --immutable --immulink --barrier --cow] file ...\n" "\n" "Sets/Unsets the extended file attributes.\n" "\n" "These utilities exist as an interim until lsattr and\n" "chattr are updated.\n" ); }else if (strstr(argv[0],"showattr")!=NULL){ bool verbose = true; for (int i=1; i