Format code

toolchain_update
Jiajie Chen 6 years ago
parent 72efa797e5
commit e5894b652c

@ -12,8 +12,6 @@ use rcore_memory::paging::PageTable;
use rcore_memory::PAGE_SIZE; use rcore_memory::PAGE_SIZE;
use volatile::Volatile; use volatile::Volatile;
use rcore_fs::dev::BlockDevice;
use crate::drivers::BlockDriver; use crate::drivers::BlockDriver;
use crate::memory::active_table; use crate::memory::active_table;
use crate::sync::SpinNoIrqLock as Mutex; use crate::sync::SpinNoIrqLock as Mutex;

@ -72,21 +72,21 @@ pub trait Driver: Send + Sync {
} }
// send an ethernet frame, only use it when necessary // send an ethernet frame, only use it when necessary
fn send(&self, data: &[u8]) -> Option<usize> { fn send(&self, _data: &[u8]) -> Option<usize> {
unimplemented!("not a net driver") unimplemented!("not a net driver")
} }
// get mac address from ip address in arp table // get mac address from ip address in arp table
fn get_arp(&self, ip: IpAddress) -> Option<EthernetAddress> { fn get_arp(&self, _ip: IpAddress) -> Option<EthernetAddress> {
unimplemented!("not a net driver") unimplemented!("not a net driver")
} }
// block related drivers should implement these // block related drivers should implement these
fn read_block(&self, block_id: usize, buf: &mut [u8]) -> bool { fn read_block(&self, _block_id: usize, _buf: &mut [u8]) -> bool {
unimplemented!("not a block driver") unimplemented!("not a block driver")
} }
fn write_block(&self, block_id: usize, buf: &[u8]) -> bool { fn write_block(&self, _block_id: usize, _buf: &[u8]) -> bool {
unimplemented!("not a block driver") unimplemented!("not a block driver")
} }
} }

@ -15,7 +15,6 @@ use smoltcp::wire::EthernetAddress;
use smoltcp::wire::*; use smoltcp::wire::*;
use smoltcp::Result; use smoltcp::Result;
use crate::memory::active_table;
use crate::net::SOCKETS; use crate::net::SOCKETS;
use crate::sync::FlagsGuard; use crate::sync::FlagsGuard;
use crate::sync::SpinNoIrqLock as Mutex; use crate::sync::SpinNoIrqLock as Mutex;

@ -2,7 +2,6 @@ use alloc::alloc::{GlobalAlloc, Layout};
use alloc::format; use alloc::format;
use alloc::string::String; use alloc::string::String;
use alloc::sync::Arc; use alloc::sync::Arc;
use alloc::vec::Vec;
use core::mem::size_of; use core::mem::size_of;
use core::slice; use core::slice;

