大虾们请帮忙!
希望高手大哥指点一下在阅读内核代码的系统调用部分时我忽然让一个问题给折腾主了,请赐教:
用户通过库函数sethostname(char* name,int len)设置主机名,CPU通过int 80的0x4a号调用由用户空间进入sys_sethostname(char *name,int len)中(系统空间),至此无疑问。
可是在sys_sethostname()的实现中遇到了疑问:
copy_from_user(system_utsname.nodename,name,len)中第一个参数是系统空间中的地址,而name来自于用户空间(即sethostname调用者的进程空间),属于不同的地址空间的两个地址,其内存复制是怎么完成的呢?
非常感谢!在线等待您的回答!
参考:
用户空间........................................................内核空间
sethostname(name,len).....系统调用.....>sys_sethostname(name,len)
.........................................................................|
.................copy_from_user(system_utsname.nodename,name,len)
.........................................................................|
.............................__copy_user_zeroing(S_U.nodename,name,len)
.........................................................................|
........................................................include/asm-i386/uaccess.h see http://www.csn.ul.ie/~mel/projects/vm/guide/pdf/understand.pdf Thank you very much.
It is really a good article,I find what I want. enjoy! it may be very simple than you expected. kernel can access user space without any barrier. it needs only to lock the page in memory and use the pointer passed in to access the user space, of course a validity check is a must. Thanks for all.
I have solved this question by my another subject.Thanks.
页:
[1]