Fix uvmcopy bugs.
This commit is contained in:
parent
f6e265ca70
commit
82c94b5311
|
@ -777,8 +777,6 @@ int enext(struct dirent *dp, struct dirent *ep, uint off, int *count)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
dp->clus_cnt = 0;
|
||||
dp->cur_clus = dp->first_clus;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/* Copyright 2018 Canaan Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef _GPIO_COMMON_H
|
||||
#define _GPIO_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum _gpio_drive_mode
|
||||
{
|
||||
GPIO_DM_INPUT,
|
||||
GPIO_DM_INPUT_PULL_DOWN,
|
||||
GPIO_DM_INPUT_PULL_UP,
|
||||
GPIO_DM_OUTPUT,
|
||||
} gpio_drive_mode_t;
|
||||
|
||||
typedef enum _gpio_pin_edge
|
||||
{
|
||||
GPIO_PE_NONE,
|
||||
GPIO_PE_FALLING,
|
||||
GPIO_PE_RISING,
|
||||
GPIO_PE_BOTH,
|
||||
GPIO_PE_LOW,
|
||||
GPIO_PE_HIGH = 8,
|
||||
} gpio_pin_edge_t;
|
||||
|
||||
typedef enum _gpio_pin_value
|
||||
{
|
||||
GPIO_PV_LOW,
|
||||
GPIO_PV_HIGH
|
||||
} gpio_pin_value_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GPIO_COMMON_H */
|
|
@ -15,14 +15,29 @@
|
|||
#ifndef _DRIVER_GPIOHS_H
|
||||
#define _DRIVER_GPIOHS_H
|
||||
|
||||
// #include <stddef.h>
|
||||
// #include <stdint.h>
|
||||
#include "gpio_common.h"
|
||||
// #include "platform.h"
|
||||
#include "plic.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef enum _gpio_drive_mode
|
||||
{
|
||||
GPIO_DM_INPUT,
|
||||
GPIO_DM_INPUT_PULL_DOWN,
|
||||
GPIO_DM_INPUT_PULL_UP,
|
||||
GPIO_DM_OUTPUT,
|
||||
} gpio_drive_mode_t;
|
||||
|
||||
typedef enum _gpio_pin_edge
|
||||
{
|
||||
GPIO_PE_NONE,
|
||||
GPIO_PE_FALLING,
|
||||
GPIO_PE_RISING,
|
||||
GPIO_PE_BOTH,
|
||||
GPIO_PE_LOW,
|
||||
GPIO_PE_HIGH = 8,
|
||||
} gpio_pin_edge_t;
|
||||
|
||||
typedef enum _gpio_pin_value
|
||||
{
|
||||
GPIO_PV_LOW,
|
||||
GPIO_PV_HIGH
|
||||
} gpio_pin_value_t;
|
||||
|
||||
/* clang-format off */
|
||||
/* Register address offsets */
|
||||
|
@ -259,8 +274,5 @@ void gpiohs_set_irq(uint8 pin, uint32 priority, void (*func)());
|
|||
*/
|
||||
void gpiohs_irq_unregister(uint8 pin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DRIVER_GPIOHS_H */
|
||||
|
|
|
@ -131,7 +131,12 @@ create(char *path, short type)
|
|||
return NULL;
|
||||
|
||||
elock(dp);
|
||||
ep = ealloc(dp, name, type == T_DIR);
|
||||
if ((ep = ealloc(dp, name, type == T_DIR)) == NULL) {
|
||||
eunlock(dp);
|
||||
eput(dp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((type == T_DIR && !(ep->attribute & ATTR_DIRECTORY)) ||
|
||||
(type == T_FILE && (ep->attribute & ATTR_DIRECTORY))) {
|
||||
eput(ep);
|
||||
|
@ -373,15 +378,24 @@ sys_remove(void)
|
|||
{
|
||||
char path[FAT32_MAX_PATH];
|
||||
struct dirent *ep;
|
||||
|
||||
if(argstr(0, path, FAT32_MAX_PATH) < 0)
|
||||
int len;
|
||||
if((len = argstr(0, path, FAT32_MAX_PATH)) <= 0)
|
||||
return -1;
|
||||
|
||||
char *s = path + len - 1;
|
||||
while (s >= path && *s == '/') {
|
||||
s--;
|
||||
}
|
||||
if (s >= path && *s == '.' && (s == path || *--s == '/')) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((ep = ename(path)) == NULL){
|
||||
return -1;
|
||||
}
|
||||
elock(ep);
|
||||
if(//ep->ref != 1 ||
|
||||
((ep->attribute & ATTR_DIRECTORY) && !isdirempty(ep))){
|
||||
((ep->attribute & ATTR_DIRECTORY) && !isdirempty(ep))){
|
||||
eunlock(ep);
|
||||
eput(ep);
|
||||
return -1;
|
||||
|
|
14
kernel/vm.c
14
kernel/vm.c
|
@ -372,11 +372,11 @@ int
|
|||
uvmcopy(pagetable_t old, pagetable_t new, pagetable_t knew, uint64 sz)
|
||||
{
|
||||
pte_t *pte;
|
||||
uint64 pa, i;
|
||||
uint64 pa, i = 0, ki = 0;
|
||||
uint flags;
|
||||
char *mem;
|
||||
|
||||
for(i = 0; i < sz; i += PGSIZE){
|
||||
while (i < sz){
|
||||
if((pte = walk(old, i, 0)) == NULL)
|
||||
panic("uvmcopy: pte should exist");
|
||||
if((*pte & PTE_V) == 0)
|
||||
|
@ -386,16 +386,20 @@ uvmcopy(pagetable_t old, pagetable_t new, pagetable_t knew, uint64 sz)
|
|||
if((mem = kalloc()) == NULL)
|
||||
goto err;
|
||||
memmove(mem, (char*)pa, PGSIZE);
|
||||
if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0 ||
|
||||
mappages(knew, i, PGSIZE, (uint64)mem, flags & ~PTE_U) != 0){
|
||||
if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0) {
|
||||
kfree(mem);
|
||||
goto err;
|
||||
}
|
||||
i += PGSIZE;
|
||||
if(mappages(knew, ki, PGSIZE, (uint64)mem, flags & ~PTE_U) != 0){
|
||||
goto err;
|
||||
}
|
||||
ki += PGSIZE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
err:
|
||||
vmunmap(knew, 0, i / PGSIZE, 0);
|
||||
vmunmap(knew, 0, ki / PGSIZE, 0);
|
||||
vmunmap(new, 0, i / PGSIZE, 1);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1798,10 +1798,10 @@ rmdot(char *s)
|
|||
printf("%s: chdir dots failed\n", s);
|
||||
exit(1);
|
||||
}
|
||||
// if(remove(".") == 0){
|
||||
// printf("%s: rm . worked!\n", s);
|
||||
// exit(1);
|
||||
// }
|
||||
if(remove(".") == 0){
|
||||
printf("%s: rm . worked!\n", s);
|
||||
exit(1);
|
||||
}
|
||||
if(remove("..") == 0){
|
||||
printf("%s: rm .. worked!\n", s);
|
||||
exit(1);
|
||||
|
@ -1810,10 +1810,10 @@ rmdot(char *s)
|
|||
printf("%s: chdir / failed\n", s);
|
||||
exit(1);
|
||||
}
|
||||
// if(remove("dots/.") == 0){
|
||||
// printf("%s: remove dots/. worked!\n", s);
|
||||
// exit(1);
|
||||
// }
|
||||
if(remove("dots/.") == 0){
|
||||
printf("%s: remove dots/. worked!\n", s);
|
||||
exit(1);
|
||||
}
|
||||
if(remove("dots/..") == 0){
|
||||
printf("%s: remove dots/.. worked!\n", s);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue