return NULL;
}
-static int namedev_parse(const char *filename, void *data)
+static int namedev_parse(struct udevice *udev, const char *filename)
{
char line[LINE_SIZE];
char *bufline;
return -1;
if ((stats.st_mode & S_IFMT) != S_IFDIR)
- retval = namedev_parse(udev_rules_filename, NULL);
+ retval = namedev_parse(NULL, udev_rules_filename);
else
- retval = call_foreach_file(namedev_parse, udev_rules_filename, RULEFILE_SUFFIX, NULL);
+ retval = call_foreach_file(namedev_parse, NULL, udev_rules_filename, RULEFILE_SUFFIX);
return retval;
}
void namedev_close(void)
{
struct config_device *dev;
+ struct config_device *temp_dev;
- list_for_each_entry(dev, &config_device_list, node) {
+ list_for_each_entry_safe(dev, temp_dev, &config_device_list, node) {
list_del(&dev->node);
free(dev);
}
* Userspace devfs
*
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-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
extern int udev_db_add_device(struct udevice *dev);
extern int udev_db_delete_device(struct udevice *dev);
-extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *devpath);
+extern int udev_db_get_device_by_devpath(struct udevice *udev, const char *devpath);
extern int udev_db_get_device_by_name(struct udevice *udev, const char *name);
extern int udev_db_call_foreach(int (*handler_function)(struct udevice *udev));
#include "udev_utils.h"
#include "logging.h"
-static int run_program(const char *filename, void *data)
+static int run_program(struct udevice *udev, const char *filename)
{
pid_t pid;
int fd;
- struct udevice *udev = data;
dbg("running %s", filename);
if (strcmp(devname, udev->subsystem) != 0) {
snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname);
dirname[PATH_MAX-1] = '\0';
- call_foreach_file(run_program, dirname, suffix, udev);
+ call_foreach_file(run_program, udev, dirname, suffix);
}
temp[0] = '/';
if (udev->name[0] != '\0') {
snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->name);
dirname[PATH_MAX-1] = '\0';
- call_foreach_file(run_program, dirname, suffix, udev);
+ call_foreach_file(run_program, udev, dirname, suffix);
}
if (udev->subsystem[0] != '\0') {
snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->subsystem);
dirname[PATH_MAX-1] = '\0';
- call_foreach_file(run_program, dirname, suffix, udev);
+ call_foreach_file(run_program, udev, dirname, suffix);
}
snprintf(dirname, PATH_MAX, "%s/default", basedir);
dirname[PATH_MAX-1] = '\0';
- call_foreach_file(run_program, dirname, suffix, udev);
+ call_foreach_file(run_program, udev, dirname, suffix);
}
path[--len] = '\0';
}
-struct name_entry {
- struct list_head node;
- char name[NAME_SIZE];
-};
-
-/* sort files in lexical order */
-static int name_list_add(struct list_head *name_list, const char *name, int sort)
+int name_list_add(struct list_head *name_list, const char *name, int sort)
{
struct name_entry *loop_name;
struct name_entry *new_name;
strfieldcpy(new_name->name, name);
list_add_tail(&new_name->node, &loop_name->node);
+
return 0;
}
/* calls function for every file found in specified directory */
-int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix, void *data)
+int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string),
+ struct udevice *udev, const char *dirname, const char *suffix)
{
struct dirent *ent;
DIR *dir;
snprintf(filename, NAME_SIZE, "%s/%s", dirname, loop_file->name);
filename[NAME_SIZE-1] = '\0';
- fnct(filename, data);
+ handler_function(udev, filename);
list_del(&loop_file->node);
free(loop_file);
# define asmlinkage /* nothing */
#endif
+struct name_entry {
+ struct list_head node;
+ char name[NAME_SIZE];
+};
+
extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem);
extern int kernel_release_satisfactory(unsigned int version, unsigned int patchlevel, unsigned int sublevel);
extern int create_path(const char *path);
extern void file_unmap(char *buf, size_t bufsize);
extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur);
extern void no_trailing_slash(char *path);
-typedef int (*file_fnct_t)(const char *filename, void *data);
-extern int call_foreach_file(file_fnct_t fnct, const char *dirname,
- const char *suffix, void *data);
-
+extern int name_list_add(struct list_head *name_list, const char *name, int sort);
+extern int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string),
+ struct udevice *udev, const char *dirname, const char *suffix);
#endif