Unix Files
Unix Files
Unix Files
ln –s /usr/jose/original /usr/mary/slink
cat –n /usr/mary/slink
ls –l /usr/mary/slink
sr—r—r-- 1 terry 20 Aug 20, 1994 slink->usr/jose/original
UNIX and POSIX File Systems
root directory – “/”
Absolute path name – starts from “/”
Relative path name – may start with a “.” or “..”
A file name may not exceed NAME_MAX characters and path
name PATH_MAX characters.
legal file name characters – A to Z a to z 0 to 9.
The path name of a file is called the hard link. Can have one or
more hard links.
ln /usr/foo/path1/ usr/prog/new/n1
UNIX and POSIX File Systems
/etc Stores system admin files and programs
/etc/passwd Stores all user information
/etc/shadow Stores user passwords (For UNIX System V only)
/etc/group Stores all group info
/bin Stores all system programs like cat, rm, cp..etc
/dev Stores all character and block device files.
/usr/include Stores standard header files/
/usr/lib Stores standard libraries
/tmp Stores temporary file.
UNIX and POSIX File
Attributes
File type
Access permission
Hard link count
UID
GID
File size
Last access time
Last modify time
Last change time
Inode number
File system ID
UNIX and POSIX File Attributes
File Table
Kernel Space
r
rc = 1
rw rc = 1
xyz
rc = 1
w rc = 2 abc
rc = 1
Process Space
Read/write function
• The file descriptor is the first argument to read/write system
call.
• Kernel uses the file descriptor to index to the file descriptor
table to find the file table entry.
• It checks the file table entry to see if the appropriate mode and
permissions are there.
• Use the file table entry to access the file’s inode record.
• Use the file pointer in the file table entry to determine where
read/write should occur.
• Checks the file type in inode record and invokes the appropriate
driver function.
Limitations of hardlinks:
• Cannot create hardlinks for directories unless they have
superuser privileges
• Users cannot create hardlinks on a file system that
references files on a different system.
Hard Link Vs Symbolic Link
Cannot link files across file Can link files across file systems
systems
Increase the hard link count of the Does not change the hard link
linked inode count of the linked inode
ln Vs cp
ln creates a new directory entry to a referenced file whereas cp creates a
duplicated copy of the file to another file with a different name.
ln /usr/mary/abc /usr/mary/xyz
Inode Filename Inode Filename
number number
115 515
89 989
89 989