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 volatile::Volatile;
use rcore_fs::dev::BlockDevice;
use crate::drivers::BlockDriver;
use crate::memory::active_table;
use crate::sync::SpinNoIrqLock as Mutex;

@ -72,21 +72,21 @@ pub trait Driver: Send + Sync {
}
// 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")
}
// 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")
}
// 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")
}
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")
}
}

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

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

@ -105,7 +105,7 @@ impl KernelStack {
pub fn new() -> Self {
use alloc::alloc::{alloc, Layout};
let bottom =
unsafe { alloc(Layout::from_size_align(KSTACK_SIZE, KSTACK_SIZE).unwrap())} as usize;
unsafe { alloc(Layout::from_size_align(KSTACK_SIZE, KSTACK_SIZE).unwrap()) } as usize;
KernelStack(bottom)
}
pub fn top(&self) -> usize {

@ -55,7 +55,7 @@ pub trait Socket: Send + Sync {
fn write(&self, data: &[u8], sendto_endpoint: Option<Endpoint>) -> SysResult;
fn poll(&self) -> (bool, bool, bool); // (in, out, err)
fn connect(&mut self, endpoint: Endpoint) -> SysResult;
fn bind(&mut self, endpoint: Endpoint) -> SysResult {
fn bind(&mut self, _endpoint: Endpoint) -> SysResult {
Err(SysError::EINVAL)
}
fn listen(&mut self) -> SysResult {
@ -73,11 +73,11 @@ pub trait Socket: Send + Sync {
fn remote_endpoint(&self) -> Option<Endpoint> {
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");
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");
Ok(0)
}

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

@ -6,28 +6,28 @@ use crate::process::*;
use alloc::string::String;
use alloc::vec::Vec;
#[cfg(not(feature = "run_cmdline"))]
pub fn add_user_shell() {
/// the busybox of alpine linux can not transfer env vars into child process
/// Now we use busybox from
/// https://raw.githubusercontent.com/docker-library/busybox/82bc0333a9ae148fbb4246bcbff1487b3fc0c510/musl/busybox.tar.xz -O busybox.tar.xz
/// This one can transfer env vars!
/// Why???
// #[cfg(target_arch = "x86_64")]
// let init_shell="/bin/busybox"; // from alpine linux
//
// #[cfg(not(target_arch = "x86_64"))]
let init_shell="/busybox"; //from docker-library
// the busybox of alpine linux can not transfer env vars into child process
// Now we use busybox from
// https://raw.githubusercontent.com/docker-library/busybox/82bc0333a9ae148fbb4246bcbff1487b3fc0c510/musl/busybox.tar.xz -O busybox.tar.xz
// This one can transfer env vars!
// Why???
// #[cfg(target_arch = "x86_64")]
// let init_shell="/bin/busybox"; // from alpine linux
//
// #[cfg(not(target_arch = "x86_64"))]
let init_shell = "/busybox"; //from docker-library
#[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"))]
let init_envs=Vec::new();
let init_envs = Vec::new();
let init_args=vec!["busybox".into(), "ash".into()];
let init_args = vec!["busybox".into(), "ash".into()];
if let Ok(inode) = ROOT_INODE.lookup(init_shell) {
let data = inode.read_as_vec().unwrap();

@ -625,27 +625,23 @@ pub fn sys_pipe(fds: *mut u32) -> SysResult {
let fds = unsafe { proc.vm.check_write_array(fds, 2)? };
let (read, write) = Pipe::create_pair();
let read_fd = proc.add_file(
FileLike::File(FileHandle::new(
let read_fd = proc.add_file(FileLike::File(FileHandle::new(
Arc::new(read),
OpenOptions {
read: true,
write: false,
append: false,
},
)),
);
)));
let write_fd = proc.add_file(
FileLike::File(FileHandle::new(
let write_fd = proc.add_file(FileLike::File(FileHandle::new(
Arc::new(write),
OpenOptions {
read: false,
write: true,
append: false,
},
)),
);
)));
fds[0] = read_fd as u32;
fds[1] = write_fd as u32;
@ -678,9 +674,7 @@ pub fn sys_sendfile(
let mut buffer = [0u8; 1024];
let mut read_offset = if !offset_ptr.is_null() {
unsafe {
*(*proc_cell.get()).vm.check_read_ptr(offset_ptr)?
}
unsafe { *(*proc_cell.get()).vm.check_read_ptr(offset_ptr)? }
} else {
in_file.seek(SeekFrom::Current(0))? as usize
};
@ -700,7 +694,7 @@ pub fn sys_sendfile(
let mut bytes_written = 0;
let mut rlen = read_len;
while bytes_written < read_len {
let write_len = out_file.write(&buffer[bytes_written..(bytes_written+rlen)])?;
let write_len = out_file.write(&buffer[bytes_written..(bytes_written + rlen)])?;
if write_len == 0 {
info!(
"sendfile:END_ERR out: {}, in: {}, offset_ptr: {:?}, count: {} = bytes_read {}, bytes_written {}, write_len {}",
@ -709,9 +703,9 @@ pub fn sys_sendfile(
return Err(SysError::EBADF);
}
bytes_written += write_len;
rlen-=write_len;
rlen -= write_len;
}
total_written+=bytes_written;
total_written += bytes_written;
}
if !offset_ptr.is_null() {

@ -46,15 +46,15 @@ pub fn sys_mmap(
addr,
addr + len,
prot.to_attr(),
// ByFrame::new(GlobalFrameAlloc), //eagle mmap mode
// ByFrame::new(GlobalFrameAlloc), //eagle mmap mode
Delay::new(GlobalFrameAlloc),
"mmap_anon",
);
//init with zero for eagle mmap mode
// let data = unsafe { slice::from_raw_parts_mut(addr as *mut u8, len) };
// for x in data {
// *x = 0;
// }
// let data = unsafe { slice::from_raw_parts_mut(addr as *mut u8, len) };
// for x in data {
// *x = 0;
// }
return Ok(addr);
} else {
// only check

@ -192,15 +192,16 @@ pub struct RLimit {
max: u64, // hard limit
}
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);
let mut proc = process();
let slice = unsafe { proc.vm.check_write_array(buf, len)? };
let mut i=0;
let mut i = 0;
for elm in slice {
unsafe{ *elm=i+ crate::trap::TICK as u8;}
i+=1;
unsafe {
*elm = i + crate::trap::TICK as u8;
}
i += 1;
}
Ok(len)

@ -231,7 +231,7 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
SYS_MAP_PCI_DEVICE => sys_map_pci_device(args[0], args[1]),
SYS_GET_PADDR => sys_get_paddr(args[0] as *const u64, args[1] as *mut u64, args[2]),
//SYS_GETRANDOM => unimplemented("getrandom", Err(SysError::EINVAL)),
SYS_GETRANDOM =>sys_getrandom( args[0] as *mut u8, args[1] as usize, args[2] as u32),
SYS_GETRANDOM => sys_getrandom(args[0] as *mut u8, args[1] as usize, args[2] as u32),
SYS_TKILL => unimplemented("tkill", Ok(0)),
_ => {
let ret = match () {

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