libudev.c revision 33a5cc297680f20e791c792a45fe949f715f5f69
/*
* 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 "config.h"
#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"
#include "../udev.h"
const char *format, ...)
{
}
{
static int log = -1;
if (log == -1) {
log = 1;
else
log = 0;
}
if (log == 1) {
}
}
/* glue to udev logging, needed until udev logging code is "fixed" */
#ifdef USE_LOG
{
}
#endif
{
const char *pos;
return -1;
return -1;
}
/**
* udev_new:
*
* Create udev library context.
*
* The initial refcount is 1, and needs to be decremented to
* release the ressources of the udev library context.
*
* Returns: a new udev library context
**/
{
return NULL;
sysfs_init();
return udev;
}
/**
* udev_ref:
* @udev: udev library context
*
* Take a reference of the udev library context.
*
* Returns: the passed udev library context
**/
{
return udev;
}
/**
* udev_unref:
* @udev: udev library context
*
* Drop a reference of the udev library context. If the refcount
* reaches zero, the ressources of the context will be released.
*
**/
{
return;
}
/**
* udev_set_log_fn:
* @udev: udev library context
* @log_fn: function to be called for logging messages
*
* The built-in logging, which writes to stderr if the
* LIBUDEV_DEBUG environment variable is set, can be
* overridden by a custom function, to plug log messages
* into the users logging functionality.
*
**/
{
}
/**
* udev_get_sys_path:
* @udev: udev library context
*
* Retrieve the sysfs mount point. The default is "/sys". For
* testing purposes, it can be overridden with the environment
* variable SYSFS_PATH.
*
* Returns: the sys mount point
**/
{
return sysfs_path;
}
/**
* udev_get_dev_path:
* @udev: udev library context
*
* Retrieve the device directory path. The default value is "/dev",
* the actual value may be overridden in the udev configuration
* file.
*
* Returns: the device directory path
**/
{
return udev_root;
}
{
struct udev_device *udev_device;
if (udev_device == NULL)
return NULL;
return udev_device;
}
/**
* udev_device_new_from_devpath:
* @udev: udev library context
* @devpath: sys device path
*
* Create new udev device, and fill in information from the sysfs
* device and the udev database entry. The devpath must not contain
* the sysfs mount path, and must contain a leading '/'.
*
* The initial refcount is 1, and needs to be decremented to
* release the ressources of the udev device.
*
* Returns: a new udev device, or #NULL, if it does not exist
**/
{
struct udev_device *udev_device;
int err;
return NULL;
return NULL;
if (udev_device == NULL)
return NULL;
return NULL;
}
if (err >= 0)
log_info(udev, "device %p filled with %s data\n", udev_device, udev_device_get_devpath(udev_device));
return udev_device;
}
/**
* udev_device_get_udev:
*
* Retrieve the udev library context the device was created with.
*
* Returns: the udev library context
**/
{
return udev_device->udev;
}
/**
* udev_device_ref:
* @udev_device: udev device
*
* Take a reference of a udev device.
*
* Returns: the passed udev device
**/
{
udev_device->refcount++;
return udev_device;
}
/**
* udev_device_unref:
* @udev_device: udev device
*
* Drop a reference of a udev device. If the refcount reaches zero,
* the ressources of the device will be released.
*
**/
{
udev_device->refcount--;
if (udev_device->refcount > 0)
return;
}
/**
* udev_device_get_devpath:
* @udev_device: udev device
*
* Retrieve the sys path of the udev device. The path does not contain
* the sys mount point.
*
* Returns: the sys path of the udev device
**/
{
}
/**
* udev_device_get_devname:
* @udev_device: udev device
*
* Retrieve the device node file name belonging to the udev device.
* The path does not contain the device directory, and does not contain
* a leading '/'.
*
* Returns: the device node file name of the udev device, or #NULL if no device node exists
**/
{
return NULL;
}
/**
* udev_device_get_subsystem:
* @udev_device: udev device
*
* Retrieve the subsystem string of the udev device. The string does not
* contain any "/".
*
* Returns: the subsystem name of the udev device, or #NULL if it can not be determined
**/
{
return NULL;
}
/**
* udev_device_get_devlinks:
* @udev_device: udev device
* @cb: function to be called for every device link found
* @data: data to be passed to the function
*
* Retrieve the device links pointing to the device file of the
* udev device. For every device link, the passed function will be
* called with the device link string. If the function returns 1,
* remaning device links will be ignored. The device link path
* does not contain the device directory, and does not contain
* a leading '/'.
*
* Returns: the number of device links passed to the caller, or a negative value on error
**/
void *data)
{
struct name_entry *name_loop;
int count = 0;
count++;
break;
}
return count;
}
/**
* udev_device_get_properties:
* @udev_device: udev device
* @cb: function to be called for every property found
* @data: data to be passed to the function
*
* called. If the function returns 1, remaning properties will be
* ignored.
*
* Returns: the number of properties passed to the caller, or a negative value on error
**/
void *data)
{
struct name_entry *name_loop;
int count = 0;
char *val;
continue;
val[0] = '\0';
break;
}
return count;
}
struct list_head *device_list)
{
return -1;
continue;
}
return 0;
}
struct list_head *device_list)
{
return -1;
continue;
}
return 0;
}
{
static const char *delay_device_list[] = {
};
int i;
for (i = 0; delay_device_list[i] != NULL; i++) {
return 1;
}
}
return 0;
}
void *data),
void *data,
int *cb_rc)
{
const char *name;
return -1;
name++;
return -1;
return 0;
}
/**
* udev_devices_enumerate:
* @udev_device: udev device
* @cb: function to be called for every property found
* @data: data to be passed to the function
*
* called. If the function returns 1, remaning properties will be
* ignored.
*
* Returns: the number of properties passed to the caller, or a negative value on error
**/
void *data)
{
struct list_head device_list;
struct name_entry *loop_device;
struct name_entry *tmp_device;
int cb_rc = 0;
int count = 0;
} else {
}
continue;
if (cb_rc == 0)
count++;
}
/* handle remaining delayed devices */
if (cb_rc == 0)
count++;
}
return count;
}