-/* Copyright (C) 1985-1988, 1990, 1992, 1999-2013 Free Software
+/* Copyright (C) 1985-1988, 1990, 1992, 1999-2015 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
Instead we read the whole file, modify it, and write it out. */
#include <config.h>
-#include <unexec.h>
-
-extern _Noreturn void fatal (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
+#include "unexec.h"
+#include "lisp.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <memory.h>
-#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
#endif
struct stat stat_buf;
off_t old_file_size;
- int mask;
/* Open the old file, allocate a buffer of the right size, and read
in the file contents. */
- old_file = open (old_name, O_RDONLY);
+ old_file = emacs_open (old_name, O_RDONLY, 0);
if (old_file < 0)
fatal ("Can't open %s for reading: %s", old_name, strerror (errno));
fatal ("Can't fstat (%s): %s", old_name, strerror (errno));
#if MAP_ANON == 0
- mmap_fd = open ("/dev/zero", O_RDONLY);
+ mmap_fd = emacs_open ("/dev/zero", O_RDONLY, 0);
if (mmap_fd < 0)
fatal ("Can't open /dev/zero for reading: %s", strerror (errno));
#endif
the image of the new file. Set pointers to various interesting
objects. */
- new_file = open (new_name, O_RDWR | O_CREAT, 0666);
+ new_file = emacs_open (new_name, O_RDWR | O_CREAT, 0777);
if (new_file < 0)
fatal ("Can't creat (%s): %s", new_name, strerror (errno));
/* Close the files and make the new file executable. */
#if MAP_ANON == 0
- close (mmap_fd);
+ emacs_close (mmap_fd);
#endif
- if (close (old_file) != 0)
+ if (emacs_close (old_file) != 0)
fatal ("Can't close (%s): %s", old_name, strerror (errno));
- if (close (new_file) != 0)
+ if (emacs_close (new_file) != 0)
fatal ("Can't close (%s): %s", new_name, strerror (errno));
-
- if (stat (new_name, &stat_buf) != 0)
- fatal ("Can't stat (%s): %s", new_name, strerror (errno));
-
- mask = umask (777);
- umask (mask);
- stat_buf.st_mode |= 0111 & ~mask;
- if (chmod (new_name, stat_buf.st_mode) != 0)
- fatal ("Can't chmod (%s): %s", new_name, strerror (errno));
}