libudev-enumerate.c revision 065db052211d3bf08d9b0f698a79a8798faf11d2
/*
* libudev - interface to udev device information
*
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <dirent.h>
#include <fnmatch.h>
#include "libudev.h"
#include "libudev-private.h"
struct udev_enumerate {
int refcount;
struct udev_list_node sysattr_match_list;
struct udev_list_node sysattr_nomatch_list;
struct udev_list_node subsystem_match_list;
struct udev_list_node subsystem_nomatch_list;
struct udev_list_node properties_match_list;
struct udev_list_node devices_list;
int devices_sorted;
};
/**
* udev_enumerate_new:
* @udev: udev library context
*
* Returns: an enumeration context
**/
{
struct udev_enumerate *udev_enumerate;
if (udev_enumerate == NULL)
return NULL;
return udev_enumerate;
}
{
if (udev_enumerate == NULL)
return NULL;
return udev_enumerate;
}
{
if (udev_enumerate == NULL)
return;
if (udev_enumerate->refcount > 0)
return;
}
{
if (udev_enumerate == NULL)
return NULL;
return udev_enumerate->udev;
}
{
if (udev_enumerate == NULL)
return NULL;
if (!udev_enumerate->devices_sorted)
}
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
{
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
return -ENOMEM;
return 0;
}
int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
{
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
return -ENOMEM;
return 0;
}
int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
{
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
return -ENOMEM;
return 0;
}
int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
{
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
return -ENOMEM;
return 0;
}
static int match_sysattr_value(struct udev *udev, const char *syspath, const char *sysattr, const char *match_val)
{
struct udev_device *device;
int match = 0;
return -EINVAL;
goto exit;
match = 1;
goto exit;
}
match = 1;
goto exit;
}
exit:
return match;
}
int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value)
{
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
return -ENOMEM;
return 0;
}
{
struct udev_list_entry *list_entry;
/* skip list */
return 0;
}
/* include list */
/* anything that does not match, will make it FALSE */
return 0;
}
return 1;
}
return 1;
}
{
struct udev_device *dev;
struct udev_list_entry *list_entry;
int match = 0;
/* no match always matches */
return 1;
/* no device does not match */
return 0;
/* loop over matches */
struct udev_list_entry *property_entry;
/* loop over device properties */
if (fnmatch(udev_list_entry_get_name(list_entry), udev_list_entry_get_name(property_entry), 0) == 0) {
const char *match_value;
const char *dev_value;
match = 1;
goto out;
}
continue;
match = 1;
goto out;
}
}
}
}
out:
return match;
}
{
char path[UTIL_PATH_SIZE];
size_t l;
char *s;
s = path;
return -1;
char syspath[UTIL_PATH_SIZE];
char filename[UTIL_PATH_SIZE];
continue;
continue;
continue;
continue;
continue;
continue;
}
return 0;
}
{
struct udev_list_entry *list_entry;
return 0;
}
return 1;
}
return 0;
}
return 1;
}
static int scan_dir(struct udev_enumerate *udev_enumerate, const char *basedir, const char *subdir, const char *subsystem)
{
char path[UTIL_PATH_SIZE];
return -1;
continue;
continue;
}
return 0;
}
{
static const char *delay_device_list[] = {
};
int i;
for (i = 0; delay_device_list[i] != NULL; i++) {
return 1;
}
}
return 0;
}
/* sort delayed devices to the end of the list */
{
struct udev_list_entry *entry_loop;
struct udev_list_entry *entry_tmp;
struct udev_list_node devices_list;
/* move delayed to delay list */
udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(&udev_enumerate->devices_list)) {
}
}
/* move delayed back to end of list */
}
return 0;
}
{
struct udev_device *udev_device;
if (udev_enumerate == NULL)
return -EINVAL;
return 0;
/* resolve to real syspath */
if (udev_device == NULL)
return -EINVAL;
return 0;
}
/**
* udev_enumerate_scan_devices:
* @udev_enumerate: udev enumeration context
*
* Returns: a negative value on error.
**/
{
char base[UTIL_PATH_SIZE];
if (udev_enumerate == NULL)
return -EINVAL;
/* we have /subsystem/, forget all the old stuff */
} else {
/* if block isn't a class, scan /block/ */
/* scan disks */
/* scan partitions */
}
}
}
return 0;
}
/**
* udev_enumerate_scan_subsystems:
* @udev_enumerate: udev enumeration context
*
* Returns: a negative value on error.
**/
{
char base[UTIL_PATH_SIZE];
const char *subsysdir;
if (udev_enumerate == NULL)
return -EINVAL;
subsysdir = "subsystem";
else
subsysdir = "bus";
}
}
return 0;
}