summaryrefslogtreecommitdiff
path: root/src/pdumper.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-09-11 11:26:07 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-09-11 11:27:14 -0700
commit5fafa40d076ee24baf880e97d4290b6196cf838a (patch)
tree03452b023e9777409d979932b53f9ef347601b76 /src/pdumper.c
parenta6daae7b3df3a964b3dcde85987c02fd0af66a89 (diff)
downloademacs-5fafa40d076ee24baf880e97d4290b6196cf838a.tar.gz
Improve checking of pdump load failures
* src/alloc.c (memory_full): Just report "memory exhausted" if failure occurs during initialization, since fancier recovery schemes are not likely to work when not initialized. * src/emacs.c (dump_error_to_string): Accept int, not enum pdumper_load_result, since the result might not fit in the enum. Use strerror if it was derived from errno. This is for better diagnostics of pdump load failures. (load_pdump_find_executable): Return char *, not enum. 2nd arg is now pointer to buffer size, rather than pointer to pointer to buffer. All callers changed. Use Emacs allocator since they should now be OK even during early startup. Use check_executable instead access, to use effective rather than real permissions. (load_pdump): Return void since callers ignore result. Use int where enum could be too narrow. Use heap rather than stack for possibly-long string. Prefer ptrdiff_t to size_t. * src/fileio.c (check_executable): Now extern. * src/pdumper.c (pdumper_load): Return int that may have errno added to it, for better diagnostics when loads fail.
Diffstat (limited to 'src/pdumper.c')
-rw-r--r--src/pdumper.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pdumper.c b/src/pdumper.c
index 98090238b1a..2e382145be2 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5303,7 +5303,7 @@ enum dump_section
N.B. We run very early in initialization, so we can't use lisp,
unwinding, xmalloc, and so on. */
-enum pdumper_load_result
+int
pdumper_load (const char *dump_filename)
{
intptr_t dump_size;
@@ -5328,10 +5328,15 @@ pdumper_load (const char *dump_filename)
/* We can load only one dump. */
eassert (!dump_loaded_p ());
- enum pdumper_load_result err = PDUMPER_LOAD_FILE_NOT_FOUND;
+ int err;
int dump_fd = emacs_open (dump_filename, O_RDONLY, 0);
if (dump_fd < 0)
- goto out;
+ {
+ err = (errno == ENOENT || errno == ENOTDIR
+ ? PDUMPER_LOAD_FILE_NOT_FOUND
+ : PDUMPER_LOAD_ERROR + errno);
+ goto out;
+ }
err = PDUMPER_LOAD_FILE_NOT_FOUND;
if (fstat (dump_fd, &stat) < 0)