aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoland McGrath1994-06-16 06:55:46 +0000
committerRoland McGrath1994-06-16 06:55:46 +0000
commit2d30a233cf3c6040e193079abd9a33913f067a9c (patch)
tree555bbdf32cb33aff14ccfd6ea3c341941f701601 /src
parent4a73e687bafe15410b40709914ab62b887074c91 (diff)
downloademacs-2d30a233cf3c6040e193079abd9a33913f067a9c.tar.gz
emacs-2d30a233cf3c6040e193079abd9a33913f067a9c.zip
Include <sys/file.h> and [USG5] <fcntl.h> to define O_* macros.
(O_RDONLY, O_RDWR): Define if undefined. [emacs] (report_error): Use report_file_error so the user can tell what the errno code was. (unexec): Use O_RDONLY instead of explicit 0. (make_hdr): Don't undo A_TEXT_OFFSET adjustment #ifndef NO_REMAP, since it was never adjusted earlier #ifndef NO_REMAP. (adjust_lnnoptrs): Use O_RDWR instead of explicit 2.
Diffstat (limited to 'src')
-rw-r--r--src/unexec.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/unexec.c b/src/unexec.c
index 3bc147fec47..d91644519f1 100644
--- a/src/unexec.c
+++ b/src/unexec.c
@@ -137,7 +137,7 @@ thus, the amount of offset can depend on the data in the file.
137* A_TEXT_SEEK(HDR) 137* A_TEXT_SEEK(HDR)
138 138
139If defined, this macro specifies the number of bytes to seek into the 139If defined, this macro specifies the number of bytes to seek into the
140a.out file before starting to write the text segment.a 140a.out file before starting to write the text segment.
141 141
142* EXEC_MAGIC 142* EXEC_MAGIC
143 143
@@ -214,6 +214,20 @@ struct aouthdr
214#include <sys/stat.h> 214#include <sys/stat.h>
215#include <errno.h> 215#include <errno.h>
216 216
217#include <sys/file.h> /* Must be after sys/types.h for USG and BSD4_1*/
218
219#ifdef USG5
220#include <fcntl.h>
221#endif
222
223#ifndef O_RDONLY
224#define O_RDONLY 0
225#endif
226#ifndef O_RDWR
227#define O_RDWR 2
228#endif
229
230
217extern char *start_of_text (); /* Start of text */ 231extern char *start_of_text (); /* Start of text */
218extern char *start_of_data (); /* Start of initialized data */ 232extern char *start_of_data (); /* Start of initialized data */
219 233
@@ -311,6 +325,8 @@ static int pagemask;
311 325
312#ifdef emacs 326#ifdef emacs
313 327
328#include "lisp.h"
329
314static 330static
315report_error (file, fd) 331report_error (file, fd)
316 char *file; 332 char *file;
@@ -318,7 +334,7 @@ report_error (file, fd)
318{ 334{
319 if (fd) 335 if (fd)
320 close (fd); 336 close (fd);
321 error ("Failure operating on %s\n", file); 337 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
322} 338}
323#endif /* emacs */ 339#endif /* emacs */
324 340
@@ -357,7 +373,7 @@ unexec (new_name, a_name, data_start, bss_start, entry_address)
357{ 373{
358 int new, a_out = -1; 374 int new, a_out = -1;
359 375
360 if (a_name && (a_out = open (a_name, 0)) < 0) 376 if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
361 { 377 {
362 PERROR (a_name); 378 PERROR (a_name);
363 } 379 }
@@ -774,9 +790,13 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
774 PERROR (new_name); 790 PERROR (new_name);
775 } 791 }
776 792
793 /* This adjustment was done above only #ifndef NO_REMAP,
794 so only undo it now #ifndef NO_REMAP. */
795#ifndef NO_REMAP
777#ifdef A_TEXT_OFFSET 796#ifdef A_TEXT_OFFSET
778 hdr.a_text -= A_TEXT_OFFSET (ohdr); 797 hdr.a_text -= A_TEXT_OFFSET (ohdr);
779#endif 798#endif
799#endif
780 800
781 return 0; 801 return 0;
782 802
@@ -1055,7 +1075,7 @@ adjust_lnnoptrs (writedesc, readdesc, new_name)
1055#ifdef MSDOS 1075#ifdef MSDOS
1056 if ((new = writedesc) < 0) 1076 if ((new = writedesc) < 0)
1057#else 1077#else
1058 if ((new = open (new_name, 2)) < 0) 1078 if ((new = open (new_name, O_RDWR)) < 0)
1059#endif 1079#endif
1060 { 1080 {
1061 PERROR (new_name); 1081 PERROR (new_name);