2 * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <sys/ioctl.h>
29 #include <sys/socket.h>
31 #include <linux/sockios.h>
34 #include "udev_rules.h"
37 struct udevice *udev_device_init(struct udevice *udev)
40 udev = malloc(sizeof(struct udevice));
43 memset(udev, 0x00, sizeof(struct udevice));
45 INIT_LIST_HEAD(&udev->symlink_list);
46 INIT_LIST_HEAD(&udev->run_list);
47 INIT_LIST_HEAD(&udev->env_list);
49 /* set sysfs device to local storage, can be overridden if needed */
50 udev->dev = &udev->dev_local;
52 /* default node permissions */
54 strcpy(udev->owner, "root");
55 strcpy(udev->group, "root");
57 udev->event_timeout = -1;
62 void udev_device_cleanup(struct udevice *udev)
64 name_list_cleanup(&udev->symlink_list);
65 name_list_cleanup(&udev->run_list);
66 name_list_cleanup(&udev->env_list);
70 dev_t udev_device_get_devt(struct udevice *udev)
73 unsigned int maj, min;
75 /* read it from sysfs */
76 attr = sysfs_attr_get_value(udev->dev->devpath, "dev");
78 if (sscanf(attr, "%u:%u", &maj, &min) == 2)
79 return makedev(maj, min);