- stat("/", &d);
- rdev = d.st_dev;
- rino = d.st_ino;
- for (;;) {
- stat(dot, &d);
- if (d.st_ino==rino && d.st_dev==rdev)
- prname();
- if ((file = opendir(dotdot)) == NULL) {
- fprintf(stderr,"pwd: cannot open ..\n");
- exit(1);
- }
- fstat(file->dd_fd, &dd);
- chdir(dotdot);
- if(d.st_dev == dd.st_dev) {
- if(d.st_ino == dd.st_ino)
- prname();
- do
- if ((dir = readdir(file)) == NULL) {
- fprintf(stderr,"read error in ..\n");
- exit(1);
- }
- while (dir->d_ino != d.st_ino);
- } else
- do {
- if ((dir = readdir(file)) == NULL) {
- fprintf(stderr,"read error in ..\n");
- exit(1);
- }
- stat(dir->d_name, &dd);
- } while(dd.st_ino != d.st_ino || dd.st_dev != d.st_dev);
- closedir(file);
- cat();
- }
-}