diff options
author | Jim Meyering <jim@meyering.net> | 2003-03-04 21:27:34 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-03-04 21:27:34 +0000 |
commit | 7820b193f6f465185b8d3022a5118bbd8ce08515 (patch) | |
tree | 687cbdf800dfe016df696720a70f0de635f8ccf2 | |
parent | 88410798e7195d2924d8505aab97c7307cc1e89a (diff) | |
download | coreutils-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.
-rw-r--r-- | lib/save-cwd.c | 32 |
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 |