User's Guide
Reference Manual
Release Notes
PDF
Top

Erlang Run-Time System Application (ERTS)
Reference Manual
Version 5.7.4

Expand All
Contract All

Table of Contents

- erl_prim_loader
  - Top of manual page
  - start/3
  - get_file/1
  - get_path/0
  - list_dir/1
  - read_file_info/1
  - set_path/1
- erlang
  - Top of manual page
  - abs/1
  - adler32/1
  - adler32/2
  - adler32_combine/3
  - erlang:append_element/2
  - apply/2
  - apply/3
  - atom_to_binary/2
  - atom_to_list/1
  - binary_to_atom/2
  - binary_to_existing_atom/2
  - binary_to_list/1
  - binary_to_list/3
  - bitstring_to_list/1
  - binary_to_term/1
  - bit_size/1
  - erlang:bump_reductions/1
  - byte_size/1
  - erlang:cancel_timer/1
  - check_process_code/2
  - concat_binary/1
  - crc32/1
  - crc32/2
  - crc32_combine/3
  - date/0
  - decode_packet/3
  - delete_module/1
  - erlang:demonitor/1
  - erlang:demonitor/2
  - disconnect_node/1
  - erlang:display/1
  - element/2
  - erase/0
  - erase/1
  - erlang:error/1
  - erlang:error/2
  - exit/1
  - exit/2
  - float/1
  - float_to_list/1
  - erlang:fun_info/1
  - erlang:fun_info/2
  - erlang:fun_to_list/1
  - erlang:function_exported/3
  - garbage_collect/0
  - garbage_collect/1
  - get/0
  - get/1
  - erlang:get_cookie/0
  - get_keys/1
  - erlang:get_stacktrace/0
  - group_leader/0
  - group_leader/2
  - halt/0
  - halt/1
  - erlang:hash/2
  - hd/1
  - erlang:hibernate/3
  - integer_to_list/1
  - erlang:integer_to_list/2
  - iolist_to_binary/1
  - iolist_size/1
  - is_alive/0
  - is_atom/1
  - is_binary/1
  - is_bitstring/1
  - is_boolean/1
  - erlang:is_builtin/3
  - is_float/1
  - is_function/1
  - is_function/2
  - is_integer/1
  - is_list/1
  - is_number/1
  - is_pid/1
  - is_port/1
  - is_process_alive/1
  - is_record/2
  - is_record/3
  - is_reference/1
  - is_tuple/1
  - length/1
  - link/1
  - list_to_atom/1
  - list_to_binary/1
  - list_to_bitstring/1
  - list_to_existing_atom/1
  - list_to_float/1
  - list_to_integer/1
  - erlang:list_to_integer/2
  - list_to_pid/1
  - list_to_tuple/1
  - load_module/2
  - erlang:load_nif/2
  - erlang:loaded/0
  - erlang:localtime/0
  - erlang:localtime_to_universaltime/2
  - erlang:localtime_to_universaltime/3
  - make_ref/0
  - erlang:make_tuple/2
  - erlang:make_tuple/3
  - erlang:max/2
  - erlang:md5/1
  - erlang:md5_final/1
  - erlang:md5_init/0
  - erlang:md5_update/2
  - erlang:memory/0
  - erlang:memory/1
  - erlang:min/2
  - module_loaded/1
  - erlang:monitor/2
  - monitor_node/2
  - erlang:monitor_node/3
  - node/0
  - node/1
  - nodes/0
  - nodes/1
  - now/0
  - open_port/2
  - erlang:phash/2
  - erlang:phash2/2
  - pid_to_list/1
  - port_close/1
  - port_command/2
  - erlang:port_command/3
  - port_connect/2
  - port_control/3
  - erlang:port_call/3
  - erlang:port_info/1
  - erlang:port_info/2
  - erlang:port_to_list/1
  - erlang:ports/0
  - pre_loaded/0
  - erlang:process_display/2
  - process_flag/2
  - process_flag/3
  - process_info/1
  - process_info/2
  - processes/0
  - purge_module/1
  - put/2
  - erlang:raise/3
  - erlang:read_timer/1
  - erlang:ref_to_list/1
  - register/2
  - registered/0
  - erlang:resume_process/1
  - round/1
  - self/0
  - erlang:send/2
  - erlang:send/3
  - erlang:send_after/3
  - erlang:send_nosuspend/2
  - erlang:send_nosuspend/3
  - erlang:set_cookie/2
  - setelement/3
  - size/1
  - spawn/1
  - spawn/2
  - spawn/3
  - spawn/4
  - spawn_link/1
  - spawn_link/2
  - spawn_link/3
  - spawn_link/4
  - spawn_monitor/1
  - spawn_monitor/3
  - spawn_opt/2
  - spawn_opt/3
  - spawn_opt/4
  - spawn_opt/5
  - split_binary/2
  - erlang:start_timer/3
  - statistics/1
  - erlang:suspend_process/2
  - erlang:suspend_process/1
  - erlang:system_flag/2
  - erlang:system_info/1
  - erlang:system_monitor/0
  - erlang:system_monitor/2
  - erlang:system_monitor/2
  - erlang:system_profile/0
  - erlang:system_profile/2
  - term_to_binary/1
  - term_to_binary/2
  - throw/1
  - time/0
  - tl/1
  - erlang:trace/3
  - erlang:trace_delivered/1
  - erlang:trace_info/2
  - erlang:trace_pattern/2
  - erlang:trace_pattern/3
  - trunc/1
  - tuple_size/1
  - tuple_to_list/1
  - erlang:universaltime/0
  - erlang:universaltime_to_localtime/2
  - unlink/1
  - unregister/1
  - whereis/1
  - erlang:yield/0
