}
/* create new queue file */
- new_queue_file = fopen("/run/udev/queue.tmp", "w+");
+ new_queue_file = fopen("/run/udev/queue.tmp", "w+e");
if (new_queue_file == NULL)
goto error;
seqnum = udev_queue_export->seqnum_max;
if (stat(device, &statbuf) < 0)
return -ENODEV;
- fp = fopen("/proc/self/mountinfo", "r");
+ fp = fopen("/proc/self/mountinfo", "re");
if (fp == NULL)
return -ENOSYS;
while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
const char *filearg = argv[optind+1];
if (strchr(filearg, '/')) {
/* Keymap file argument is a path */
- FILE *f = fopen(filearg, "r");
+ FILE *f = fopen(filearg, "re");
if (f)
merge_table(fd, f);
else
char keymap_path[PATH_MAX];
FILE *f;
snprintf(keymap_path, sizeof(keymap_path), "%s%s", SYSCONFDIR "/udev/keymaps/", filearg);
- f = fopen(keymap_path, "r");
+ f = fopen(keymap_path, "re");
if (f) {
merge_table(fd, f);
} else {
snprintf(keymap_path, sizeof(keymap_path), "%s%s", UDEVLIBEXECDIR "/keymaps/", filearg);
- f = fopen(keymap_path, "r");
+ f = fopen(keymap_path, "re");
if (f)
merge_table(fd, f);
else
int c;
int retval = 0;
- fd = fopen(config_file, "r");
+ fd = fopen(config_file, "re");
if (fd == NULL) {
if (errno == ENOENT) {
return 1;
int klog;
FILE *f;
- klog = open("/dev/kmsg", O_WRONLY);
+ klog = open("/dev/kmsg", O_WRONLY|O_CLOEXEC);
if (klog < 0)
return;
FILE *f;
char line[UTIL_LINE_SIZE];
- f = fopen(filename, "r");
+ f = fopen(filename, "re");
if (f == NULL)
return -1;
while (fgets(line, sizeof(line), f) != NULL)
}
log_debug("read rules file: %s\n", filename);
- f = fopen(filename, "r");
+ f = fopen(filename, "re");
if (f == NULL)
return -1;
FILE *f;
bool imported = false;
- f = fopen("/proc/cmdline", "r");
+ f = fopen("/proc/cmdline", "re");
if (f != NULL) {
char cmdline[4096];
log_debug("ATTR '%s' writing '%s' %s:%u\n", attr, value,
&rules->buf[rule->rule.filename_off],
rule->rule.filename_line);
- f = fopen(attr, "w");
+ f = fopen(attr, "we");
if (f != NULL) {
if (fprintf(f, "%s", value) <= 0)
log_error("error writing ATTR{%s}: %m\n", attr);
uname(&kernel);
util_strscpyl(modules, sizeof(modules), ROOTPREFIX "/lib/modules/", kernel.release, "/modules.devname", NULL);
- f = fopen(modules, "r");
+ f = fopen(modules, "re");
if (f == NULL)
return;
char buf[4096];
long int memsize = -1;
- f = fopen("/proc/meminfo", "r");
+ f = fopen("/proc/meminfo", "re");
if (f == NULL)
return -1;
if (access(filename, F_OK) < 0)
return 0;
- f = fopen("/dev/kmsg", "w");
+ f = fopen("/dev/kmsg", "we");
if (f != NULL) {
fprintf(f, "<30>systemd-udevd[%u]: converting old udev database\n", getpid());
fclose(f);
sd_notify(1, "READY=1");
}
- f = fopen("/dev/kmsg", "w");
+ f = fopen("/dev/kmsg", "we");
if (f != NULL) {
fprintf(f, "<30>systemd-udevd[%u]: starting version " VERSION "\n", getpid());
fclose(f);