openThe open builtin allows you to create new IO spaces, by opening an
IO device. It has the following prototype:
fun open = (string handler, uint<64> flags = 0) int<32>
where handler is a string identifying the IO device that will serve the IO space. This handler can be:
*name*An auto growing memory buffer.
pid://[0-9]+The process ID of some process.
/path/to/fileAn either absolute or relative path to a file.
nbd://host:port/exportnbd+unix:///export?socket=/path/to/socketA connection to an NBD server. See nbd command
flags is a bitmask that specifies several aspects of the operation, including the mode in which the IO space is opened. Its value is usually built by ORing a set of flags that are provided by the compiler. These are:
IOS_F_READThe IO space is intended to be read.
IOS_F_WRITEThe IO space is intended to be written.
IOS_F_CREATEIf the IO device doesn’t exist, then create it, usually empty.
Note that the specific behaviour of these flags depend on the nature of the IO space that is opened. For example a memory buffer is always truncated at creation by default.
In order to ease the usage of open, a few pre-made bitmaps are
provided to specify opening modes:
IOS_M_RDONLYThis is equivalent to IOS_F_READ.
IOS_M_WRONLYThis is equivalent to IOS_F_WRITE.
IOS_M_RDWRThis is equivalent to IOS_F_READ | IOS_F_WRITE.
The open builtin returns a signed 32-bit integer. This number
will identify the just opened IOS until it gets closed.
If there is a problem opening the specified IO device then open
will raise an E_no_ios exception.