Inodeinfo.pl

Page last edited hace 2208 días 9 horas
De Solaris-ES
Saltar a: navegación, buscar
#!/usr/bin/perl 
# *********************************************************************** #
#                                                                         #
#  SCRIPT: inodeinfo.pl                                                   #
#  AUTHOR: mariano.obarrio@gmail.com                                      #
#    DATE: 11/05/10                                                       #
#     REV: 0.1                                                            #
#                                                                         #
#  PLATFORM: Solaris 10                                                   #
#                                                                         #
#  PROPOSITO: Muestra la informacion del inodo para un archivo especifico #
#                                                                         #
#  ESTE ESCRIPT ES LLAMADO DESDE:                                         #
#     Linea de comando                                                    #
#                                                                         #
#                                                                         #
#  EXIT CODES:                                                            #
#  NOTE: You must have root privileges to execute this script.            #
#                                                                         #
# Historico:                                                              #
#                                                                         #
# *********************************************************************** #
use POSIX qw(strftime);
if (@ARGV < 1){
        print ("Insufficient arguments.\ninodeinfo [FILENAME]\n"); 
        exit 1;
}
my $filename   = shift(@ARGV);
unless (-e $filename){
        print("File: [$filename] not exists.\n");
        exit(1);
}


($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);

print("\nFilename: [$filename]\n\n");
print("00 dev      Device number of filesystem                            : [$dev]\n");
print("01 ino      Inode number: 0 (zero) in Perl for Win32               : [$ino]\n");
print("02 mode     File permission mode: read/write/execute               : [$mode]\n");
print("03 nlink    Number of (hard) links to the file                     : [$nlink]\n");
print("04 uid      User ID - zero for Win32                               : [$uid]\n");
print("05 gid      Group ID - zero for Win32                              : [$gid]\n");
print("06 rdev     The device identifier (special files only)             : [$rdev]\n");
print("07 size     Total size of file, in bytes                           : [$size]\n");
print("08 atime    Last access time in seconds since the epoch            : [".convertirtiempo($atime)."]\n");
print("09 mtime    Last modify time in seconds since the epoch            : [".convertirtiempo($mtime)."]\n");
print("10 ctime    Inode change time (NOT creation time!) since the epoch : [".convertirtiempo($ctime)."]\n");
print("11 blksize  Preferred block size for file system I/O               : [$blksize]\n");
print("12 blocks   Actual number of blocks allocated                      : [$blocks]\n");
print "\n";
exit;

sub convertirtiempo(){
        my $time = shift;
        %mes = ( 0  => "Enero",
                 1  => "Febrero",
                 2  => "Marzo",
                 3  => "Abril",
                 4  => "Mayo",
                 5  => "Junio",
                 6  => "Julio",
                 7  => "Agosto",
                 8  => "Septiembre",
                 9  => "Octubre",
                 10 => "Noviembre",
                 11 => "Diciembre");


        ($seconds, $minutes, $hours, $day_of_month, $month, $year, $wday, $yday, $isdst) = localtime($time);
        $year += 1900;
        $time = "$day_of_month/$mes{$month}/$year $hours:$minutes:$seconds";
        return($time);
}


  • Ej:
 root@hancock # inodeinfo svdc.iostat 
 
 Filename: [svdc.iostat]
 
 00 dev      Device number of filesystem                            : [7602176]
 01 ino      Inode number: 0 (zero) in Perl for Win32               : [289386]
 02 mode     File permission mode: read/write/execute               : [33261]
 03 nlink    Number of (hard) links to the file                     : [1]
 04 uid      User ID - zero for Win32                               : [0]
 05 gid      Group ID - zero for Win32                              : [1]
 06 rdev     The device identifier (special files only)             : [0]
 07 size     Total size of file, in bytes                           : [1334]
 08 atime    Last access time in seconds since the epoch            : [24/Enero/2012 10:55:10]
 09 mtime    Last modify time in seconds since the epoch            : [19/Octubre/2011 16:4:36]
 10 ctime    Inode change time (NOT creation time!) since the epoch : [19/Octubre/2011 16:4:36]
 11 blksize  Preferred block size for file system I/O               : [8192]
 12 blocks   Actual number of blocks allocated                      : [4]