rosetta/internal/erl/kernel/r_file
Types
pub type DeleteOption =
Placeholder
pub type FileInfoOption =
Placeholder
pub type FilenameAll =
Placeholder
pub type Placeholder =
dynamic.Dynamic
Represents POSIX error codes (kernel:posix/0
in Erlang).
This type provides a direct mapping to POSIX error codes commonly used in UNIX systems and many C compiler runtime libraries. These codes are used to indicate various system-level errors that can occur during operations such as file I/O, network communication, and process management.
POSIX (Portable Operating System Interface) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. These error codes are part of that standard, ensuring consistent error reporting across different POSIX-compliant systems.
When working with system calls or libraries that interact closely with the operating system, functions may return these error codes to indicate specific failure conditions. Understanding these codes can help in diagnosing issues and handling errors appropriately in your application.
Note: While these codes originate from POSIX standards, their exact behavior or availability may vary slightly depending on the underlying system and the specific Gleam/Erlang libraries being used.
You may also encounter these atoms in other places, like for example inet
.
This is due to Gleam’s limitation: a type can not have fields i.e. from the other type (like in Go, for example)
pub type PosixError {
Eagain
Eacces
Ebadf
Ebadmsg
Ebusy
Edeadlk
Edeadlock
Edquot
Eexist
Efault
Efbig
Eftype
Eintr
Einval
Eio
Eisdir
Emfile
Emlink
Emultihop
Enametoolong
Enfile
Enobufs
Enodev
Enoent
Enolink
Enolck
Enomem
Enospc
Enosr
Enosys
Enostr
Enotblk
Enotdir
Enotsup
Enxio
Eopnotsup
Eoverflow
Eperm
Epipe
Erange
Erofs
Espipe
Esrch
Estale
Exdev
}
Constructors
-
Eagain
Resource temporarily unavailable
-
Eacces
Permision denied - error code
-
Ebadf
Bad file number
-
Ebadmsg
Bad message. NOT DOCUMENTED IN ERLANG Indicates that the message structure is incorrect or the message is of an inappropriate type for the operation being performed.
This error typically occurs in scenarios involving:
- Interprocess communication (IPC)
- Network operations with corrupted or malformed packets
- Stream I/O operations
- Parsing of structured data (e.g., XML, JSON)
Common situations:
- Reading a malformed message from a queue
- Receiving a corrupted network packet
- Attempting to process a stream with an invalid format
Note: While this error code originates from POSIX systems, its exact behavior may vary slightly depending on the underlying system and the specific Gleam/Erlang libraries being used.
-
Ebusy
File busy
-
Edeadlk
Edeadlk
-
Edeadlock
Edeadlock
-
Edquot
Disk quota exceeded
-
Eexist
File already exists
-
Efault
Bad address in system call argument
-
Efbig
File too large
-
Eftype
Missing documentation
-
Eintr
Interrupted system call
-
Einval
Invalid argument
-
Eio
I/O error
-
Eisdir
Illegal operation on a driectory
-
Emfile
Too many open files
-
Emlink
Too many links
-
Emultihop
Multihop attempted NOT DOCUMENTED IN ERLANG Indicates that an attempt was made to perform a multihop operation which is not supported. This error is typically encountered in distributed or network file systems.
Common scenarios:
- Accessing a resource in a distributed file system that requires traversing multiple network nodes
- Operations on file systems that do not support or have limitations on multihop routing
Note: This error is relatively rare and usually appears in the context of advanced network operations or specialized distributed systems.
-
Enametoolong
Filename too long
-
Enfile
File table overflow
-
Enobufs
No buffer space available NOT DOCUMENTED IN ERLANG Indicates that the system lacks sufficient buffer space to perform the requested operation. This error is commonly encountered in network operations and inter-process communication (IPC).
Common scenarios:
- Attempting to send data through a socket when network buffers are full
- Creating new sockets when the system has reached its resource limits
- Operations on message queues when there’s insufficient memory for buffering
Possible causes:
- System overload
- Exhaustion of system resources
- Application errors leading to excessive buffer usage
Handling: Applications should be prepared to handle this error, typically by retrying the operation after a short delay, implementing flow control mechanisms, or managing and releasing unused buffers.
-
Enodev
No such device
-
Enoent
No such file or directory
-
Enolink
Link has been severed NOT DOCUMENTED IN ERLANG Indicates that a link has been severed. This error typically occurs in distributed file systems or network-related operations.
Common scenarios:
- Attempting to access a remote file system resource that is no longer available
- Network connection interruptions in distributed systems
Note: This error is closely related to operations in network file systems.
-
Enolck
No locks available NOT DOCUMENTED IN ERLANG Indicates that no locks are available. This error occurs when a process cannot acquire a lock on a file due to system limits.
Common scenarios:
- Attempting to lock a file when the system’s maximum number of locks is reached
- Issues with file locking mechanisms in the operating system
Note: This error is often encountered in systems with heavy file I/O operations.
-
Enomem
Not enough memory
-
Enospc
No space left on the device
-
Enosr
Out of streams resources NOT DOCUMENTED IN ERLANG Indicates that the system is out of STREAMS resources. This error is specific to systems that implement STREAMS I/O.
Common scenarios:
- Attempting to open a STREAMS device when all STREAMS resources are exhausted
- Heavy usage of STREAMS-based communication in the system
Note: This error is less common in modern systems and may not be relevant in all operating environments.
-
Enosys
Function not implemented NOT DOCUMENTED IN ERLANG Indicates that the function is not implemented on the current system.
Common scenarios:
- Calling a system call or library function that is not supported by the OS
- Attempting to use a feature that is not available in the current environment
Note: This error is important for maintaining portability across different systems.
-
Enostr
Not a STREAM NOT DOCUMENTED IN ERLANG Indicates that a STREAMS operation was attempted on a non-STREAMS device.
Common scenarios:
- Attempting STREAMS I/O operations on a file descriptor that doesn’t support them
- Misuse of STREAMS-related system calls
Note: Like ENosr, this error is specific to systems with STREAMS I/O support.
-
Enotblk
Block device required
-
Enotdir
Not a directory
-
Enotsup
Operation not supported
-
Enxio
No such device or addres
-
Eopnotsup
Operation not supported
-
Eoverflow
Value too large for defined data type NOT DOCUMENTED IN ERLANG Indicates that a value is too large to be stored in a specific data type.
Common scenarios:
- Attempting to store a value in a variable that exceeds its maximum size
- File operations where a file size or offset exceeds the maximum allowed value
Note: This error is important in systems programming and data processing tasks.
-
Eperm
Not owner
-
Epipe
Broken pipe
-
Erange
Missing documentation
-
Erofs
Read-only file system
-
Espipe
Invalid seek
-
Esrch
No such process
-
Estale
Stale remote file handle
-
Exdev
Cross-device link
pub type PosixFileAdvise =
Placeholder
pub type ReadFileOption =
Placeholder
pub type SendfileOption =
Placeholder
Functions
pub fn r_advise_4(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
arg4: Dynamic,
) -> Dynamic
advise/4
pub fn r_allocate_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
allocate/3
pub fn r_change_group_2(arg1: Dynamic, arg2: Dynamic) -> Dynamic
change_group/2
pub fn r_change_owner_2(arg1: Dynamic, arg2: Dynamic) -> Dynamic
change_owner/2
pub fn r_change_owner_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
change_owner/3
pub fn r_change_time_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
change_time/3
pub fn r_make_symlink_2(arg1: Dynamic, arg2: Dynamic) -> Dynamic
make_symlink/2
pub fn r_path_consult_2(arg1: Dynamic, arg2: Dynamic) -> Dynamic
path_consult/2
pub fn r_path_open_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
path_open/3
pub fn r_path_script_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
path_script/3
pub fn r_pwrite_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
pwrite/3
pub fn r_read_file_info_2(
arg1: Dynamic,
arg2: Dynamic,
) -> Dynamic
read_file_info/2
pub fn r_read_link_info_2(
arg1: Dynamic,
arg2: Dynamic,
) -> Dynamic
read_link_info/2
pub fn r_sendfile_5(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
arg4: Dynamic,
arg5: Dynamic,
) -> Dynamic
sendfile/5
pub fn r_write_file_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
write_file/3
pub fn r_write_file_info_2(
arg1: Dynamic,
arg2: Dynamic,
) -> Dynamic
write_file_info/2
pub fn r_write_file_info_3(
arg1: Dynamic,
arg2: Dynamic,
arg3: Dynamic,
) -> Dynamic
write_file_info/3