UNIX index node (inode)
- Each file is represented by an Inode
- Inode contains all of a file's metadata
- Access rights, owner,accounting info
- (partial) block index table of a file
- Each inode has a unique number (within a partition)
- System oriented name
- Try `ls -i' on Unix (Linux)
- Directories map file names to inode numbers
- Map human-oriented to system-oriented names
- Mapping can be many-to-one; Hard links
ozdogan@ozdogan:~/week12$ man ls
.
-i, --inode print index number of each file
.
ozdogan@ozdogan:~/week12$ ls -i
toplam 128
901649 drwxr-xr-x 3 ozdogan ozdogan 4096 2004-05-25 15:00 ./
885067 drwxr--r-- 5 ozdogan ozdogan 8192 2004-05-25 14:47 ../
901651 drwxr-xr-x 2 ozdogan ozdogan 4096 2004-05-25 14:47 figures/
901656 -rw-r--r-- 1 ozdogan ozdogan 1264 2004-05-25 14:59 week12.aux
901658 -rw-r--r-- 1 ozdogan ozdogan 5264 2004-05-25 14:59 week12.dvi
901655 -rw-r--r-- 1 ozdogan ozdogan 8654 2004-05-25 14:59 week12.log
901657 -rw-r--r-- 1 ozdogan ozdogan 57 2004-05-25 14:59 week12.out
901659 -rw-r--r-- 1 ozdogan ozdogan 55968 2004-05-25 15:00 week12.ps
901652 -rw-r--r-- 1 ozdogan ozdogan 2153 2004-05-25 14:59 week12.tex
901654 -rw-r--r-- 1 ozdogan ozdogan 1939 2004-05-25 14:58 week12.tex~
901653 -rw-r--r-- 1 ozdogan ozdogan 13767 2004-05-25 14:47 week12.tex.backup
A code example for for printing out structure members of files; Try `structuremembers *' on Unix (Linux)
/* structuremembers.c
print structure members of files
st_mode the type and mode of the file
st_ino
st_dev
st_rdev
st_nlink
st_uid
st_gid
st_size
st_atime
st_mtime
st_ctime
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
main(argc,argv)
int argc; char *argv[];
{
struct stat status;
int i;
for(i=1; i < argc; i++)
if(stat (argv[i],&status))
fprintf(stderr,"Cannot stat %s \n",argv[i]);
else
printf("%15s %4.4o\n",argv[i],status.st_mode & 07777);
//printf("%15s %14d\n",argv[i],status.st_ino);
}
Internal sructure of week12 inode
Inode: 901649 Type: directory Mode: 0755 Flags: 0x0 Generation: 2473956264
User: 1000 Group: 1000 Size: 4096
File ACL: 0 Directory ACL: 0
Links: 3 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x40b33fde -- Tue May 25 15:45:18 2004
atime: 0x40b34ba7 -- Tue May 25 16:35:35 2004
mtime: 0x40b33fde -- Tue May 25 15:45:18 2004
BLOCKS:
(0):1828886
TOTAL: 1
Internal sructure of week12.ps inode
Inode: 901659 Type: regular Mode: 0644 Flags: 0x0 Generation: 2473956273
User: 1000 Group: 1000 Size: 83309
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 176
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x40b34007 -- Tue May 25 15:45:59 2004
atime: 0x40b34016 -- Tue May 25 15:46:14 2004
mtime: 0x40b34007 -- Tue May 25 15:45:59 2004
BLOCKS:
(0-11):7742-7753, (IND):7754, (12-20):7755-7763
TOTAL: 22
Figure 1:
Inode contents.
|