summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--udev.c2
-rw-r--r--udev_rules.h3
-rw-r--r--udev_rules_parse.c36
-rw-r--r--udevd.c4
-rw-r--r--udevrulescompile.c97
-rw-r--r--udevstart.c2
-rw-r--r--udevtest.c2
8 files changed, 8 insertions, 139 deletions
diff --git a/Makefile b/Makefile
index 8446eee924..4f6d3da983 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,6 @@ PROGRAMS = \
udev \
udevd \
udevsend \
- udevrulescompile \
udevinitsend \
udeveventrecorder \
udevcontrol \
diff --git a/udev.c b/udev.c
index 926c4b526a..aab9f015fb 100644
--- a/udev.c
+++ b/udev.c
@@ -132,7 +132,7 @@ int main(int argc, char *argv[], char *envp[])
}
udev_init_device(&udev, devpath, subsystem, action);
- udev_rules_init(&rules, 1, 0);
+ udev_rules_init(&rules, 0);
retval = udev_process_event(&rules, &udev);
diff --git a/udev_rules.h b/udev_rules.h
index be13378e4e..6d9d306ded 100644
--- a/udev_rules.h
+++ b/udev_rules.h
@@ -100,11 +100,10 @@ struct udev_rules {
char *buf;
size_t bufsize;
size_t current;
- int mapped;
int resolve_names;
};
-extern int udev_rules_init(struct udev_rules *rules, int read_compiled, int resolve_names);
+extern int udev_rules_init(struct udev_rules *rules, int resolve_names);
extern void udev_rules_close(struct udev_rules *rules);
extern void udev_apply_format(struct udevice *udev, char *string, size_t maxsize,
diff --git a/udev_rules_parse.c b/udev_rules_parse.c
index 7d1853acbe..6e978d74b4 100644
--- a/udev_rules_parse.c
+++ b/udev_rules_parse.c
@@ -591,42 +591,14 @@ static int parse_file(struct udev_rules *rules, const char *filename)
return retval;
}
-static int rules_map(struct udev_rules *rules, const char *filename)
+int udev_rules_init(struct udev_rules *rules, int resolve_names)
{
- if (file_map(filename, &rules->buf, &rules->bufsize)) {
- rules->buf = NULL;
- return -1;
- }
- if (rules->bufsize == 0) {
- file_unmap(rules->buf, rules->bufsize);
- rules->buf = NULL;
- return -1;
- }
- rules->mapped = 1;
-
- return 0;
-}
-
-int udev_rules_init(struct udev_rules *rules, int read_compiled, int resolve_names)
-{
- char comp[PATH_SIZE];
struct stat stats;
int retval;
memset(rules, 0x00, sizeof(struct udev_rules));
rules->resolve_names = resolve_names;
- /* check for precompiled rules */
- if (read_compiled) {
- strlcpy(comp, udev_rules_filename, sizeof(comp));
- strlcat(comp, ".compiled", sizeof(comp));
- if (stat(comp, &stats) == 0) {
- dbg("map compiled rules '%s'", comp);
- if (rules_map(rules, comp) == 0)
- return 0;
- }
- }
-
/* parse rules file or all matching files in directory */
if (stat(udev_rules_filename, &stats) != 0)
return -1;
@@ -660,11 +632,7 @@ int udev_rules_init(struct udev_rules *rules, int read_compiled, int resolve_nam
void udev_rules_close(struct udev_rules *rules)
{
if (rules->buf) {
- if (rules->mapped) {
- rules->mapped = 0;
- file_unmap(rules->buf, rules->bufsize);
- } else
- free(rules->buf);
+ free(rules->buf);
rules->buf = NULL;
}
}
diff --git a/udevd.c b/udevd.c
index e2514e5947..154c370589 100644
--- a/udevd.c
+++ b/udevd.c
@@ -880,7 +880,7 @@ int main(int argc, char *argv[], char *envp[])
}
/* parse the rules and keep it in memory */
- udev_rules_init(&rules, 0, 1);
+ udev_rules_init(&rules, 1);
if (daemonize) {
pid_t pid;
@@ -1065,7 +1065,7 @@ int main(int argc, char *argv[], char *envp[])
if (reload_config) {
reload_config = 0;
udev_rules_close(&rules);
- udev_rules_init(&rules, 0, 1);
+ udev_rules_init(&rules, 1);
}
/* forked child have returned */
diff --git a/udevrulescompile.c b/udevrulescompile.c
deleted file mode 100644
index a2c5f2e9fc..0000000000
--- a/udevrulescompile.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * udevrulescompile.c - store already parsed config on disk
- *
- * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "udev_libc_wrapper.h"
-#include "udev_sysfs.h"
-#include "udev.h"
-#include "udev_version.h"
-#include "logging.h"
-#include "udev_rules.h"
-#include "udev_utils.h"
-#include "list.h"
-
-#ifdef USE_LOG
-void log_message(int priority, const char *format, ...)
-{
- va_list args;
-
- if (priority > udev_log_priority)
- return;
-
- va_start(args, format);
- vsyslog(priority, format, args);
- va_end(args);
-}
-#endif
-
-int main(int argc, char *argv[], char *envp[])
-{
- struct udev_rules rules;
- FILE *f;
- char comp[PATH_SIZE];
- char comp_tmp[PATH_SIZE];
- int retval = 0;
-
- logging_init("udevrulescompile");
- udev_init_config();
- dbg("version %s", UDEV_VERSION);
-
- strlcpy(comp, udev_rules_filename, sizeof(comp));
- strlcat(comp, ".compiled", sizeof(comp));
- strlcpy(comp_tmp, comp, sizeof(comp_tmp));
- strlcat(comp_tmp, ".tmp", sizeof(comp_tmp));
-
- /* remove old version, otherwise we would read it instead of the real rules */
- unlink(comp);
- unlink(comp_tmp);
-
- udev_rules_init(&rules, 0, 1);
-
- f = fopen(comp_tmp, "w");
- if (f == NULL) {
- err("unable to create db file '%s'", comp_tmp);
- unlink(comp_tmp);
- retval = 1;
- goto exit;
- }
-
- dbg("storing compiled rules in '%s' size=%zi", comp_tmp, rules.bufsize);
- fwrite(rules.buf, rules.bufsize, 1, f);
- fclose(f);
-
- dbg("activating compiled rules in '%s'", comp);
- if (rename(comp_tmp, comp) != 0) {
- err("unable to write file");
- unlink(comp);
- unlink(comp_tmp);
- retval = 2;
- }
-
-exit:
- logging_close();
- return retval;
-}
diff --git a/udevstart.c b/udevstart.c
index 057d59fcaa..8ee079dbe5 100644
--- a/udevstart.c
+++ b/udevstart.c
@@ -364,7 +364,7 @@ int main(int argc, char *argv[], char *envp[])
/* trigger timeout to prevent hanging processes */
alarm(UDEV_ALARM_TIMEOUT);
- udev_rules_init(&rules, 0, 1);
+ udev_rules_init(&rules, 1);
udev_scan_class(&device_list);
udev_scan_block(&device_list);
diff --git a/udevtest.c b/udevtest.c
index 6e973e31e6..4890b6837c 100644
--- a/udevtest.c
+++ b/udevtest.c
@@ -92,7 +92,7 @@ int main(int argc, char *argv[], char *envp[])
info("looking at device '%s' from subsystem '%s'", devpath, subsystem);
/* initialize the naming deamon */
- udev_rules_init(&rules, 0, 0);
+ udev_rules_init(&rules, 0);
/* fill in values and test_run flag*/
udev_init_device(&udev, devpath, subsystem, "add");