Monday, 6 July 2015

PR(01) Inode Information



#program inode.py
import os,sys

#open a file
fd = os.open("1.mp4",os.O_RDWR|os.O_CREAT)
#example.jpg can be replaced by other file name.

#get the information in variable
info = os.fstat(fd)

print "File information is as follows:"

print "File inode number:", info.st_ino

print "Device number:", info.st_dev

print "Number of link:", info.st_nlink

print "UID of the :%d" % info.st_uid

print "GID of the :%d" % info.st_gid

print "Size:", info.st_size

print "Access time:", info.st_atime

print "Modify time:", info.st_mtime

print "Change time:", info.st_ctime

print "Protection:", info.st_mode

print "Number of blocks allocated:", info.st_blocks

#close opened file
os.close(fd)
 

No comments:

Post a Comment