summaryrefslogtreecommitdiff
path: root/lib/save-cwd.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-03-04 21:27:34 +0000
committerJim Meyering <jim@meyering.net>2003-03-04 21:27:34 +0000
commit7820b193f6f465185b8d3022a5118bbd8ce08515 (patch)
tree687cbdf800dfe016df696720a70f0de635f8ccf2 /lib/save-cwd.c
parent88410798e7195d2924d8505aab97c7307cc1e89a (diff)
downloadcoreutils-7820b193f6f465185b8d3022a5118bbd8ce08515.tar.xz
(restore_cwd): Remove two parameters.
Simplify. Don't call error upon failure. Let callers do that. (save_cwd): Mention that Irix 5.3 has the same problem as SunOS4 when auditing is enabled. But don't bother updating the #if.
Diffstat (limited to 'lib/save-cwd.c')
-rw-r--r--lib/save-cwd.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 4c147efd2..d7045b3e7 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -78,8 +78,8 @@ save_cwd (struct saved_cwd *cwd)
}
# if __sun__ || sun
- /* On SunOS 4, fchdir returns EINVAL if accounting is enabled,
- so we have to fall back to chdir. */
+ /* On SunOS 4 and IRIX 5.3, fchdir returns EINVAL when auditing
+ is enabled, so we have to fall back to chdir. */
if (fchdir (cwd->desc))
{
if (errno == EINVAL)
@@ -116,30 +116,16 @@ save_cwd (struct saved_cwd *cwd)
}
/* Change to recorded location, CWD, in directory hierarchy.
- If "saved working directory", NULL))
- */
+ Upon failure, return nonzero (errno is set by chdir or fchdir).
+ Upon success, return zero. */
int
-restore_cwd (const struct saved_cwd *cwd, const char *dest, const char *from)
+restore_cwd (const struct saved_cwd *cwd)
{
- int fail = 0;
- if (cwd->desc >= 0)
- {
- if (fchdir (cwd->desc))
- {
- error (0, errno, "cannot return to %s%s%s",
- (dest ? dest : "saved working directory"),
- (from ? " from " : ""),
- (from ? from : ""));
- fail = 1;
- }
- }
- else if (chdir (cwd->name) < 0)
- {
- error (0, errno, "%s", cwd->name);
- fail = 1;
- }
- return fail;
+ if (0 <= cwd->desc)
+ return fchdir (cwd->desc) < 0;
+ else
+ return chdir (cwd->name) < 0;
}
void