udev_device.c revision ff9a488d8c559a2ee40e522cdc68b750670711e4
/*
* udev_device.c - main udev data object
*
* Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
*
* 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 <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <stropts.h>
#include "udev.h"
#include "udev_rules.h"
struct udevice *udev_device_init(void)
{
return NULL;
/* set sysfs device to local storage, can be overridden if needed */
/* default node permissions */
return udev;
}
{
}
{
const char *attr;
/* read it from sysfs */
}
return makedev(0, 0);
}
{
int sk;
int retval;
return 0;
if (sk < 0) {
return -1;
}
if (retval != 0)
return retval;
}
{
int retval = 0;
/* add device node */
if (udev->ignore_device) {
info("device event will be ignored");
goto exit;
}
info("device node creation supressed");
goto exit;
}
/* read current database entry, we may want to cleanup symlinks */
udev_old = udev_device_init();
}
}
/* create node and symlinks, store record in database */
if (retval == 0)
goto exit;
}
/* add netif */
if (udev->ignore_device) {
info("device event will be ignored");
goto exit;
}
/* look if we want to change the name of the netif */
char *pos;
if (retval != 0)
goto exit;
/* export old name */
/* now fake the devpath, because the kernel name changed silently */
}
}
goto exit;
}
/* remove device node */
struct name_entry *name_loop;
/* import and delete database entry */
if (udev->ignore_remove) {
return 0;
}
/* restore stored persistent data */
} else {
dbg("'%s' not found in database, using kernel name '%s'", udev->dev->devpath, udev->dev->kernel_name);
}
if (udev->ignore_device) {
info("device event will be ignored");
goto exit;
}
goto exit;
}
/* default devices */
if (udev->ignore_device)
info("device event will be ignored");
exit:
return retval;
}