sorry30 发表于 2003-9-18 17:25:13

大虾们请帮忙!

希望高手大哥指点一下
在阅读内核代码的系统调用部分时我忽然让一个问题给折腾主了,请赐教:
用户通过库函数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

Dragonfly 发表于 2003-9-18 21:53:05

see http://www.csn.ul.ie/~mel/projects/vm/guide/pdf/understand.pdf

sorry30 发表于 2003-9-19 10:31:13

Thank you very much.
It is really a good article,I find what I want.

Dragonfly 发表于 2003-9-20 10:01:56

enjoy!

zhiwood 发表于 2003-9-29 14:55:22

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.

sorry30 发表于 2003-9-30 10:09:47

Thanks for all.

I have solved this question by my another subject.Thanks.
页: [1]
查看完整版本: 大虾们请帮忙!