2005-04-27 07:59:47 +04:00
/*
* udev . h
*
* Userspace devfs
*
* Copyright ( C ) 2003 Greg Kroah - Hartman < greg @ kroah . com >
2005-03-04 23:33:57 +03:00
* Copyright ( C ) 2003 - 2005 Kay Sievers < kay . sievers @ vrfy . org >
2005-04-27 07:59:47 +04:00
*
* This program is free software ; you can redistribute it and / or modify it
* 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 0213 9 , USA .
*
*/
2004-03-23 09:22:20 +03:00
# ifndef _UDEV_H_
# define _UDEV_H_
2005-04-27 07:59:47 +04:00
2005-02-09 06:37:32 +03:00
# include <sys/types.h>
2003-12-02 11:26:46 +03:00
# include <sys/param.h>
2004-03-23 09:22:20 +03:00
# include "libsysfs/sysfs/libsysfs.h"
2005-02-21 16:48:12 +03:00
# include "list.h"
2005-04-27 07:59:47 +04:00
2004-11-05 15:16:32 +03:00
# define ALARM_TIMEOUT 120
2003-12-03 12:08:46 +03:00
# define COMMENT_CHARACTER '#'
2003-10-16 10:50:13 +04:00
2005-03-04 23:13:18 +03:00
# define LINE_SIZE 512
2004-03-23 09:39:39 +03:00
# define NAME_SIZE 256
2004-11-29 15:44:01 +03:00
# define USER_SIZE 32
2003-07-19 09:48:28 +04:00
2004-09-05 20:05:29 +04:00
# define ACTION_SIZE 32
# define DEVPATH_SIZE 256
# define SUBSYSTEM_SIZE 32
# define SEQNUM_SIZE 32
2004-02-27 06:40:32 +03:00
2004-11-12 08:21:16 +03:00
# define DEVD_DIR " / etc / dev.d"
# define DEVD_SUFFIX ".dev"
2004-11-23 10:01:57 +03:00
# define HOTPLUGD_DIR " / etc / hotplug.d"
# define HOTPLUG_SUFFIX ".hotplug"
2005-02-09 10:43:18 +03:00
# define DEFAULT_PARTITIONS_COUNT 15
2005-02-21 15:45:04 +03:00
enum device_type {
UNKNOWN ,
CLASS ,
BLOCK ,
NET ,
PHYSDEV ,
} ;
2003-10-21 09:48:44 +04:00
struct udevice {
2004-11-06 16:28:01 +03:00
char devpath [ DEVPATH_SIZE ] ;
char subsystem [ SUBSYSTEM_SIZE ] ;
2004-11-29 04:15:55 +03:00
2003-10-21 09:48:44 +04:00
char name [ NAME_SIZE ] ;
2005-03-04 23:13:18 +03:00
char devname [ NAME_SIZE ] ;
2004-11-29 04:15:55 +03:00
char symlink [ NAME_SIZE ] ;
2004-11-29 15:44:01 +03:00
char owner [ USER_SIZE ] ;
char group [ USER_SIZE ] ;
2004-11-29 04:15:55 +03:00
mode_t mode ;
2003-10-21 09:48:44 +04:00
char type ;
2005-02-21 15:44:39 +03:00
dev_t devt ;
2004-11-29 04:15:55 +03:00
2005-02-09 06:37:32 +03:00
char tmp_node [ NAME_SIZE ] ;
2004-02-17 08:44:28 +03:00
int partitions ;
2004-11-13 16:43:24 +03:00
int ignore_remove ;
[PATCH] first stupid try for a rule compose gui
On Mon, Mar 15, 2004 at 09:28:17PM +0100, Kay Sievers wrote:
> Here is a first simple and pretty stupid try to make a simple tool for
> composing of a udev rule.
>
> It reads the udevdb to get all currently handled devices and presents a
> list, where you can choose the device to compose the rule for.
>
> The composed rule is just printed out in a window, nothing else by now.
>
> Do we want something like this?
> Nevermind, I always wanted to know, how this newt thing works :)
Here is the next step, I still can't sleep and there are to many patches
pending to make something useful :)
Cause nobody wanted to play with me, I've made a screenshot.
The device list is sorted in alphabetical order now and if there are only
a few recently discovered devices, they are placed on top of the list.
For those who want to have a look:
http://vrfy.org/projects/udev/udevruler.png
The patch applies on top of today's mmap() patch. The db format is
changed to have the file and line number of the applied rule. So it
should be easy to edit the matching rule with this beast. It compiles
with "make all udevruler".
2004-03-24 05:24:25 +03:00
int config_line ;
char config_file [ NAME_SIZE ] ;
2004-02-13 09:51:44 +03:00
char bus_id [ SYSFS_NAME_LEN ] ;
char program_result [ NAME_SIZE ] ;
char kernel_number [ NAME_SIZE ] ;
char kernel_name [ NAME_SIZE ] ;
2004-10-19 06:11:51 +04:00
int test_run ;
2003-10-21 09:48:44 +04:00
} ;
2004-10-19 06:11:51 +04:00
extern int udev_add_device ( struct udevice * udev , struct sysfs_class_device * class_dev ) ;
extern int udev_remove_device ( struct udevice * udev ) ;
2003-12-03 12:08:46 +03:00
extern void udev_init_config ( void ) ;
[PATCH] Make udev/udevstart be one binary
Hi,
The following patch makes udev/udevstart be a common binary. First,
doing this grows udev by a total of 1.8kB (ppc32, stripped) whereas
udevstart by itself is 6.4kB. I know you mentioned being able to
replace udevstart with a script, but at 1.8kB I don't think it'll be
easy to beat this with size there. Next, the following are by-eye
timings of before, after, and with devfs on a slow, but still usable
embedded platform (config stripped down to more-or-less bare for
ramdisk):
-- Embedded Planet RPX LITE, 64Mhz MPC 823e --
devfs : 15.333s, 15.253s, 14.988s (15.191s avg)
udev-pristine : 18.675s, 18.079s, 18.418s (18.390s avg)
udev-multi : 14.587s, 14.747s, 14.868s (14.734s avg)
The patch ends up being rather large to add this, as in doing so I ended
up making all refs (that I hit..) to devpath/subsystem be marked as
'const'.
Signed-off-by: Tom Rini <trini@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2004-08-10 11:50:21 +04:00
extern int udev_start ( void ) ;
2004-11-25 04:44:38 +03:00
extern void udev_multiplex_directory ( struct udevice * udev , const char * basedir , const char * suffix ) ;
2005-02-21 15:44:39 +03:00
extern int udev_make_node ( struct udevice * udev , const char * file , dev_t devt , mode_t mode , uid_t uid , gid_t gid ) ;
2003-04-11 07:04:38 +04:00
2003-10-22 07:19:09 +04:00
extern char sysfs_path [ SYSFS_PATH_MAX ] ;
2003-12-03 12:08:46 +03:00
extern char udev_root [ PATH_MAX ] ;
2004-11-06 16:28:01 +03:00
extern char udev_db_path [ PATH_MAX + NAME_MAX ] ;
2003-10-22 07:19:09 +04:00
extern char udev_config_filename [ PATH_MAX + NAME_MAX ] ;
2003-12-03 12:08:46 +03:00
extern char udev_rules_filename [ PATH_MAX + NAME_MAX ] ;
2004-02-12 09:10:26 +03:00
extern int udev_log ;
[PATCH] netdev - udevdb+dev.d changes
Here is a patch to change the netdev handling in the database and for
the dev.d/ calls. I applies on top of the udevd.patch, cause klibc has
no sysinfo().
o netdev's are also put into our database now. I want this for the
udevruler gui to get a list of all handled devices.
All devices in the db are stamped with the system uptime value at
the creation time. 'udevinfo -d' prints it.
o the DEVPATH value is the key for udevdb, but if we rename
a netdev, the name is replaced in the kernel, so we add
the changed name to the db to match with the remove event.
NOTE: The dev.d/ scripts still get the original name from the
hotplug call. Should we replace DEVPATH with the new name too?
o We now only add a device to the db, if we have successfully created
the main node or successfully renamed a netdev. This is the main part
of the patch, cause I needed to clean the retval passing trough all
the functions used for node creation.
o DEVNODE sounds a bit ugly for netdev's so I exported DEVNAME too.
Can we change the name?
o I've added a UDEV_NO_DEVD to possibly skip the script execution
and used it in udev-test.pl.
udevstart is the same horror now, if you have scripts with logging
statements in dev.d/ it takes minutes to finish, can we skip the
scripts here too?
o The get_device_type() function is changed to be more strict, cause
'udevinfo -a -p /block/' gets a class device for it and tries to
print the major/minor values.
o bugfix, the RESULT value has now a working newline removal and a test
for this case.
2004-04-01 11:12:57 +04:00
extern int udev_dev_d ;
2004-11-25 12:15:32 +03:00
extern int udev_hotplug_d ;
2003-10-22 07:19:09 +04:00
2005-04-27 07:59:47 +04:00
# endif