udevstart.c revision 1aa1e24848903d11780db1ade355be73ad61a937
/*
*
* Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2004 Kay Sievers <kay@vrfy.org>
*
* Quick and dirty way to populate a /dev with udev if your system
* does not have access to a shell. Based originally on a patch
* from:
* Harald Hoyer <harald@redhat.com>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* 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, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <dirent.h>
#include <signal.h>
#include <syslog.h>
#include "udev.h"
#include "udev_rules.h"
static const char *udev_run_str;
static const char *udev_log_str;
static struct udev_rules rules;
#ifdef USE_LOG
{
if (priority > udev_log_priority)
return;
}
#endif
struct device {
};
/* sort files in lexical order */
{
struct device *loop_device;
struct device *new_device;
break;
}
}
if (new_device == NULL) {
dbg("error malloc");
return -ENOMEM;
}
return 0;
}
/* list of devices that we should run last due to any one of a number of reasons */
static char *last_list[] = {
NULL,
};
/* list of devices that we should run first due to any one of a number of reasons */
static char *first_list[] = {
NULL,
};
static int add_device(const char *devpath)
{
struct sysfs_device *dev;
/* clear and set environment for next event */
clearenv();
if (udev_log_str)
if (udev_run_str)
return -1;
udev = udev_device_init();
return -1;
/* override built-in sysfs device */
return -1;
}
if (udev->ignore_device) {
dbg("device event will be ignored");
goto exit;
}
dbg("device node creation supressed");
goto run;
}
run:
struct name_entry *name_loop;
dbg("executing run list");
else
}
}
exit:
return 0;
}
{
struct device *loop_device;
struct device *tmp_device;
int i;
/* handle the "first" type devices first */
for (i = 0; first_list[i] != NULL; i++) {
break;
}
}
}
/* handle the devices we are allowed to, excluding the "last" type devices */
int found = 0;
found = 1;
break;
}
}
if (found)
continue;
}
/* handle the rest of the devices left over, if any */
}
}
{
return 1;
return 0;
}
{
continue;
else
continue;
/* look for partitions */
continue;
}
}
}
}
}
{
continue;
continue;
}
}
}
}
}
{
switch (signum) {
case SIGALRM:
exit(1);
case SIGINT:
case SIGTERM:
}
}
{
logging_init("udevstart");
/* disable all logging if not explicitely requested */
if (udev_log_str == NULL)
udev_log_priority = 0;
/* set signal handlers */
/* trigger timeout to prevent hanging processes */
sysfs_init();
return 0;
}