libudev-enumerate.c revision 438d4c3cd4b89381348f84ef9f8b8937814f8362
/*
* libudev - interface to udev device information
*
* Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <dirent.h>
#include "libudev.h"
#include "libudev-private.h"
struct udev_enumerate {
int refcount;
struct list_node devices_list;
};
{
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;
}
struct list_node *devices_list)
{
char path[UTIL_PATH_SIZE];
}
return -1;
char syspath[UTIL_PATH_SIZE];
char filename[UTIL_PATH_SIZE];
continue;
continue;
}
return 0;
}
struct udev_list_entry *subsystem_include_list,
struct udev_list_entry *subsystem_exclude_list,
struct list_node *devices_list)
{
if (subsystem_include_list != NULL) {
struct udev_list_entry *list_entry;
/* if list of subsystems to scan is given, just use this list */
if (udev_list_entry_get_by_name(subsystem_exclude_list, udev_list_entry_get_name(list_entry)) != NULL)
continue;
}
} else {
char path[UTIL_PATH_SIZE];
/* if no list of subsystems to scan is given, scan all, and possible exclude some subsystems */
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;
}
/**
* 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;
}
/**
* udev_enumerate_scan_devices:
* @udev_enumerate: udev enumeration context
* @subsystem: the list of names of subsystems to look for devices
*
* Returns: 0 on success.
**/
{
const char *arg;
char base[UTIL_PATH_SIZE];
struct list_node subsystem_include_list;
struct list_node subsystem_exclude_list;
struct udev_list_entry *list_entry;
if (udev_enumerate == NULL)
return -EINVAL;
if (arg[0] != '!')
else
}
/* we have /subsystem/, forget all the old stuff */
} else {
/* if block isn't a class, scan /block/ */
int include_block = (include_list == NULL || udev_list_entry_get_by_name(include_list, "block") != NULL);
if (include_block && !exclude_block) {
/* scan disks */
/* scan partitions */
}
}
}
/* sort delayed devices to the end of the list */
}
return 0;
}
/**
* udev_enumerate_scan_subsystems:
* @udev_enumerate: udev enumeration context
*
* Returns: 0 on success.
**/
{
char base[UTIL_PATH_SIZE];
const char *subsysdir;
if (udev_enumerate == NULL)
return -EINVAL;
subsysdir = "/subsystem";
else
subsysdir = "/bus";
return 0;
}