You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
## getcwd
|
|
|
|
|
|
|
|
|
|
##### 1)思路分析
|
|
|
|
|
|
|
|
|
|
###### 获取当前目录的节点号
|
|
|
|
|
|
|
|
|
|
current_ino = get_ino_byname(".")
|
|
|
|
|
|
|
|
|
|
###### 获取当前节点的父目录的节点号
|
|
|
|
|
|
|
|
|
|
parent_ino = get_ino_byname("..") namei函数
|
|
|
|
|
|
|
|
|
|
###### 判断是否在根目录; **循环**直至根目录
|
|
|
|
|
|
|
|
|
|
if(current_ino == parent_ino)break;
|
|
|
|
|
|
|
|
|
|
###### 切换到父目录,根据current_ino,搜索到对应的文件名并记录
|
|
|
|
|
|
|
|
|
|
chdir("..")
|
|
|
|
|
|
|
|
|
|
buf[depth] = find_name_byino(current_ino) //buf这可能会出问题
|
|
|
|
|
|
|
|
|
|
depth += len(find_name_byino(current_ino))
|
|
|
|
|
|
|
|
|
|
等break出来
|
|
|
|
|
|
|
|
|
|
###### 根据buf输出路径
|
|
|
|
|
|
|
|
|
|
##### 2)现有问题
|
|
|
|
|
|
|
|
|
|
没有实现如何搜索到对应文件名记录
|
|
|
|
|
|
|
|
|
|
路径名传入没实现
|
|
|
|
|
|
|
|
|
|
## sleep
|
|
|
|
|
|
|
|
|
|
###### 1)思路
|
|
|
|
|
|
|
|
|
|
在系统调用里分别调用
|
|
|
|
|
|
|
|
|
|
mysignal(SIGALRM,SIG_IGN);
|
|
|
|
|
|
|
|
|
|
alram(1)
|
|
|
|
|
|
|
|
|
|
pasue()
|
|
|
|
|
|
|
|
|
|
的系统调用函数,通过改变alarm中的参数,实现想睡多久就睡多久。
|
|
|
|
|
|
|
|
|
|
2)问题
|
|
|
|
|
|
|
|
|
|
系统调用函数实现后,发现测试报错
|
|
|
|
|
|
|
|
|
|
显示错误:
|
|
|
|
|
|
|
|
|
|
-----testing sleep:
|
|
|
|
|
|
|
|
|
|
malloc called with impossibly large argument(334988)
|
|
|
|
|
|
|
|
|
|
Kernel panic: malloc: bad arg
|
|
|
|
|
|
|
|
|
|
最后解决方法是将原来直接跳过的系统调用号给补上,
|
|
|
|
|
|
|
|
|
|
加了个89的系统调用函数pipe2()
|
|
|
|
|
|