Chapter 8
Chapter 8
File length
Creation timestamp
Read timestamp
Write timestamp
Attribute timestamp
Reference count
Owner
File type
Access control list
filedes = open(name, mode) Opens an existing file with the given name.
filedes = creat(name, mode) Creates a new file with the given name.
Both operations deliver a file descriptor referencing the open
file. The mode is read, write or both.
status = close(filedes) Closes the open file filedes.
count = read(filedes, buffer, n) Transfers n bytes from the file referenced by filedes to buffer.
count = write(filedes, buffer, n) Transfers n bytes to the file referenced by filedes from buffer.
Both operations deliver the number of bytes actually transferred
and advance the read-write pointer.
pos = lseek(filedes, offset, Moves the read-write pointer to offset (relative or absolute,
whence) depending on whence).
status = unlink(name) Removes the file name from the directory structure. If the file
has no other names, it is deleted.
status = link(name1, name2) Adds a new name (name2) for a file (name1).
status = stat(name, buffer) Gets the file attributes for file name into buffer.
Lookup
AddName
Client computer UnName Server computer
GetNames
Client module
Read
Write
Create
Delete
GetAttributes
SetAttributes
Sukkur IBA University , Sukkur DS - Spring 2018 13
File Service architecture
Flat file service interface Fig. 8.6
Most of the operations in the interface of flat file service are repeatable
Suitable for implementation by stateless servers
Access control
Access rights checks should be performed at the server
Server is vulnerable to forged identities
Result of an access rights checks needs to be retained at the server
To make the server stateless, either of the following may be adopted:
An access check is made whenever a file name is converted to an
UFID and the results are encoded in the form of a capability
A user identity is submitted with every client request and access
checks are performed by the server for every file operation
This a more common approach
None of the above can overcome the forged user identities problem
Directory service interface Fig 8.7
Translate text names to UFIDs
Lookup(Dir, Name) -> FileId Locates the text name in the directory and returns the
— throwsNotFound relevant UFID. If Name is not in the directory, throws an
exception.
AddName(Dir, Name, FileId) If Name is not in the directory, adds (Name, File) to the
— throwsNameDuplicate directory and updates the file’s attribute record.
If Name is already in the directory: throws an exception.
UnName(Dir, Name) If Name is in the directory: the entry containing Name is
— throwsNotFound removed from the directory.
If Name is not in the directory: throws an exception.
GetNames(Dir, Pattern) -> NameSeq Returns all the text names in the directory that match the
regular expression Pattern.
File groups
A collection of files located on a given server
A server may hold several file groups and the groups can be
moved between servers
A file cannot change the group to which it belongs
Introduced as a facility for moving collection of files stored on
removable media between computers
UFID includes a file group identifier component
File group identifiers must be unique throughout the distributed
system
Algorithm should ensure global uniqueness
Application Application
program program
UNIX
system calls
UNIX kernel
UNIX kernel Virtual file system Virtual file system
Local Remote
file system
client server
system system
NFS
protocol
remote files
UNIX NFS UNIX
NFS NFS Client
file file
Other
client server
system system
NFS
protocol
(remote operations)
Sukkur IBA University , Sukkur DS - Spring 2018 20
*
Sun Network File System
Virtual file system....
File handles are passed from server to client in the results of lookup,
create and mkdir operations
Virtual file system layer has one VFS structure for each mounted file
system and one v-node per open file
The v-node contains an indicator to show whether the file is local or
remote
Client integration
NFS client module provides an interface for use by application
programs
It is integrated with the UNIX kernel and emulates the semantics of
standard UNIX file system primitives precisely
User programs can access files via UNIX system calls
A single client module serves all of the user-level processes
Encryption key can be retained in the kernel
NFS client module cooperates with the VFS in each client machine
Maintains caching of different file blocks
Cache consistency problems arise
Remote Remote
people s tudents x s taff users
mount mount
Note: The file system mounted at /usr/students in the client is actually the sub-tree located at /export/people in Server 1;
the file system mounted at /usr/staff in the client is actually the sub-tree located at /nfs/users in Server 2.