-#include "logging.h"
-#include "udev_utils.h"
-#include "list.h"
-
-
-int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action)
-{
- char *pos;
-
- memset(udev, 0x00, sizeof(struct udevice));
- INIT_LIST_HEAD(&udev->symlink_list);
- INIT_LIST_HEAD(&udev->run_list);
-
- if (subsystem)
- strlcpy(udev->subsystem, subsystem, sizeof(udev->subsystem));
-
- if (action)
- strlcpy(udev->action, action, sizeof(udev->action));
-
- if (devpath) {
- strlcpy(udev->devpath, devpath, sizeof(udev->devpath));
- remove_trailing_char(udev->devpath, '/');
-
- if (strncmp(udev->devpath, "/block/", 7) == 0)
- udev->type = DEV_BLOCK;
- else if (strncmp(udev->devpath, "/class/net/", 11) == 0)
- udev->type = DEV_NET;
- else if (strncmp(udev->devpath, "/class/", 7) == 0)
- udev->type = DEV_CLASS;
- else if (strncmp(udev->devpath, "/devices/", 9) == 0)
- udev->type = DEV_DEVICE;
-
- /* get kernel name */
- pos = strrchr(udev->devpath, '/');
- if (pos) {
- strlcpy(udev->kernel_name, &pos[1], sizeof(udev->kernel_name));
- dbg("kernel_name='%s'", udev->kernel_name);
-
- /* Some block devices have '!' in their name, change that to '/' */
- pos = udev->kernel_name;
- while (pos[0] != '\0') {
- if (pos[0] == '!')
- pos[0] = '/';
- pos++;
- }
-
- /* get kernel number */
- pos = &udev->kernel_name[strlen(udev->kernel_name)];
- while (isdigit(pos[-1]))
- pos--;
- strlcpy(udev->kernel_number, pos, sizeof(udev->kernel_number));
- dbg("kernel_number='%s'", udev->kernel_number);
- }
- }
-
- if (udev->type == DEV_BLOCK || udev->type == DEV_CLASS) {
- udev->mode = 0660;
- strcpy(udev->owner, "root");
- strcpy(udev->group, "root");
- }
-
- return 0;
-}
-
-void udev_cleanup_device(struct udevice *udev)
-{
- struct name_entry *name_loop;
- struct name_entry *temp_loop;