udev.c revision 2b41e68a08548ce44b4d145900dab2bb04cd34f7
/*
* udev.c
*
* Userspace devfs
*
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.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 <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include "libsysfs/sysfs/libsysfs.h"
#include "udev.h"
#include "udev_lib.h"
#include "udev_sysfs.h"
#include "udev_version.h"
#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
/* global variables */
char **main_argv;
char **main_envp;
#ifdef LOG
unsigned char logname[LOGNAME_SIZE];
{
if (!udev_log)
return;
}
#endif
{
switch (signum) {
case SIGALRM:
exit(1);
case SIGINT:
case SIGTERM:
}
}
{
struct sysfs_class_device *class_dev;
char path[SYSFS_PATH_MAX];
enum {
ADD,
} act_type;
logging_init("udev");
} else {
const char *action = get_action();
const char *devpath = get_devpath();
if (!action) {
dbg("no action?");
goto exit;
}
} else {
goto exit;
}
if (!devpath) {
dbg("no devpath?");
goto exit;
}
/* we only care about class devices and block stuff */
dbg("not a block or class device");
goto exit;
}
if (!subsystem) {
dbg("no subsystem");
goto exit;
}
/* skip blacklisted subsystems */
goto exit;
};
}
/* set signal handlers */
/* alarm must not restart syscalls*/
/* trigger timout to interrupt blocking syscalls */
switch(act_type) {
case UDEVSTART:
dbg("udevstart");
namedev_init();
retval = udev_start();
break;
case ADD:
dbg("udev add");
/* open the device */
dbg ("sysfs_open_class_device_path failed");
break;
}
/* init rules */
namedev_init();
/* name, create node, store in db */
/* run scripts */
break;
case REMOVE:
dbg("udev remove");
/* get node from db, delete it*/
/* run scripts */
}
exit:
return retval;
}