bug solved version of munmap

master
forever-learner 2 years ago
parent 9465af4e86
commit 0e544a13f5

@ -466,7 +466,6 @@ void calc_mem(void)
}
}
static int my_share(unsigned long address, struct task_struct * p)
{
unsigned long from;
@ -505,10 +504,9 @@ static int my_share(unsigned long address, struct task_struct * p)
long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
{
printk("start mmaping\n");
/* va_list args;
va_start(args,len); */
int prot=3,flags=1,fd=3,off=0;
int prot=3,flags=2,fd=3,off=0;
/* prot=va_arg(args,int);flags=va_arg(args,int);fd=va_arg(args,int);
off_t off=va_arg(args,off_t);
int *ll=&len;printk("%d,%d,%d,%d,%d\n",*ll,*(ll+1),*(ll+2),*(ll+3),*(ll+4));
@ -544,12 +542,11 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
if(!(prot& PROT_READ)) return MAP_FAILED;
//permissions of the file ,搬运函数namei.c::permissions
printk("fd: %d\n",fd);
struct m_inode *inode=current->filp[fd]->f_inode;
printk("end of permissions\n");
int mode = inode->i_mode;
if (inode->i_dev && !inode->i_nlinks)
{printk("end of permissions1\n");return MAP_FAILED;}
return MAP_FAILED;
else if (current->euid==inode->i_uid)
mode >>= 6;
else if (current->egid==inode->i_gid)
@ -560,7 +557,6 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
return MAP_FAILED;
}
//end of permission check
printk("end of permissions\n");
//设置用户空间的虚拟地址初始为32MB处这样写在brk增长至32MB时会有bug,我们忽略
//同时,当栈向下增长到一定程度时,也会和当前地址冲突,我们忽略
@ -580,7 +576,6 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
mmap->ps=flags;
mmap->filenode=(struct m_inode*)malloc(sizeof(struct m_inode));
memcpy(mmap->filenode,inode,sizeof(struct m_inode));
printk("izone[0]:%x:\n",inode->i_zone[0]);
if(!mmap->filenode->i_count)mmap->filenode->i_count=1;
mmap->off=off;
mmap->next=NULL;
@ -591,7 +586,6 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
current->mmap_tail->next=mmap;
current->mmap_tail=mmap;
}
printk("buf: %x\n",(unsigned long )buf);
//分配物理页
@ -635,7 +629,7 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
if(flags & MAP_SHARED)
{
printk("i am doing sharing.");
//printk("i am doing sharing.");
struct task_struct ** p;
for (p = &LAST_TASK ; p > &FIRST_TASK ; --p) {
@ -661,7 +655,6 @@ long sys_mmap(void * start,size_t len,...)// int prot,int flags,int fd,off_t off
p1=temp+off;p2=buf;
while(l--)
put_fs_byte(*(p1++),p2++);
printk("%s\n",temp+off);
return buf;
}
static int my_sync(off_t pos, struct m_inode * inode, char * buf, int count)
@ -671,21 +664,6 @@ static int my_sync(off_t pos, struct m_inode * inode, char * buf, int count)
char * p;
int i=0;
//int block;
//struct buffer_head * bh;
struct dir_entry * de;
int ttp=0;;
printk("sync:izone[0]:%x:\n",inode->i_zone[0]);
if (!(block = inode->i_zone[0]))
return -1;
if (!(bh = bread(inode->i_dev,block)))
return -1;
de=(char*)bh->b_data;
for(ttp=0;ttp<count;ttp++)
{
printk("char:%c,",*(de+ttp));
}
while (i<count) {
if (!(block = create_block(inode,pos/BLOCK_SIZE)))
break;
@ -741,7 +719,6 @@ int sys_munmap(void * start ,size_t size)
else{
pre->next=temp->next;
}
printk("addr: %lx,endaddr : %lx\n",temp->address,temp->endaddr);
unsigned long from;
unsigned long to;
unsigned long from_page;
@ -818,21 +795,9 @@ mytag:
else{
*(unsigned long *)from_page &= ~1;
}
address+=PAGE_SIZE;
}
int block;
struct buffer_head * bh;
struct dir_entry * de;
int ttp=0;;
printk("temp->izone[0]:%x:\n",temp->filenode->i_zone[0]);
if (!(block = temp->filenode->i_zone[0]))
return -1;
if (!(bh = bread(temp->filenode->i_dev,block)))
return -1;
de=(char*)bh->b_data;
for(ttp=0;ttp<temp->size;ttp++)
{
printk("char:%c,",*(de+ttp));
}
free(temp->filenode);
free(temp);
return 0;
}

Loading…
Cancel
Save