Friday 26 August 2016

Write a program in Python/C++ to read display the i-node information for a given text file, image file.

Code

 

 

 
import os
name=raw_input("Enter the file name for which inode information is to processed\n") 
fd=os.open(name,os.O_RDWR)
info=os.fstat(fd)
print "File information is as follows" 
print "Inode number:",info.st_ino
print "Device number:",info.st_dev
print "Number of links:",info.st_nlink
print "File UID:%d" %info.st_uid
print "File GID:%d" %info.st_gid
print "file Size:",info.st_size
print "Access time:",info.st_atime
print "Modify time:",info.st_mtime
print "Change time:",info.st_ctime
print "File Protection:",info.st_mode
print "Number of blocks allocated:",info.st_blocks
print "Size of block:",info.st_blksize

Output



[te@dbsl1 asgn4]$ python asi4.py
Enter the file name for which inode information is to processed
asi4.py
File information is as follows
Inode number: 52829038
Device number: 64770
Number of links: 1
File UID:1001
File GID:1001
file Size: 640
Access time: 1469023210.19
Modify time: 1469023207.41
Change time: 1469023207.46
File Protection: 33277
Number of blocks allocated: 8
Size of block: 4096

No comments:

Post a Comment