From 57df6d3b56b604c1369e28132e4967dbacaeaa8f Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Tue, 6 May 2008 18:08:10 -0300 Subject: [PATCH] Document system calls and the open call. --- _ldd.xml | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/_ldd.xml b/_ldd.xml index 2dd4fa6..3d7a928 100644 --- a/_ldd.xml +++ b/_ldd.xml @@ -10,17 +10,80 @@ Introduction -Devices are files in /dev + +Devices in POSIX Systems are files in /dev directory. As with any files +in POSIX, they may be opened, closed, read from, written to, seeked, +ioctl'd, and others. + + + +Examples of device files: + -/dev/sda + +/dev/sda - A SCSI block device + -/dev/ttyS0 + +/dev/ttyS0 - A Serial terminal device + + +POSIX I/O calls + +POSIX systems have some standard calls for I/O. Since devices are files, +these same system calls are used to work with devices. We are gonna work +with the following calls: + + + +open + + +read + + +write + + +close + + +seek + + +ioctl + + + + + +open + +The open system call opens a file. When working with devices, that's +when some initialization should be done. Some devices may be opened only +once at a time. + + +int open (char * filename, int flags); + + +flags may be O_RDONLY, O_WRONLY, O_RDWR and many others, some not +important for devices. + + +Example: + + +fd = open ("/dev/ttyS0", O_RDWR); + + + -- 2.20.1