udev-event.c revision 6880b25d4044f2d154908f88e717435412187355
/*
* Copyright (C) 2004-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 <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include "udev.h"
{
struct udev_event *event;
return NULL;
return event;
}
{
}
/* extract possible {attr} and move str behind it */
{
char *pos;
if (*str[0] == '{') {
return NULL;
}
pos[0] = '\0';
}
return attr;
}
/* extract possible format length and move str behind it*/
{
int num;
char *tail;
if (num > 0) {
return num;
} else {
}
}
return -1;
}
{
char temp[UTIL_PATH_SIZE];
char temp2[UTIL_PATH_SIZE];
int len;
int i;
int count;
enum subst_type {
};
static const struct subst_map {
char *name;
char fmt;
enum subst_type type;
} map[] = {
{ NULL, '\0', 0 }
};
enum subst_type type;
while (1) {
len = -1;
while (head[0] != '\0') {
if (head[0] == '$') {
/* substitute named variable */
break;
head++;
continue;
}
head[0] = '\0';
goto found;
}
}
head[0] = '$';
} else if (head[0] == '%') {
/* substitute format char */
break;
head++;
continue;
}
head[0] = '\0';
tail++;
goto found;
}
}
head[0] = '%';
}
head++;
}
break;
switch (type) {
case SUBST_DEVPATH:
break;
case SUBST_KERNEL:
break;
case SUBST_KERNEL_NUMBER:
break;
break;
case SUBST_ID:
}
break;
case SUBST_DRIVER:
break;
}
break;
case SUBST_MAJOR:
break;
case SUBST_MINOR:
break;
case SUBST_RESULT:
break;
/* get part part of the result string */
i = 0;
if (i > 0) {
while (--i) {
cpos++;
cpos++;
}
if (i > 0) {
break;
}
/* %{2+}c copies the whole string from the second part on */
if (rest[0] != '+') {
if (cpos)
cpos[0] = '\0';
}
} else {
}
break;
case SUBST_ATTR:
else {
const char *val;
/* try the current device, other matches may have selected */
}
if (value[0]=='\0')
break;
/* strip trailing whitespace, and replace unwanted characters */
if (count > 0)
}
break;
case SUBST_PARENT:
{
struct udev_device *dev_parent;
const char *devnode;
if (dev_parent == NULL)
break;
}
}
break;
case SUBST_TEMP_NODE:
}
break;
case SUBST_NAME:
} else {
}
break;
case SUBST_LINKS:
{
struct udev_list_entry *list_entry;
}
}
break;
case SUBST_ROOT:
break;
case SUBST_SYS:
break;
case SUBST_ENV:
break;
} else {
struct udev_list_entry *list_entry;
const char *value;
if (list_entry == NULL)
break;
break;
}
default:
break;
}
/* possibly truncate to format-char specified length */
}
}
}
{
int klog;
FILE *f;
if (klog < 0)
return;
if (f == NULL) {
return;
}
fprintf(f, "<6>udev: renamed network interface %s to %s\n",
fclose(f);
}
{
int sk;
int err;
return 0;
if (sk < 0) {
return -1;
}
if (err == 0)
else {
int loop;
/* see if the destination interface name already exists */
goto exit;
}
/* free our own name, another process may wait for us */
if (err != 0) {
goto exit;
}
/* wait 30 seconds for our target to become available */
while (loop--) {
if (err == 0) {
break;
}
break;
}
}
}
exit:
return err;
}
{
int err = 0;
}
/* add device node */
(strcmp(udev_device_get_action(dev), "add") == 0 || strcmp(udev_device_get_action(dev), "change") == 0)) {
char filename[UTIL_PATH_SIZE];
struct udev_device *dev_old;
}
if (event->ignore_device) {
goto exit;
}
if (event->name_ignore) {
goto exit;
}
}
/* set device node name */
/* read current database entry; cleanup, if it is known device */
}
}
if (err != 0)
goto exit;
goto exit;
}
/* add netif */
if (strcmp(udev_device_get_subsystem(dev), "net") == 0 && strcmp(udev_device_get_action(dev), "add") == 0) {
if (event->ignore_device) {
goto exit;
}
goto exit;
}
/* look if we want to change the name of the netif */
char syspath[UTIL_PATH_SIZE];
char *pos;
if (err != 0)
goto exit;
/* remember old name */
/* now change the devpath, because the kernel device name has changed */
}
}
goto exit;
}
/* remove device node */
if (major(udev_device_get_devnum(dev)) != 0 && strcmp(udev_device_get_action(dev), "remove") == 0) {
/* import database entry and delete it */
char devnode[UTIL_PATH_SIZE];
}
if (event->ignore_device) {
goto exit;
}
if (udev_device_get_ignore_remove(dev)) {
goto exit;
}
goto exit;
}
/* default devices */
if (event->ignore_device)
exit:
return err;
}
{
struct udev_list_entry *list_entry;
int err = 0;
struct udev_monitor *monitor;
continue;
} else {
char program[UTIL_PATH_SIZE];
char **envp;
err = -1;
}
}
}
return err;
}