DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦70b96e87a⟧ Ada Source

    Length: 16384 (0x4000)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package Unix, seg_0509a4

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



-------------------------------------------------------------------------
--               The "popular" Unix AIX Interface                      --
--                                                                     --
--  This package defines the Ada-to-C interface for calls to the       --
--  more popular Unix system calls.  Some data structures are          --
--  machine-dependent; these are defined in unix_status_buffer.        --
-------------------------------------------------------------------------

with System;
use System;
with C_Strings;
use C_Strings;
with Os_Files;
with Unix_Status_Buffer;
with Language;

package Unix is

    use System;
    use C_Strings;
    use Language;

    --
    --\x09Error codes for unix functions
    --
    type Error_Codes is
       (E_Noerror, -- No Error
        Eperm, -- Not super-user\x09\x09\x09
        Enoent, -- No such file or directory\x09\x09
        Esrch, -- No such process\x09\x09\x09
        Eintr, -- interrupted system call\x09\x09
        Eio, -- I/O error\x09\x09\x09\x09
        Enxio, -- No such device or address\x09\x09
        E2big, -- Arg list too long\x09\x09\x09
        Enoexec, -- Exec format error\x09\x09\x09
        Ebadf, -- Bad file number\x09\x09\x09
        Echild, -- No children\x09\x09\x09\x09
        Eagain, -- No more processes\x09\x09\x09
        Enomem, -- Not enough core\x09\x09\x09
        Eacces, -- Permission denied\x09\x09\x09
        Efault, -- Bad address\x09\x09\x09\x09
        Enotblk, -- Block device required\x09\x09
        Ebusy, -- Mount device busy\x09\x09\x09
        Eexist, -- File exists\x09\x09\x09\x09
        Exdev, -- Cross-device link\x09\x09\x09
        Enodev, -- No such device\x09\x09\x09
        Enotdir, -- Not a directory\x09\x09\x09
        Eisdir, -- Is a directory\x09\x09\x09
        Einval, -- Invalid argument\x09\x09\x09
        Enfile, -- File table overflow\x09\x09\x09
        Emfile, -- Too many open files\x09\x09\x09
        Enotty, -- Not a typewriter\x09\x09\x09
        Etxtbsy, -- Text file busy\x09\x09\x09
        Efbig, -- File too large\x09\x09\x09
        Enospc, -- No space left on device\x09\x09
        Espipe, -- Illegal seek\x09\x09\x09\x09
        Erofs, -- Read only file system\x09\x09
        Emlink, -- Too many links\x09\x09\x09
        Epipe, -- Broken pipe\x09\x09\x09\x09
        Edom, -- Math arg out of domain of func\x09
        Erange, -- Math result not representable\x09
        Enomsg, -- No message of desired type\x09\x09
        Eidrm, -- Identifier removed\x09\x09\x09
        Echrng, -- Channel number out of range\x09\x09
        El2nsync, -- Level 2 not synchronized\x09\x09
        El3hlt, -- Level 3 halted\x09\x09\x09
        El3rst, -- Level 3 reset\x09\x09\x09
        Elnrng, -- Link number out of range\x09\x09
        Eunatch, -- Protocol driver not attached\x09\x09
        Enocsi, -- No CSI structure available\x09\x09
        El2hlt, -- Level 2 halted\x09\x09\x09
        Edeadlk, -- Record locking deadlock\x09\x09
        Enotready, -- Device not ready\x09\x09
        Ewrprotect, -- Write-protected media \x09
        Eformat, -- Unformatted media \x09\x09
        Enolck, -- No locks\x09\x09\x09
        Enoconnect, -- no connection
        Ebadconnect, -- connection has gone down
        Estale, -- no filesystem
        Edist, -- requests blocked
        Ewouldblock, -- Operation would block
        Einprogress, -- Operation now in progress
        Ealready, -- Operation already in progress
        Enotsock, -- Socket operation on non-socket
        Edestaddrreq, -- Destination address required
        Emsgsize, -- Message too long
        Eprototype, -- Protocol wrong type for socket
        Enoprotoopt, -- Protocol not available
        Eprotonosupport, -- Protocol not supported
        Esocktnosupport, -- Socket type not supported
        Eopnotsupp, -- Operation not supported on socket
        Epfnosupport, -- Protocol family not supported
        Eafnosupport, -- Address family not supported by protocol family
        Eaddrinuse, -- Address already in use
        Eaddrnotavail, -- Can't assign requested address
        Enetdown, -- Network is down
        Enetunreach, -- Network is unreachable
        Enetreset, -- Network dropped connection on reset
        Econnaborted, -- Software caused connection abort
        Econnreset, -- Connection reset by peer
        Enobufs, -- No buffer space available
        Eisconn, -- Socket is already connected
        Enotconn, -- Socket is not connected
        Eshutdown, -- Can't send after socket shutdown
        Etimedout, -- Connection timed out
        Econnrefused, -- Connection refused
        Ehostdown, -- Host is down
        Ehostunreach, -- No route to host
        Erestart, -- Restart the system call
        Eproclim, -- Too many processes
        Eusers, -- Too many users
        Eloop, -- Too many levels of symbolic links
        Enametoolong, -- File name too long
        Enotempty, -- Directory not empty
        Edquot, -- Disc quota exceeded
        Edummy89, -- Dummy
        Elibacc, -- Shared library cannot be accessed
        Edummy90, -- Dummy
        Elibbad, -- Shared library format is bad
        Elibscn, -- .lib section in executable is corrupted
        Elibmax, -- Too many shared libraries
        Eremote, -- Item is not local to host
        Esitedn1, -- Required site is not available
        Esitedn2, -- Operation terminated due to site failure
        Enostore, -- File or working directory is unavailable
        Enldev, -- Not a local device.
        Ebadst, -- Bad site specification
        Eldwrg, -- Load module not for this machine
        Elocalonly, -- Operation restricted to local site
        Elock, -- Lock conflict
        Etable, -- Miscellaneous system table full
        Exgfs, -- Improper mount operation requested
        Ejournal, -- Undefined journal operation
        Epbusy, -- Pack is busy
        Enspec, Edlock, Enosys, -- Function not implemented  POSIX
        Emedia, -- Media surface error
        Esoft, -- I/O completed, but needs relocation
        Enoattr, -- No attribute found
        Esad, -- Security authentication denied
        Enotrust  -- Not a trusted program
        );

    for Error_Codes'Size use 32;

    subtype Status_Code is Integer;

    Error : constant Status_Code := -1;
    Ok : constant Status_Code := 0;

    subtype Offset is Integer range -1 .. Integer'Last;

    subtype Io_Count is Integer range -1 .. Integer'Last;

    subtype Whence is Integer;

    L_Set : constant Whence := 0;
    L_Incr : constant Whence := 1;
    L_Xtnd : constant Whence := 2;

    type Access_Mode is (F_Ok, X_Ok, W_Ok, R_Ok);
    for Access_Mode use (F_Ok => 0, X_Ok => 1, W_Ok => 2, R_Ok => 4);
    for Access_Mode'Size use 32;

    subtype A_Status_Buffer is Unix_Status_Buffer.A_Status_Buffer;
    subtype Permission is Unix_Status_Buffer.Permission_Integer;
    Allow_Read_Write : Permission renames Unix_Status_Buffer.Allow_Read_Write;


    --
    --\x09The UNIX system calls
    --

    -- The following set are overloaded, so we can provide interfaces
    -- both for C strings and for Ada strings.  We must use an intermediary
    -- package to allow pragma interfaces for these overloaded names.
    package Resolve_Overloading is
        function Sys_Access (Filename : C_String; Mode : Access_Mode)
                            return Status_Code;
        function Chdir (Filename : C_String) return Status_Code;
        function Chmod (Filename : C_String; Perm : Permission)
                       return Status_Code;
        function Chown (Filename : C_String; User, Group : Integer)
                       return Status_Code;
        function Open (Filename : C_String;
                       Mode : Os_Files.Open_Flags :=
                          Os_Files."+" (Os_Files.O_Rdwr,
                                        Os_Files."+" (Os_Files.O_Creat,
                                                      Os_Files.O_Excl));
                       Perm : Permission := Allow_Read_Write)
                      return Os_Files.File_Descriptor;
        function Stat (Filename : C_String; Statbuf : A_Status_Buffer)
                      return Status_Code;
        function Truncate (Filename : C_String; Length : Offset)
                          return Status_Code;
        function Unlink (Linkname : C_String) return Status_Code;
        function Link (Filename, Linkname : C_String) return Status_Code;
        function Symlink (Filename, Linkname : C_String) return Status_Code;
        function Readlink (Path : C_String; Buffer : Address; Bufsiz : Integer)
                          return Io_Count;
        function Rename (From_Name, To_Name : C_String) return Status_Code;

    private

        pragma Interface (C, Sys_Access);
        pragma Interface_Name (Sys_Access, C_Subp_Prefix & "access");
        pragma Interface (C, Chdir);
        pragma Interface (C, Chmod);
        pragma Interface (C, Chown);
        pragma Interface (C, Open);
        pragma Interface (C, Stat);
        pragma Interface (C, Truncate);
        pragma Interface (C, Unlink);
        pragma Interface (C, Link);
        pragma Interface (C, Symlink);
        pragma Interface (C, Readlink);
        pragma Interface (C, Rename);
    end Resolve_Overloading;

    function Sys_Access
                (Filename : C_String; Mode : Access_Mode) return Status_Code
        renames Resolve_Overloading.Sys_Access;
    function Chdir (Filename : C_String) return Status_Code
        renames Resolve_Overloading.Chdir;
    function Chmod (Filename : C_String; Perm : Permission) return Status_Code
        renames Resolve_Overloading.Chmod;
    function Chown (Filename : C_String; User, Group : Integer)
                   return Status_Code renames Resolve_Overloading.Chown;
    function Open (Filename : C_String;
                   Mode : Os_Files.Open_Flags :=
                      Os_Files."+" (Os_Files.O_Rdwr,
                                    Os_Files."+" (Os_Files.O_Creat,
                                                  Os_Files.O_Excl));
                   Perm : Permission := Allow_Read_Write)
                  return Os_Files.File_Descriptor
        renames Resolve_Overloading.Open;
    function Stat (Filename : C_String; Statbuf : A_Status_Buffer)
                  return Status_Code renames Resolve_Overloading.Stat;
    function Truncate (Filename : C_String; Length : Offset) return Status_Code
        renames Resolve_Overloading.Truncate;
    function Unlink (Linkname : C_String) return Status_Code
        renames Resolve_Overloading.Unlink;
    function Link (Filename, Linkname : C_String) return Status_Code
        renames Resolve_Overloading.Link;
    function Symlink (Filename, Linkname : C_String) return Status_Code
        renames Resolve_Overloading.Symlink;
    function Readlink (Path : C_String; Buffer : Address; Bufsiz : Integer)
                      return Io_Count renames Resolve_Overloading.Readlink;
    function Rename (From_Name, To_Name : C_String) return Status_Code
        renames Resolve_Overloading.Rename;

    -- the above are overloaded for Ada string parameters whereever
    -- c_string parameters are used.
    function Sys_Access
                (Filename : String; Mode : Access_Mode) return Status_Code;
    function Chdir (Filename : String) return Status_Code;
    function Chmod (Filename : String; Perm : Permission) return Status_Code;
    function Chown (Filename : String; User, Group : Integer)
                   return Status_Code;
    function Open (Filename : String;
                   Mode : Os_Files.Open_Flags :=
                      Os_Files."+" (Os_Files.O_Rdwr,
                                    Os_Files."+" (Os_Files.O_Creat,
                                                  Os_Files.O_Excl));
                   Perm : Permission := Allow_Read_Write)
                  return Os_Files.File_Descriptor;
    function Stat (Filename : String; Statbuf : A_Status_Buffer)
                  return Status_Code;
    function Truncate (Filename : String; Length : Offset) return Status_Code;
    function Unlink (Linkname : String) return Status_Code;
    function Link (Filename, Linkname : String) return Status_Code;
    function Symlink (Filename, Linkname : String) return Status_Code;
    function Readlink (Path : String; Buffer : Address; Bufsiz : Integer)
                      return Io_Count;
    function Rename (From_Name, To_Name : String) return Status_Code;

    function Get_Temp_Name (Root : String := "/tmp/adatmp") return String;
    function Gethostname (Name : Address; Namelen : Integer) return Status_Code;

    function Fchmod (File : Os_Files.File_Descriptor; Perm : Permission)
                    return Status_Code;
    function Fchown (File : Os_Files.File_Descriptor; User, Group : Integer)
                    return Status_Code;
    function Close (File : Os_Files.File_Descriptor) return Status_Code;
    procedure Sys_Exit (Code : Integer := 0);
    function Lseek
                (File : Os_Files.File_Descriptor; Incr : Offset; From : Whence)
                return Offset;
    function Read (File : Os_Files.File_Descriptor;
                   Buffer : Address;
                   Count : Io_Count) return Io_Count;
    function Fstat (File : Os_Files.File_Descriptor; Statbuf : A_Status_Buffer)
                   return Status_Code;
    function Ftruncate (File : Os_Files.File_Descriptor; Length : Offset)
                       return Status_Code;
    function Write (File : Os_Files.File_Descriptor;
                    Buffer : Address;
                    Count : Io_Count) return Io_Count;
    function Getpid return Integer;
    function Getppid return Integer;
    function Signal (Sig : Integer; Handler : System.Address)
                    return System.Address;

    Errnum : Error_Codes;

    -- for unix BSD/SysV compatibility:
    procedure Getcwd (Path : in out String);

