/*
 * 返回父目录
 */
void excute_return_parent_directory(){

	if(strcmp(currentDisk,"home")==0)
	{

	}
	else if(strcmp(currentDirectory,"unknown")==0)
	{
		memset(currentDisk, 0, sizeof(char)*MAX_BUF_SIZE);
		memcpy(currentDisk, "home",sizeof(char)*4);
	}
	else
	{
		currentDirId = get_parent_id(currentDirId);
		if(strcmp(currentDirId,"0")==0)
		{
			memset(currentDirectory, 0, sizeof(char)*MAX_BUF_SIZE);
			memcpy(currentDirectory, "unknown", sizeof(char)*7);
			//当前ID?
		}
		else
		{
			currentDirectory = get_directory_name(currentDirId);
		}
	}

}
Пример #2
0
/*
 * Recursive function that moves through the directory inodes to find the
 * inumber of the desired file.
 */
int path_to_inode_number(struct unixfilesystem *fs, const char *pathname, int dir)
{
  if(pathname[0] == 0) return 1;
  else if  (is_filename(pathname)) 
  {
return name_to_inode_number(fs, pathname, dir);
  }
  else
  {
	char directoryName[MAX_NAME];
	const char* newPath = get_directory_name(pathname, directoryName);
	dir = name_to_inode_number (fs, directoryName, dir);

	return path_to_inode_number(fs, newPath, dir);
  }
}