- init
  - Top of manual page
  - boot/1
  - get_args/0
  - get_argument/1
  - get_arguments/0
  - get_plain_arguments/0
  - get_status/0
  - reboot/0
  - restart/0
  - script_id/0
  - stop/0
  - stop/1
- zlib
  - Top of manual page
  - open/0
  - close/1
  - deflateInit/1
  - deflateInit/2
  - deflateInit/6
  - deflate/2
  - deflate/3
  - deflateSetDictionary/2
  - deflateReset/1
  - deflateParams/3
  - deflateEnd/1
  - inflateInit/1
  - inflateInit/2
  - inflate/2
  - inflateSetDictionary/2
  - inflateReset/1
  - inflateEnd/1
  - setBufSize/2
  - getBufSize/1
  - crc32/1
  - crc32/2
  - crc32/3
  - crc32_combine/4
  - adler32/2
  - adler32/3
  - adler32_combine/4
  - compress/1
  - uncompress/1
  - zip/1
  - unzip/1
  - gzip/1
  - gunzip/1
- epmd
- erl
- erlc
- werl
- escript
- erlsrv
- start_erl
- erl_set_memory_block
  - Top of manual page
  - erl_set_memory_block()
  - erl_memory_show()
  - erl_mem_info_get()
- run_erl
- start
- erl_driver
  - Top of manual page
  - driver_system_info()
  - driver_output()
  - driver_output2()
  - driver_output_binary()
  - driver_outputv()
  - driver_vec_to_buf()
  - driver_set_timer()
  - driver_cancel_timer()
  - driver_read_timer()
  - driver_get_now()
  - driver_select()
  - driver_alloc()
  - driver_realloc()
  - driver_free()
  - driver_alloc_binary()
  - driver_realloc_binary()
  - driver_free_binary()
  - driver_binary_get_refc()
  - driver_binary_inc_refc()
  - driver_binary_dec_refc()
  - driver_enq()
  - driver_pushq()
  - driver_deq()
  - driver_sizeq()
  - driver_enq_bin()
  - driver_pushq_bin()
  - driver_peekq()
  - driver_enqv()
  - driver_pushqv()
  - driver_pdl_create()
  - driver_pdl_lock()
  - driver_pdl_unlock()
  - driver_pdl_get_refc()
  - driver_pdl_inc_refc()
  - driver_pdl_dec_refc()
  - driver_monitor_process()
  - driver_demonitor_process()
  - driver_get_monitored_process()
  - driver_compare_monitors()
  - add_driver_entry()
  - remove_driver_entry()
  - erl_errno_id()
  - set_busy_port()
  - set_port_control_flags()
  - driver_failure_eof()
  - driver_failure_atom()
  - driver_failure_posix()
  - driver_failure()
  - driver_connected()
  - driver_caller()
  - driver_output_term()
  - driver_mk_atom()
  - driver_mk_port()
  - driver_send_term()
  - driver_async ()
  - driver_async_cancel()
  - driver_lock_driver()
  - driver_create_port()
  - erl_drv_thread_create()
  - erl_drv_thread_opts_create()
  - erl_drv_thread_opts_destroy()
  - erl_drv_thread_exit()
  - erl_drv_thread_join()
  - erl_drv_thread_self()
  - erl_drv_equal_tids()
  - erl_drv_mutex_create()
  - erl_drv_mutex_destroy()
  - erl_drv_mutex_lock()
  - erl_drv_mutex_trylock()
  - erl_drv_mutex_unlock()
  - erl_drv_cond_create()
  - erl_drv_cond_destroy()
  - erl_drv_cond_signal()
  - erl_drv_cond_broadcast()
  - erl_drv_cond_wait()
  - erl_drv_rwlock_create()
  - erl_drv_rwlock_destroy()
  - erl_drv_rwlock_rlock()
  - erl_drv_rwlock_tryrlock()
  - erl_drv_rwlock_runlock()
  - erl_drv_rwlock_rwlock()
  - erl_drv_rwlock_tryrwlock()
  - erl_drv_rwlock_rwunlock()
  - erl_drv_tsd_key_create()
  - erl_drv_tsd_key_destroy()
  - erl_drv_tsd_set()
  - erl_drv_tsd_get()
  - erl_drv_putenv()
  - erl_drv_getenv()
