erl_prim_loader(3)

MODULE
erl_prim_loader - The Low Level Erlang Loader.

DESCRIPTION

The erl_prim_loader is used to load all Erlang modules into the system. The start script is also fetched with the low level loader.

The erl_prim_loader knows about the environment and how to fetch modules. The loader could, for example, fetch files using the file system (with absolute file names as input), or a database (where the binary format of a module is stored).

The -loader Loader command line flag can be used to choose the method used by the erl_prim_loader. Two Loader methods are supported by the Erlang system: efile and inet. If another loader is required, then it has to be implemented by the user. The Loader provided by the user must fulfill the protocol defined below, and it is started with the erl_prim_loader by evaluatingopen_port({spawn, Loader}, [binary]).

EXPORTS

start(Id,Loader,Hosts) -> {ok, Pid} | {error, What}

    Types
        Id = term()
        Loader = atom()
        Hosts = [Host]
        Host = atom()
        Pid = pid()
        What = term()

    Starts the Erlang low level loader. This function is called by the init process (and module). The init process reads the command line flags -id Id, -loader Loader, and -hosts Hosts. These are the arguments supplied to the start/3 function.

    If -loader is not given, the default loader is efile which tells the system to read from the file system.

    If -loader is inet, the -id Id, -hosts Hosts, and -setcookie Cookie flags must also be supplied. Hosts identifies hosts which this node can contact in order to load modules. One Erlang system with a erl_boot_server process must be started on each of hosts given in Hosts in order to answer the requests. See erl_boot_server(3).

    If -loader is something else, the given port program is started. The port program is supposed to follow the protocol specified below.

get_file(File) -> {ok, Bin, FullName} | error

    Types
        File = string()
        Bin = binary()
        FullName = string()

    This function fetches a file using the low level loader. File is either an absolute file name or just the name of the file, for example "lists.jam". If an internal path is set to the loader, this path is used to find the file. If a user supplied loader is used, the path can be stripped off if it is obsolete, and the loader does not use a path. FullName is the complete name of the fetched file. Bin is the contents of the file as a binary.

get_path() -> {ok, Path}

    Types
        Path = [Dir]
        Dir = string()

    This function gets the path set in the loader. The path is set by the init process according to information found in the start script.

set_path(Path) -> ok

    Types
        Path = [Dir]
        Dir = string()

    This function sets the path of the loader if init interprets a path command in the start script.

Protocol

The following protocol must be followed if a user provided loader port program is used. The Loader port program is started with the command open_port({spawn, Loader}, [binary]). The protocol is as follows:

Function          Send               Receive
-------------------------------------------------------------
get_file          [102 | FileName]   [121 | BinaryFile] (on success)
                                     [122]              (failure)
stop              eof                terminate

Command Line Flags

The erl_prim_loader module interprets the following flags:

    -loader Loader:
        Specifies the name of the loader used by erl_prim_loader. Loader can be efile (use the local file system), or inet (load using the boot_server on another Erlang node). If Loader is user defined, the defined Loader port program is started.

        If the -loader flag is omitted, it defaults to efile.

    -hosts Hosts:
        Specifies which other Erlang nodes the inet loader can use. This flag is mandatory if the -loader inet flag is present. On each host, there must be on Erlang node with the erl_boot_server which handles the load requests. Hosts is a list of IP addresses (hostnames are not acceptable).

    -id Id:
        Specifies the identity of the Erlang system. If the system runs as a distributed node, Id must be identical to the name supplied with the -sname or -name distribution flags.

    -setcookie Cookie:
        Specifies the cookie of the Erlang system. This flag is mandatory if the -loader inet flag is present.

SEE ALSO

init(3), erl_boot_server(3)

AUTHOR
Magnus Froberg - magnus@erix.ericsson.se