19962016 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. erl_prim_loader erl_prim_loader.xml
erl_prim_loader Low Level Erlang Loader

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

erl_prim_loader knows about the environment and how to fetch modules.

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 runtime system: efile and inet.

The support for loading of code from archive files is experimental. The sole purpose of releasing it before it is ready is to obtain early feedback. The file format, semantics, interfaces etc. may be changed in a future release. The functions list_dir/1 and read_file_info/1 as well as the flag -loader_debug are also experimental

Get a file

This function fetches a file using the low level loader. Filename is either an absolute file name or just the name of the file, for example "lists.beam". If an internal path is set to the loader, this path is used to find the file. FullName is the complete name of the fetched file. Bin is the contents of the file as a binary.

The Filename can also be a file in an archive. For example $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia.beam. See code(3) about archive files.

Get the path set in the loader

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.

List files in a directory

Lists all the files in a directory. Returns {ok, Filenames} if successful. Otherwise, it returns error. Filenames is a list of the names of all the files in the directory. The names are not sorted.

The Dir can also be a directory in an archive. For example $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin. See code(3) about archive files.

Get information about a file

Retrieves information about a file. Returns {ok, FileInfo} if successful, otherwise error. FileInfo is a record file_info, defined in the Kernel include file file.hrl. Include the following directive in the module from which the function is called:

-include_lib("kernel/include/file.hrl").

See file(3) for more info about the record file_info.

The Filename can also be a file in an archive. For example $OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia. See code(3) about archive files.

Get information about a link or file

This function works like read_file_info/1 except that if Filename is a symbolic link, information about the link will be returned in the file_info record and the type field of the record will be set to symlink.

If Filename is not a symbolic link, this function returns exactly the same result as read_file_info/1. On platforms that do not support symbolic links, this function is always equivalent to read_file_info/1.

Set the path of the loader

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

Command Line Flags

The erl_prim_loader module interprets the following command line 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 the -loader flag is omitted, it defaults to efile.

-loader_debug

Makes the efile loader write some debug information, such as the reason for failures, while it handles files.

-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(3) which handles the load requests. Hosts is a list of IP addresses (hostnames are not acceptable).

-setcookie Cookie

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

SEE ALSO

init(3), erl_boot_server(3)