From: Theodore Tso Date: Wed, 3 Mar 1999 23:25:33 +0000 (+0000) Subject: prof_file.c (profile_flush_file): On the Macintosh, fopen() doesn't X-Git-Tag: krb5-1.1-beta1~313 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b1fd0ffe7fb3566e062f9730216a29cdf3cca6db;p=krb5.git 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 --- diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index b54fe058e..835a00b59 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 + + * 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 * 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 410bdc6a5..e6e35db0a 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 3bdb5d6f3..fe9137afd 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; }