prof_file.c (profile_flush_file): On the Macintosh, fopen() doesn't
authorTheodore Tso <tytso@mit.edu>
Wed, 3 Mar 1999 23:25:33 +0000 (23:25 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 3 Mar 1999 23:25:33 +0000 (23:25 +0000)
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

src/util/profile/ChangeLog
src/util/profile/prof_err.et
src/util/profile/prof_file.c

index b54fe058eabfe7ffcb1519ff08f5e783d38089c4..835a00b592de9e7eaa7f2853932f2b2817858dce 100644 (file)
@@ -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
index 410bdc6a54febe019852634e4820abc35db9506e..e6e35db0acc4f37a737c8cc74d13b4da46c5f67f 100644 (file)
@@ -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
index 3bdb5d6f305ccdc9501c4aa27ea8e285f14ada02..fe9137afd6977aa7c1254befcf35ae669bc4f7a2 100644 (file)
@@ -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;
        }