#include <errno.h>
#include <fcntl.h>
-#include "error.h"
-#include "exitfail.h"
+#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
#include "save-cwd.h"
#include "gettext.h"
va_end (arg);
}
- if (fd == AT_FDCWD || *file == '/')
+ if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
return open (file, flags, mode);
if (save_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("openat: unable to record current working directory"));
+ openat_save_die (errno);
if (fchdir (fd) != 0)
{
saved_errno = errno;
if (restore_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("openat: unable to restore working directory"));
+ openat_restore_die (errno);
free_cwd (&saved_cwd);
return opendir (".");
if (save_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("fdopendir: unable to record current working directory"));
+ openat_save_die (errno);
if (fchdir (fd) != 0)
{
saved_errno = errno;
if (restore_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("fdopendir: unable to restore working directory"));
+ openat_restore_die (errno);
free_cwd (&saved_cwd);
: stat (file, st));
if (save_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("fstatat: unable to record current working directory"));
+ openat_save_die (errno);
if (fchdir (fd) != 0)
{
saved_errno = errno;
if (restore_cwd (&saved_cwd) != 0)
- error (exit_failure, errno,
- _("fstatat: unable to restore working directory"));
+ openat_restore_die (errno);
free_cwd (&saved_cwd);