#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include <fcntl.h>
#include <errno.h>
#ifndef PROGRAM_NAME
#define min(a, b) MIN(a, b) /* glue for linux kernel source */
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
/* Verbose messages */
#define bareverbose(verbose, fmt, ...) do { \
if (verbose) \
{
int fd, rd, tmp, tmp1;
- fd = open(file, O_RDONLY);
+ fd = open(file, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return -1;
int fd, rd;
char buf[50];
- fd = open(file, O_RDONLY);
+ fd = open(file, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return -1;
int fd, rd;
char buf[50];
- fd = open(file, O_RDONLY);
+ fd = open(file, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return -1;
return 0;
sprintf(file, lib->mtd_name, num);
- fd = open(file, O_RDONLY);
+ fd = open(file, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return 0;
return -1;
}
- in_fd = open(img_name, O_RDONLY);
+ in_fd = open(img_name, O_RDONLY | O_CLOEXEC);
if (in_fd == -1)
return sys_errmsg("cannot open \"%s\"", img_name);