Example: FD Creat ("Abc - TXT", O - RDONLY, 0666) 0666-RWX To File Owner. 0777-RWX To All Owners. Explanation of Algorithm
Example: FD Creat ("Abc - TXT", O - RDONLY, 0666) 0666-RWX To File Owner. 0777-RWX To All Owners. Explanation of Algorithm
Explanation of Algorithm:
The Kernel searches the specified file and if file already exists then it truncates
the file (File Size Zero) and returns the existing file descriptor slot.
Kernel assigns an inode for the new file,and then it writes the new file name
component and the inode in the parent directory, the byte offset saved in the u
area. Afterwards, it releases the inode of the parent directory.
It finally initializes the file table and i-node table.
Algorithm:
I/P: Pathname
O/P: Fd
{
get inode from file system;
if(file already exists)
{
If (permission denied)
{
Return (error);
}
else
{
Assign the i-node to the new file;
Create new entry in the parent entry: File Name & inode no;
Initialize file table and inode table;
}
return (fd);
}