mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-15 02:56:51 +07:00
[PATCH] remove typedef for call_foreach_file() handler function
This commit is contained in:
parent
03cfa1394f
commit
f0308095c7
@ -98,7 +98,7 @@ static char *get_key_attribute(char *str)
|
||||
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;
|
||||
@ -354,9 +354,9 @@ int namedev_init(void)
|
||||
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;
|
||||
}
|
||||
@ -364,8 +364,9 @@ int namedev_init(void)
|
||||
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);
|
||||
}
|
||||
|
1
udev.h
1
udev.h
@ -4,6 +4,7 @@
|
||||
* 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
|
||||
|
@ -28,7 +28,7 @@
|
||||
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));
|
||||
|
||||
|
@ -31,11 +31,10 @@
|
||||
#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);
|
||||
|
||||
@ -89,7 +88,7 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c
|
||||
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] = '/';
|
||||
@ -101,16 +100,16 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c
|
||||
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);
|
||||
}
|
||||
|
14
udev_utils.c
14
udev_utils.c
@ -259,13 +259,7 @@ void no_trailing_slash(char *path)
|
||||
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;
|
||||
@ -288,11 +282,13 @@ static int name_list_add(struct list_head *name_list, const char *name, int sort
|
||||
|
||||
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;
|
||||
@ -335,7 +331,7 @@ int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix,
|
||||
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);
|
||||
|
12
udev_utils.h
12
udev_utils.h
@ -76,6 +76,11 @@ do { \
|
||||
# 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);
|
||||
@ -85,8 +90,7 @@ extern int file_map(const char *filename, char **buf, size_t *bufsize);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user