pub fn run(args: Vec<String>, envs: Vec<String>, rootfs: Arc<dyn FileSystem>) -> Arc<Process> {
    let job = Job::root();
    let proc = Process::create_linux(&job, rootfs.clone()).unwrap();
    let thread = Thread::create_linux(&proc).unwrap();
    let loader = LinuxElfLoader {
        #[cfg(feature = "std")]
        syscall_entry: kernel_hal::context::syscall_entry as usize,
        #[cfg(not(feature = "std"))]
        syscall_entry: 0,
        stack_pages: 8,
        root_inode: rootfs.root_inode(),
    };

    {
        let mut id = 0;
        let rust_dir = rootfs.root_inode().lookup("/").unwrap();
        trace!("run(), Rootfs: / ");
        while let Ok(name) = rust_dir.get_entry(id) {
            id += 1;
            trace!("  {}", name);
        }
    }
    info!("args {:?}", args);
    let inode = rootfs.root_inode().lookup(&args[0]).unwrap();
    let data = inode.read_as_vec().unwrap();
    let path = args[0].clone();
    debug!("Linux process: {:?}", path);

    let pg_token = kernel_hal::vm::current_vmtoken();
    debug!("current pgt = {:#x}", pg_token);
    //调用zircon-object/src/task/thread.start设置好要执行的thread
    let (entry, sp) = loader.load(&proc.vmar(), &data, args, envs, path).unwrap();

    thread
        .start(entry, sp, 0, 0, thread_fn)
        .expect("failed to start main thread");
    proc
}
/// Create and run main Linux process
Create and run main Linux process
Create and run main Linux process
pub fn run(args: Vec<String>, envs: Vec<String>, rootfs: Arc<dyn FileSystem>) -> Arc<Process> {
    let job = Job::root();
    let proc = Process::create_linux(&job, rootfs.clone()).unwrap();
    let thread = Thread::create_linux(&proc).unwrap();
    let loader = LinuxElfLoader {
        #[cfg(feature = "std")]
        syscall_entry: kernel_hal::context::syscall_entry as usize,
        #[cfg(not(feature = "std"))]
        syscall_entry: 0,
        stack_pages: 8,
        root_inode: rootfs.root_inode(),
    };
    {
        let mut id = 0;
        let rust_dir = rootfs.root_inode().lookup("/").unwrap();
        trace!("run(), Rootfs: / ");
        while let Ok(name) = rust_dir.get_entry(id) {
            id += 1;
            trace!("  {}", name);
        }
    }
    info!("args {:?}", args);
    let inode = rootfs.root_inode().lookup(&args[0]).unwrap();
    let data = inode.read_as_vec().unwrap();
    let path = args[0].clone();
    debug!("Linux process: {:?}", path);
    let pg_token = kernel_hal::vm::current_vmtoken();
    debug!("current pgt = {:#x}", pg_token);
    //调用zircon-object/src/task/thread.start设置好要执行的thread
    let (entry, sp) = loader.load(&proc.vmar(), &data, args, envs, path).unwrap();
    thread
        .start(entry, sp, 0, 0, thread_fn)
        .expect("failed to start main thread");
    proc
}
pub fn run ( args : Vec < String > , envs : Vec < String > , rootfs : Arc < dyn FileSystem > ) -> Arc < Process > { let job = Job :: root ( ) ; let proc = Process :: create_linux ( & job , rootfs . clone ( ) ) . unwrap ( ) ; let thread = Thread :: create_linux ( & proc ) . unwrap ( ) ; let loader = LinuxElfLoader { # [ cfg ( feature " " ) ] syscall_entry : kernel_hal :: context :: syscall_entry as usize , # [ cfg ( not ( feature " " ) ) ] syscall_entry : 0 , stack_pages : 8 , root_inode : rootfs . root_inode ( ) , } ; { let mut id = 0 ; let rust_dir = rootfs . root_inode ( ) . lookup ( " " ) . unwrap ( ) ; trace ! ( " " ) ; while let Ok ( name ) = rust_dir . get_entry ( id ) { id += 1 ; trace ! ( " " name ) ; } } info ! ( " " args ) ; let inode = rootfs . root_inode ( ) . lookup ( & args [ 0 ] ) . unwrap ( ) ; let data = inode . read_as_vec ( ) . unwrap ( ) ; let path = args [ 0 ] . clone ( ) ; debug ! ( " " path ) ; let pg_token = kernel_hal :: vm :: current_vmtoken ( ) ; debug ! ( " " pg_token ) ; //调用zircon-object/src/task/thread.start设置好要执行的thread let ( entry , sp ) = loader . load ( & proc . vmar ( ) , & data , args , envs , path ) . unwrap ( ) ; thread . start ( entry , sp , 0 , 0 , thread_fn ) . expect ( " " ) ; proc }
Create and run main Linux process
Create and run main Linux process
args
Vec<String>
envs
Vec<String>
rootfs
Arc<dyn FileSystem>
args
Vec<String>
envs
Vec<String>
rootfs
Arc<dyn FileSystem>