fn open_file(path: *const u8) -> Result<i32> {
    // Open file
    let ret: i32;
    unsafe {
        asm!("syscall",
            in("rax") 2, // SYS_OPEN
            in("rdi") path,
            in("rsi") 0, // O_RDONLY
            //in("rdx") 0, // This is the mode. It is not used in this case
            out("rcx") _,
            out("r11") _,
            lateout("rax") ret,
        );
    }

    // If there's an error it's 99.999% certain it's because the process has terminated
    if ret.is_negative() {
        bail!("SYS_OPEN returned: {}", ret);
    }

    Ok(ret)
}
// 'path' is a pointer to a null terminated string
// Returns the fd of the open file
'path' is a pointer to a null terminated string
Returns the fd of the open file
' path ' is a pointer to a null terminated string Returns the fd of the open file
fn open_file(path: *const u8) -> Result<i32> {
    // Open file
    let ret: i32;
    unsafe {
        asm!("syscall",
            in("rax") 2, // SYS_OPEN
            in("rdi") path,
            in("rsi") 0, // O_RDONLY
            //in("rdx") 0, // This is the mode. It is not used in this case
            out("rcx") _,
            out("r11") _,
            lateout("rax") ret,
        );
    }
    // If there's an error it's 99.999% certain it's because the process has terminated
    if ret.is_negative() {
        bail!("SYS_OPEN returned: {}", ret);
    }
    Ok(ret)
}
fn open_file ( path : * const u8 ) -> Result < i32 > { // Open file let ret : i32 ; unsafe { asm ! ( " " in ( " " ) 2 // SYS_OPEN in ( " " ) path in ( " " ) 0 // O_RDONLY //in("rdx") 0, // This is the mode. It is not used in this case out ( " " ) out ( " " ) lateout ( " " ) ret ) ; } // If there's an error it's 99.999% certain it's because the process has terminated if ret . is_negative ( ) { bail ! ( " " ret ) ; } Ok ( ret ) }
'path' is a pointer to a null terminated string
Returns the fd of the open file
' path ' is a pointer to a null terminated string Returns the fd of the open file
path
*const u8