From 6d8f295fcc7c246afecdb9748cbdc059045cca2b Mon Sep 17 00:00:00 2001 From: wangmengc Date: Tue, 31 Oct 2023 10:28:03 +0800 Subject: [PATCH] add macro for shell_execve function --- bash-5.1/r_execute_cmd/src/lib.rs | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index fd0f82c..335cd11 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -5956,8 +5956,64 @@ unsafe extern "C" fn initialize_subshell() { } } +#[macro_export] +macro_rules! ENOEXEC { + () => { + 8 + }; +} +#[macro_export] +macro_rules! ENOENT { + () => { + 2 + }; +} +#[macro_export] +macro_rules! E2BIG { + () => { + 7 + }; +} + +#[macro_export] +macro_rules! ENOMEM { + () => { + 12 + }; +} + +#[macro_export] +macro_rules! EISDIR { + () => { + 21 + }; +} + +#[macro_export] +macro_rules! HASH_BANG_BUFSIZ { + () => { + 128 + }; +} + +#[macro_export] +macro_rules! READ_SAMPLE_BUF { + ($file:expr, $buf:expr, $len:expr) => { + let mut fd_0 = open($file, O_RDONLY as libc::c_int); + if fd_0 >= 0 { + $len = read( + fd_0, + $buf.as_mut_ptr() as *mut libc::c_void, + HASH_BANG_BUFSIZ!() as libc::c_int as usize, + ) as libc::c_int; + close(fd_0); + } else { + $len = -1; + } + }; +} -- Gitee