Exemplo n.º 1
0
void printPath(char* filePath){

    ino_t nodeId = getNodeIdFrom(filePath);
    char buf[BUF_LEN];
    if(nodeId!=getNodeIdFrom("..")){
    
        if(chdir("..")==-1){
            perror("chdir fail");
            exit(1);
        } 

        inode_to_name(nodeId,buf,BUF_LEN);
        printPath(".");
        printf("/%s",buf);
         
    }
}
Exemplo n.º 2
0
void
print_path_to(ino_t this_inode)
{
	ino_t my_inode;
	char name[256];


	if (get_inode("..") != this_inode) {
		chdir("..");			/* go to parent directory */
		strncpy(name, inode_to_name(this_inode), sizeof(name) - 1);
		//printf("indoe = %d, name = %s\n", this_inode, name);

		my_inode = get_inode(".");
		print_path_to(my_inode);	/* recursively */
		printf("/%s", name);
	} else {
		//strncpy(name, inode_to_name(this_inode), sizeof(name) - 1);
		//printf("indoe = %d, name = %s\n", this_inode, name);
		return;
	}
}