20,175,325 achieve mypwd (elected to do, points)
First, the subject content:
Learning pwd command 1
2 Study pwd achieve desired system call (man -k; grep), write pseudocode
3 mypwd achieved
. 4 Test mypwd
Second, the steps of:
Function: View the "current working directory" full path
using the man command pwd
pwd implementation
Study pwd achieve desired system call (man -k; grep), write pseudocode
man -k current directory
man getcwd
Implementation and testing mypwd
Third, the test code:
int get_name(int inode,char path[][BUFFERSIZE],int h)
{
DIR *dir;
struct dirent *dir2;
if((dir = opendir(".")) == NULL){
perror(".");
exit(-1);
}
while((dir2 = readdir(dir)) != NULL)
{
if(dir2->d_ino == inode)
{
strcpy(path[h],dir2->d_name);
break;
}
}
h = h+1;
return h;
}
Fourth, the code links:
https://gitee.com/sgm5/text1/commit/f74b901ecc9a50691e465ab1b97a9cf24714bd40