系统管理相关命令:df、top、free、quota、at、lp、adduser、groupaddkill、crontab、tar、unzip、gunzip、last
loc_page(gfp_mask);</P> if(unlikely(!area->pages)){
/*Successfullyallocatedipages,freethemin__vunmap()*/
area->nr_pages=i;
gotofail;
}
}
//为所分派的页面创建映照干系
if(map_vm_area(area,prot,&pages))
gotofail;
returnarea->addr;
fail:
vfree(area->addr);
returnNULL;
}
map_vm_area为所分派的内存创建映照干系,它的程序流程与unmap_vm_area差未几,都是从pgd找到pte,假如一样的映照干系不存在,则新建之.(如:pgd对应的pmd不存在,则新建pmd项,使pgd指向建好的pmd.同理,假如pmd所映照的pte项不存在,则新建pte,然后创建映照),然后将pte映照到响应的页表.代码以下:
intmap_vm_area(structvm_struct*area,pgprot_tprot,structpage***pages)
{
unsignedlongaddress=(unsignedlong)area->addr;
unsignedlongend=address+(area->size-PAGE_SIZE);
pgd_t*dir;
interr=0;
//vm肇端地点地点的页目次
dir=pgd_offset_k(address);
spin_lock(&init_mm.page_table_lock);
do{
pmd_t*pmd=pmd_alloc(&init_mm,dir,address);
if(!pmd){
err=-ENOMEM;
break;
}
//轮到pmd了^_^
if(map_area_pmd(pmd,address,end-address,prot,pages)){
err=-ENOMEM;
break;
}
address=(address+PGDIR_SIZE)&PGDIR_MASK;
dir++;
}while(address&&(address<end));
spin_unlock(&init_mm.page_table_lock);
flush_cache_vmap((unsignedlong)area->addr,end);
returnerr;
}
staticintmap_area_pmd(pmd_t*pmd,unsignedlongaddress,
unsignedlongsize,pgprot_tprot,
structpage***pages)
{
unsignedlongbase,end;
base=address&PGDIR_MASK;
address&=~PGDIR_MASK;
end=address+size;
if(end>PGDIR_SIZE)
end=PGDIR_SIZE;
do{
pte_t*pte=pte_alloc_kernel(&init_mm,pmd,base+address);
if(!pte)
return-ENOMEM;
//轮到pte了^_^
if(map_area_pte(pte,address,end-address,prot,pages))
return-ENOMEM;
address=(address+PMD_SIZE)&PMD_MASK;
pmd++;
}while(address<end);
return0;
}
//为页表页创建映照干系
staticintmap_area_pte(pte_t*pte,unsignedlongaddress,
unsignedlongsize,pgprot_tprot,
structpage***pages)
{
unsignedlongend;
address&=~PMD_MASK;
end=address+size;
if(end>PMD_SIZE)
end=PMD_SIZE;
do{
structpage*page=**pages;
WARN_ON(!pte_none(*pte));
if(!page)
return-ENOMEM;
//详细的映照在这里了^_^
set_pte(pte,mk_pte(page,prot));
address+=PAGE_SIZE;
pte++;
(*pages)++;
}while(add
上一页12345下一页
看不懂man文档的人.在linux中,命令可分为系统基本命令和应用程序命令.系统基本命令是所有的unix类系统都支持的命令,走到哪都不变,只要是unix类系统上就肯定有. |