This is an appendix to Understanding Unix/Linux Programming written for people interested in Ada programming on POSIX systems.

Connection Control: Studying stty

Section 5.2.2, page 141

Devices and System Calls

For example, code to read from a magnetic tape could look like this:

declare
   Tape       : File_Descriptor;
   Position   : IO_Offset;
   Buffer     : IO_Buffer (1 .. 1024);
   Bytes_Read : IO_Count;
begin
   Tape := Open (Name => "/dev/tape",
                 Mode => Read_Only);
   Seek (File   => Tape,
         Offset => 4096,
         Result => Position);
   Read (File   => Tape,
         Buffer => Buffer,
         Last   => Bytes_Read);
   Close (File => Tape);
end;

Some Devices Do No Support All File Operations

Terminals support Read and Write, but not Seek. Why is that?

Section 5.2.5, pages 143-144

This simple version of write does not send the Message from ... introduction and requires the filename for the terminal (the ttyname), not the username of the other person: write0.adb

Section 5.4.1, page 147

declare
   Mode    : File_Mode;
   Options : Open_Option_Set;
begin
   Get_File_Control (File    => File,
                     Mode    => Mode,
                     Options => Options);
   Options := Options + File_Synchronized;
   Set_File_Control (File    => File,
                     Options => Options);
end;

-- 

Go to next chapter.

Collected examples:
posix-in-ada.zip
Based on:
Understanding Unix/Linux Programming, Bruce Molay, ISBN 0-13-008396-8.
Main page:
http://edb.jacob-sparre.dk/Posix_in_Ada/
Written by:
Jacob Sparre Andersen.
Latest update:
19th of April, 2008