rec4-2010 - Recitation 4 File I/O system calls: open, read,...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Recitation 4 File I/O system calls : open, read, write, close File I/O std. library functions : fopen, fgets, fread, fwrite, fclose. exercise: filemerge.c
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
‘Open’ system call Prototype : int open (const char * path, int oflag, . .. ) Declared in “fcntl.h” Creates a connection between a process and a file, called the file descriptor. To open a file Specify the name of the file. The type of connection you want: O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_APPEND…
Background image of page 2
‘Open’ system call cont… Opening a file is a kernel service, if the kernel detects a problem it returns the value -1. The kernel returns the file descriptor. It is a long or an int depending on the values of system constants.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
‘Read’ system call Prototype : ssize_t read (int fildes, void *buf, size_t nbyte) Declared in unistd.h Transfer up to nbyte bytes from the file. Associated with the open file descriptor into the buffer
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/21/2011 for the course CSCI 4061 taught by Professor Tripathi during the Spring '08 term at Minnesota.

Page1 / 11

rec4-2010 - Recitation 4 File I/O system calls: open, read,...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online