@ -55,7 +55,7 @@ pub trait Socket: Send + Sync {
fn write(&self, data: &[u8], sendto_endpoint: Option<Endpoint>) -> SysResult; fn write(&self, data: &[u8], sendto_endpoint: Option<Endpoint>) -> SysResult;
fn poll(&self) -> (bool, bool, bool); // (in, out, err) fn poll(&self) -> (bool, bool, bool); // (in, out, err)
fn connect(&mut self, endpoint: Endpoint) -> SysResult; fn connect(&mut self, endpoint: Endpoint) -> SysResult;
fn bind(&mut self, endpoint: Endpoint) -> SysResult { fn bind(&mut self, _endpoint: Endpoint) -> SysResult {
Err(SysError::EINVAL) Err(SysError::EINVAL)
} }
fn listen(&mut self) -> SysResult { fn listen(&mut self) -> SysResult {
@ -73,11 +73,11 @@ pub trait Socket: Send + Sync {
fn remote_endpoint(&self) -> Option<Endpoint> { fn remote_endpoint(&self) -> Option<Endpoint> {
None None
} }
fn setsockopt(&mut self, level: usize, opt: usize, data: &[u8]) -> SysResult { fn setsockopt(&mut self, _level: usize, _opt: usize, _data: &[u8]) -> SysResult {
warn!("setsockopt is unimplemented"); warn!("setsockopt is unimplemented");
Ok(0) Ok(0)
} }
fn ioctl(&mut self, request: usize, arg1: usize, arg2: usize, arg3: usize) -> SysResult { fn ioctl(&mut self, _request: usize, _arg1: usize, _arg2: usize, _arg3: usize) -> SysResult {
warn!("ioctl is unimplemented for this socket"); warn!("ioctl is unimplemented for this socket");
Ok(0) Ok(0)
} }

@ -15,7 +15,6 @@ use xmas_elf::{
use crate::arch::interrupt::{Context, TrapFrame}; use crate::arch::interrupt::{Context, TrapFrame};
use crate::fs::{FileHandle, FileLike, INodeExt, OpenOptions, FOLLOW_MAX_DEPTH}; use crate::fs::{FileHandle, FileLike, INodeExt, OpenOptions, FOLLOW_MAX_DEPTH};
use crate::memory::{ByFrame, GlobalFrameAlloc, KernelStack, MemoryAttr, MemorySet}; use crate::memory::{ByFrame, GlobalFrameAlloc, KernelStack, MemoryAttr, MemorySet};
use crate::net::SOCKETS;
use crate::sync::{Condvar, SpinNoIrqLock as Mutex}; use crate::sync::{Condvar, SpinNoIrqLock as Mutex};
use super::abi::{self, ProcInitInfo}; use super::abi::{self, ProcInitInfo};

@ -6,14 +6,13 @@ use crate::process::*;
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
#[cfg(not(feature = "run_cmdline"))] #[cfg(not(feature = "run_cmdline"))]
pub fn add_user_shell() { pub fn add_user_shell() {
/// the busybox of alpine linux can not transfer env vars into child process // the busybox of alpine linux can not transfer env vars into child process
/// Now we use busybox from // Now we use busybox from
/// https://raw.githubusercontent.com/docker-library/busybox/82bc0333a9ae148fbb4246bcbff1487b3fc0c510/musl/busybox.tar.xz -O busybox.tar.xz // https://raw.githubusercontent.com/docker-library/busybox/82bc0333a9ae148fbb4246bcbff1487b3fc0c510/musl/busybox.tar.xz -O busybox.tar.xz
/// This one can transfer env vars! // This one can transfer env vars!
/// Why??? // Why???
// #[cfg(target_arch = "x86_64")] // #[cfg(target_arch = "x86_64")]
// let init_shell="/bin/busybox"; // from alpine linux // let init_shell="/bin/busybox"; // from alpine linux
@ -22,7 +21,8 @@ pub fn add_user_shell() {
let init_shell = "/busybox"; //from docker-library let init_shell = "/busybox"; //from docker-library
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
let init_envs=vec!["PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-alpine-linux-musl/bin".into()]; let init_envs =
vec!["PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-alpine-linux-musl/bin".into()];
#[cfg(not(target_arch = "x86_64"))] #[cfg(not(target_arch = "x86_64"))]
let init_envs = Vec::new(); let init_envs = Vec::new();

@ -625,27 +625,23 @@ pub fn sys_pipe(fds: *mut u32) -> SysResult {
let fds = unsafe { proc.vm.check_write_array(fds, 2)? }; let fds = unsafe { proc.vm.check_write_array(fds, 2)? };
let (read, write) = Pipe::create_pair(); let (read, write) = Pipe::create_pair();
let read_fd = proc.add_file( let read_fd = proc.add_file(FileLike::File(FileHandle::new(
FileLike::File(FileHandle::new(
Arc::new(read), Arc::new(read),
OpenOptions { OpenOptions {
read: true, read: true,
write: false, write: false,
append: false, append: false,
}, },
)), )));
);
let write_fd = proc.add_file( let write_fd = proc.add_file(FileLike::File(FileHandle::new(
FileLike::File(FileHandle::new(
Arc::new(write), Arc::new(write),
OpenOptions { OpenOptions {
read: false, read: false,
write: true, write: true,
append: false, append: false,
}, },
)), )));
);
fds[0] = read_fd as u32; fds[0] = read_fd as u32;
fds[1] = write_fd as u32; fds[1] = write_fd as u32;
@ -678,9 +674,7 @@ pub fn sys_sendfile(
let mut buffer = [0u8; 1024]; let mut buffer = [0u8; 1024];
let mut read_offset = if !offset_ptr.is_null() { let mut read_offset = if !offset_ptr.is_null() {
unsafe { unsafe { *(*proc_cell.get()).vm.check_read_ptr(offset_ptr)? }
*(*proc_cell.get()).vm.check_read_ptr(offset_ptr)?
}
} else { } else {
in_file.seek(SeekFrom::Current(0))? as usize in_file.seek(SeekFrom::Current(0))? as usize
}; };

@ -193,13 +193,14 @@ pub struct RLimit {
} }
pub fn sys_getrandom(buf: *mut u8, len: usize, flag: u32) -> SysResult { pub fn sys_getrandom(buf: *mut u8, len: usize, flag: u32) -> SysResult {
//info!("getrandom: buf: {:?}, len: {:?}, falg {:?}", buf, len,flag); //info!("getrandom: buf: {:?}, len: {:?}, falg {:?}", buf, len,flag);
let mut proc = process(); let mut proc = process();
let slice = unsafe { proc.vm.check_write_array(buf, len)? }; let slice = unsafe { proc.vm.check_write_array(buf, len)? };
let mut i = 0; let mut i = 0;
for elm in slice { for elm in slice {
unsafe{ *elm=i+ crate::trap::TICK as u8;} unsafe {
*elm = i + crate::trap::TICK as u8;
}
i += 1; i += 1;
} }

@ -1 +1 @@
Subproject commit 8dbc0edb935a62d748aaac39258d4a985de0ae17 Subproject commit 05f0efd3fda084109e4b6da8ff30ecb1557a267f
Loading…
Cancel
Save