|
|
@ -463,7 +463,7 @@ int sys_umask(int mask)
|
|
|
|
return (old);
|
|
|
|
return (old);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// rememeber to sync when munmap exit manual
|
|
|
|
long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
|
|
|
|
long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printk("start mmaping\n");
|
|
|
|
printk("start mmaping\n");
|
|
|
@ -481,6 +481,7 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
|
|
|
|
char *temp,*p1,*p2;
|
|
|
|
char *temp,*p1,*p2;
|
|
|
|
void * buf=start;
|
|
|
|
void * buf=start;
|
|
|
|
int tempprot=0;
|
|
|
|
int tempprot=0;
|
|
|
|
|
|
|
|
//因为new.h和namei.c定义不一样,要修改
|
|
|
|
if(prot &PROT_READ) tempprot |=4;
|
|
|
|
if(prot &PROT_READ) tempprot |=4;
|
|
|
|
if(prot &PROT_EXEC) tempprot |=1;
|
|
|
|
if(prot &PROT_EXEC) tempprot |=1;
|
|
|
|
if(prot &PROT_WRITE) tempprot |=2;
|
|
|
|
if(prot &PROT_WRITE) tempprot |=2;
|
|
|
@ -504,53 +505,38 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
|
|
|
|
printk("error permission.");
|
|
|
|
printk("error permission.");
|
|
|
|
return MAP_FAILED;
|
|
|
|
return MAP_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//end of permission check
|
|
|
|
printk("end of permissions\n");
|
|
|
|
printk("end of permissions\n");
|
|
|
|
if(start<=current->brk || start>=current->start_stack-0x8000 || start==NULL)
|
|
|
|
if(start<=current->brk || start>=current->start_stack-0x8000 || start==NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!current->mmap_tail)
|
|
|
|
buf=0x2000000;
|
|
|
|
buf=0x2000000;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
buf=current->mmap_tail->endaddr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mmap_struct *mmap=(struct mmap_struct *)malloc(sizeof(struct mmap_struct));
|
|
|
|
|
|
|
|
mmap->address=buf;mmap->size=len;
|
|
|
|
|
|
|
|
mmap->endaddr=buf+(len + 0xfff)&0xfffff000;
|
|
|
|
|
|
|
|
mmap->rw=prot;mmap->ps=flags;
|
|
|
|
|
|
|
|
mmap->next=NULL;
|
|
|
|
|
|
|
|
if(!current->mmap)
|
|
|
|
|
|
|
|
{current->mmap=current->mapp_tail=mapp;}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
current->mmap_tail->next=mapp;
|
|
|
|
printk("buf: %x\n",(unsigned long )buf);
|
|
|
|
printk("buf: %x\n",(unsigned long )buf);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//read and put in
|
|
|
|
if (!(block = inode->i_zone[0]))
|
|
|
|
if (!(block = inode->i_zone[0]))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
if (!(bh = bread(inode->i_dev,block)))
|
|
|
|
if (!(bh = bread(inode->i_dev,block)))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
temp = (char *) bh->b_data;
|
|
|
|
temp = (char *) bh->b_data;
|
|
|
|
/* int nr[4];
|
|
|
|
|
|
|
|
unsigned long page;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
unsigned long address=current->start_code+(unsigned long)buf;
|
|
|
|
|
|
|
|
printk("start of page\n");
|
|
|
|
|
|
|
|
//this part comes from do_no_page as achievement of immediate loading of cs and ds
|
|
|
|
|
|
|
|
while(address<=current->start_code+len+(unsigned long)buf)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printk("address: %x\n",address);
|
|
|
|
|
|
|
|
address &= 0xfffff000;
|
|
|
|
|
|
|
|
if (!(page = get_free_page()))
|
|
|
|
|
|
|
|
return MAP_FAILED;
|
|
|
|
|
|
|
|
for (i=0 ; i<4 ; block++,i++)
|
|
|
|
|
|
|
|
nr[i] = bmap(inode,block);
|
|
|
|
|
|
|
|
bread_page(page,inode->i_dev,nr);
|
|
|
|
|
|
|
|
if (!put_page(page,address))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
free_page(page);
|
|
|
|
|
|
|
|
return MAP_FAILED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int k=0;char c=0;
|
|
|
|
|
|
|
|
while(k++<60){c=get_fs_byte(address-current->start_code);printk("%c",c);}
|
|
|
|
|
|
|
|
printk("\n");
|
|
|
|
|
|
|
|
address+=PAGE_SIZE;
|
|
|
|
|
|
|
|
k=0;
|
|
|
|
|
|
|
|
while(k++<60)printk("%c",(char*)(page+k));
|
|
|
|
|
|
|
|
printk("\n");
|
|
|
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
printk("end of mmap\n");
|
|
|
|
printk("end of mmap\n");
|
|
|
|
p1=temp;p2=buf;
|
|
|
|
p1=temp;p2=buf;
|
|
|
|
while(l--)
|
|
|
|
while(l--)
|
|
|
|
put_fs_byte(*(p1++),p2++);
|
|
|
|
put_fs_byte(*(p1++),p2++);
|
|
|
|
printk("%s\n",temp);
|
|
|
|
printk("%s\n",temp);
|
|
|
|
return buf;
|
|
|
|
return buf;
|
|
|
|
return MAP_FAILED;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int sys_munmap()
|
|
|
|
int sys_munmap()
|
|
|
|
{
|
|
|
|
{
|
|
|
|