- driver_entry
- erts_alloc
- erl_nif
  - Top of manual page
  - enif_get_data()
  - enif_alloc()
  - enif_free()
  - enif_is_binary()
  - enif_inspect_binary()
  - enif_alloc_binary()
  - enif_release_binary()
  - enif_get_int()
  - enif_get_ulong()
  - enif_get_list_cell()
  - enif_make_binary()
  - enif_make_badarg()
  - enif_make_int()
  - enif_make_ulong()
  - enif_make_atom()
  - enif_make_tuple()
  - enif_make_list()
  - enif_make_list_cell()
  - enif_make_string()

# erl_prim_loader

### MODULE

erl_prim_loader

### MODULE SUMMARY

Low Level Erlang Loader

### DESCRIPTION

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 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 runtime 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 evaluating open_port({spawn,Loader},[binary]).

Warning

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

### EXPORTS

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

Types:

Id = term()
Loader = atom() | string()
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 runtime 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(Filename) -> {ok, Bin, FullName} | error

Types:

Filename = string()
Bin = binary()
FullName = string()

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. 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.

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

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.

list_dir(Dir) -> {ok, Filenames} | error

Types:

Dir = name()
Filenames = [Filename]
Filename = string()

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 /otp/root/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin See code(3) about archive files.

read_file_info(Filename) -> {ok, FileInfo} | error

Types:

Filename = name()
FileInfo = #file_info{}

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 /otp/root/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin/mnesia_backup.beam See code(3) about archive files.

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 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 Loader is user defined, the defined Loader port program is started.

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

-id Id

  Specifies the identity of the Erlang runtime 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 runtime system. This flag is mandatory if the -loader inet flag is present.

### SEE ALSO

init(3), erl_boot_server(3)