printpathto()
{
while(count == 0){
	
	ino_t this_inode = get_inode( "." );
	char its_name[BUFSIZ];

	chdir( ".." );					

	inum_to_name( this_inode , its_name );		

	par_inode = get_inode( "." );			

	if ( par_inode == get_inode( ".." ) ){		
	count=1;
	}

	
	strcpy(temp[count2], its_name);

	count2++;
	count3++;
}//end while
count2=count2-1;
count3=count3-1;
int i;
for(i=0; i<=count2; i++){
printf("/%s", temp[count3] );
count3--;
}


}
void printpathto(ino_t this_inode){
        ino_t   my_inode;
        char    its_name[BUFSIZ];
        char    full_path[BUFSIZ];
        char    temp[BUFSIZ];

        while(1){
                my_inode = get_inode(".");

                if (get_inode("..") != this_inode){

                        chdir("..");

                        inum_to_name(this_inode, its_name, BUFSIZ);
                        my_inode = get_inode(".");

                        this_inode = my_inode;

                        strcpy(temp,full_path);
                        sprintf(full_path, "/%s%s",its_name,temp);
                }
                else{
                        break;
                }
        }
        printf("%s", full_path);

}
int main(){
	ino_t this_inode;
	ino_t my_inode;
    char its_name[BUFSIZ];
	struct names *Head;
	struct names *temp;

	Head = (names*)malloc(sizeof(names));
//	Head->its_name = NULL;
	Head->next = NULL;

    this_inode = get_inode(".");

	while(get_inode("..") != this_inode){
		chdir("..");
		inum_to_name(this_inode, its_name, BUFSIZ);

		temp = (names*)malloc(sizeof(names));
		strncpy(temp->its_name,its_name,BUFSIZ);
		temp->next = Head;
		Head = temp;

		my_inode = get_inode(".");
		this_inode = my_inode;
	}

	temp = Head;
	while(temp->next){
		printf("/%s", temp->its_name);
		temp = temp->next;
	}

	putchar('\n');
	return 0;
}
예제 #4
0
파일: pwd.c 프로젝트: Lihaoyang1992/CS631
void printpathto(ino_t this_inode)
{
	ino_t	my_inode;
	char	its_name[BUFSIZ];
	if (get_inode("..") != this_inode) {
		chdir("..");	/* enter parent dir */
		inum_to_name(this_inode, its_name);
		my_inode = get_inode(".");
		printpathto(my_inode);
		printf("/%s", its_name);
	}
}
예제 #5
0
파일: spwd.c 프로젝트: maxjazz/moley
void printpathto (ino_t this_inode)
{
  ino_t my_inode;
  char its_name[BUFSIZE];
  if (get_inode("..") != this_inode)
  {
    chdir("..");
    inum_to_name(this_inode, its_name, BUFSIZE);
    my_inode = get_inode(".");
    printpathto(my_inode);
    printf("%s", its_name);
  }

}
예제 #6
0
파일: pwd01.c 프로젝트: victorisildur/UNIX
/* recursively print dir name of this_inode
 * get parent_inode of this_inode
 * print name of this_inode
 * recursively call method of parent_inode
*/
void printpathto(ino_t this_inode)
{
    ino_t my_inode;
    char its_name[BUFSIZ];
    if (get_inode("..") != this_inode)
    {
        chdir("..");
        /* dir name of this_inode depends on parent dir file*/
        inum_to_name(this_inode, its_name, BUFSIZ);
        my_inode = get_inode(".");
        printpathto(my_inode);
        printf("/%s", its_name);
    }
}
예제 #7
0
void FilePath::printPathTo(ino_t this_inode)
{
		ino_t my_inode;
		char its_name[BUFSIZ];
		if( get_inode("..") != this_inode)
		{
				chdir("..");
				inum_to_name(this_inode, its_name, BUFSIZ);
				my_inode = get_inode(".");
				printPathTo(my_inode);
				printf("/%s", its_name);
		}
		strcpy(path, its_name);
}
예제 #8
0
파일: spwd.c 프로젝트: benbee/Learning
printpathto( ino_t this_inode )
/*
 *	prints path leading down to an object with this inode
 *	kindof recursive
 */
{
	int	my_inode ;
	char	its_name[BUFSIZ];

	chdir( ".." );					/* up one dir	*/

	inum_to_name( this_inode , its_name );		/* get its name	*/

	my_inode = get_inode( "." );			/* print head	*/
	if ( my_inode != get_inode( ".." ) )		/* of pathname	*/
		printpathto( my_inode );		/* recursively	*/
	printf("/%s", its_name );			/* now print	*/
							/* name of this	*/
}
예제 #9
0
파일: pwd.c 프로젝트: bandari/linux_utils
static void	print_physical_path(ino_t this_inode)
{
	char 	*s;
	char	its_name[BUFSIZ];

	while (get_inode("..") != this_inode)
	{
		chdir( ".." );

		inum_to_name(this_inode, its_name, BUFSIZ);

		this_inode = get_inode(".");
	}
	
	its_name[BUFSIZ - 1] = '\0';

	while ((s = strrchr(its_name, '/')) != '\0') {
		printf("%s", s);
		its_name[s - its_name] = '\0';
	}
}