private

    pragma Interface (C, Fchown);
    pragma Interface (C, Fchmod);
    pragma Interface (C, Close);
    pragma Interface (C, Sys_Exit);
    pragma Interface_Name (Sys_Exit, C_Subp_Prefix & "exit");
    pragma Interface (C, Lseek);
    pragma Interface (C, Read);
    pragma Interface (C, Fstat);
    pragma Interface (C, Ftruncate);
    pragma Interface (C, Write);
    pragma Interface (C, Getpid);
    pragma Interface (C, Getppid);
    pragma Interface (C, Gethostname);
    pragma Interface (C, Signal);

    pragma Interface_Name (Errnum, C_Prefix & "errno");

end Unix;

E3 Meta Data

    nblk1=f
    nid=0
    hdr6=1e
        [0x00] rec0=20 rec1=00 rec2=01 rec3=032
        [0x01] rec0=19 rec1=00 rec2=02 rec3=020
        [0x02] rec0=17 rec1=00 rec2=03 rec3=00e
        [0x03] rec0=13 rec1=00 rec2=04 rec3=062
        [0x04] rec0=16 rec1=00 rec2=05 rec3=05e
        [0x05] rec0=14 rec1=00 rec2=06 rec3=052
        [0x06] rec0=22 rec1=00 rec2=07 rec3=06a
        [0x07] rec0=11 rec1=00 rec2=08 rec3=04c
        [0x08] rec0=15 rec1=00 rec2=09 rec3=030
        [0x09] rec0=14 rec1=00 rec2=0a rec3=076
        [0x0a] rec0=11 rec1=00 rec2=0b rec3=006
        [0x0b] rec0=13 rec1=00 rec2=0c rec3=00a
        [0x0c] rec0=11 rec1=00 rec2=0d rec3=024
        [0x0d] rec0=19 rec1=00 rec2=0e rec3=040
        [0x0e] rec0=12 rec1=00 rec2=0f rec3=000
    tail 0x217580360878e797e5499 0x42a00088462060003