- if (have_working_fchdir)
- {
-#if HAVE_FCHDIR
- cwd->desc = open (".", O_RDONLY);
- if (cwd->desc < 0)
- {
- error (0, errno, "cannot open current directory");
- return 1;
- }
-
-# if __sun__ || sun
- /* On SunOS 4, fchdir returns EINVAL if accounting is enabled,
- so we have to fall back to chdir. */
- if (fchdir (cwd->desc))
- {
- if (errno == EINVAL)
- {
- close (cwd->desc);
- cwd->desc = -1;
- have_working_fchdir = 0;
- }
- else
- {
- error (0, errno, "current directory");
- close (cwd->desc);
- cwd->desc = -1;
- return 1;
- }
- }
-# endif /* __sun__ || sun */
-#else
-# define fchdir(x) (abort (), 0)
- have_working_fchdir = 0;
-#endif
- }
-
- if (!have_working_fchdir)