• We
will start our study with the functions available for the file I/O operations
such as open a file, read & write a file, close a file and so on.
• Most
file IO operations are performed with the open, read, write,
lseek and close system calls.
• File
descriptors
– File
descriptor is a non-negative integer representing the file opened in the
kernel.
– When
is opened or newly created, the kernel returns a file descriptor to the
process.
– During
read/write, the file is identified by the file descriptor that was returned by
open()
System
call
|
File
Operation
|
open
|
open a
file or device fs/open.c
|
creat
|
create a
file or device
|
close
|
close a
file descriptor
|
dup2
|
duplicate
a file descriptor
|
dup
|
duplicate
an open file descriptor
|
mmap
|
map files
into memory
(Only the
PROT_READ protection flag is supported.)
|
munmap
|
unmap
files from memory
|
pread
|
read from
a file descriptor at a given offset
|
pwrite
|
write to
a file descriptor at a given offset
|
read
|
read from
a file descriptor
|
readv
|
read data
from multiple buffers
|
write
|
write to
a file descriptor
|
writev
|
write
data from multiple buffers
|
lseek
|
reposition
read/write file offset
|
llseek
|
move
extended read/write file pointer
|
lstat
|
get file
status
|
truncate
|
set a
file to a specified length
|
ftruncate
|
set a file
to a specified length
|
unlink
|
delete a
name and possibly the file it refers to
|
No comments:
Post a Comment