summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1999-03-03 23:25:33 +0000
committerTheodore Tso <tytso@mit.edu>1999-03-03 23:25:33 +0000
commitb1fd0ffe7fb3566e062f9730216a29cdf3cca6db (patch)
tree23addadd3cfcc8babcb58d802be87fb8ab344725
parent04df12f7fcb6663231290cbba39f7d4d2db99d0c (diff)
downloadkrb5-b1fd0ffe7fb3566e062f9730216a29cdf3cca6db.tar.gz
krb5-b1fd0ffe7fb3566e062f9730216a29cdf3cca6db.tar.xz
krb5-b1fd0ffe7fb3566e062f9730216a29cdf3cca6db.zip
prof_file.c (profile_flush_file): On the Macintosh, fopen() doesn't
set errno when fopen fails to open a file. Work around this by setting errno to PROF_FAIL_OPEN in this case. prof_err.et: Add new error code PROF_FAIL_OPEN. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11238 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/util/profile/ChangeLog8
-rw-r--r--src/util/profile/prof_err.et1
-rw-r--r--src/util/profile/prof_file.c12
3 files changed, 19 insertions, 2 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog
index b54fe058ea..835a00b592 100644
--- a/src/util/profile/ChangeLog
+++ b/src/util/profile/ChangeLog
@@ -1,3 +1,11 @@
+Wed Mar 3 18:23:47 1999 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * prof_file.c (profile_flush_file): On the Macintosh, fopen()
+ doesn't set errno when fopen fails to open a file. Work
+ around this by setting errno to PROF_FAIL_OPEN in this case.
+
+ * prof_err.et: Add new error code PROF_FAIL_OPEN.
+
Tue Mar 2 18:55:50 1999 Theodore Y. Ts'o <tytso@mit.edu>
* test_profile.c: Added ability to test profile set functions, and
diff --git a/src/util/profile/prof_err.et b/src/util/profile/prof_err.et
index 410bdc6a54..e6e35db0ac 100644
--- a/src/util/profile/prof_err.et
+++ b/src/util/profile/prof_err.et
@@ -47,6 +47,7 @@ error_code PROF_NO_PROFILE, "No profile file open"
# generated by prof_file.c
#
error_code PROF_MAGIC_FILE, "Bad magic value in profile_file_t"
+error_code PROF_FAIL_OPEN, "Couldn't open profile file"
#
# generated by prof_set.c
diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c
index 3bdb5d6f30..fe9137afd6 100644
--- a/src/util/profile/prof_file.c
+++ b/src/util/profile/prof_file.c
@@ -125,9 +125,14 @@ errcode_t profile_update_file(prf)
if (prf->root)
return 0;
#endif
+ errno = 0;
f = fopen(prf->filename, "r");
- if (f == NULL)
- return errno;
+ if (f == NULL) {
+ retval = errno;
+ if (retval == 0)
+ retval = PROF_FAIL_OPEN;
+ return retval;
+ }
prf->upd_serial++;
prf->flags = 0;
if (rw_access(prf->filename))
@@ -166,9 +171,12 @@ errcode_t profile_flush_file(prf)
sprintf(new_name, "%s.$$$", prf->filename);
sprintf(old_name, "%s.bak", prf->filename);
+ errno = 0;
f = fopen(new_name, "w");
if (!f) {
retval = errno;
+ if (retval == 0)
+ retval = PROF_FAIL_OPEN;
goto errout;
}