From: Paul Eggert Date: Sun, 18 Sep 2011 08:34:09 +0000 (-0700) Subject: * fileio.c: Report proper errno when syscall falls. X-Git-Tag: emacs-pretest-24.0.90~104^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e5e9d610c9b435b9053bec512957c872b8fc031c;p=emacs.git * fileio.c: Report proper errno when syscall falls. (Finsert_file_contents): Save and restore errno, so that report_file_error outputs the correct diagnostic. (Fwrite_region) [CLASH_DETECTION]: Likewise. --- diff --git a/src/ChangeLog b/src/ChangeLog index 835e70f99af..282275ffa06 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2011-09-18 Paul Eggert + + * fileio.c: Report proper errno when syscall falls. + (Finsert_file_contents): Save and restore errno, + so that report_file_error outputs the correct diagnostic. + (Fwrite_region) [CLASH_DETECTION]: Likewise. + 2011-09-18 Eli Zaretskii * .gdbinit (pgx): Fix references to fields of `struct glyph'. diff --git a/src/fileio.c b/src/fileio.c index 08be41f9fe4..e335dcf027f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3187,6 +3187,7 @@ variable `last-coding-system-used' to the coding system actually used. */) Lisp_Object p; EMACS_INT total = 0; int not_regular = 0; + int save_errno = 0; char read_buf[READ_BUF_SIZE]; struct coding_system coding; char buffer[1 << 14]; @@ -3250,6 +3251,7 @@ variable `last-coding-system-used' to the coding system actually used. */) #endif /* WINDOWSNT */ { badopen: + save_errno = errno; if (NILP (visit)) report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); st.st_mtime = -1; @@ -4281,6 +4283,7 @@ variable `last-coding-system-used' to the coding system actually used. */) && current_buffer->modtime == -1) { /* If visiting nonexistent file, return nil. */ + errno = save_errno; report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); } @@ -4618,7 +4621,9 @@ This calls `write-region-annotate-functions' at the start, and if (ret < 0) { #ifdef CLASH_DETECTION + save_errno = errno; if (!auto_saving) unlock_file (lockname); + errno = save_errno; #endif /* CLASH_DETECTION */ UNGCPRO; report_file_error ("Lseek error", Fcons (filename, Qnil));