2005-04-27 07:59:47 +04:00
/*
* udev . h
*
* Userspace devfs
*
* Copyright ( C ) 2003 Greg Kroah - Hartman < greg @ kroah . com >
*
* 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
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-04-27 07:59:47 +04:00
2003-12-03 12:08:46 +03:00
# define COMMENT_CHARACTER '#'
2003-10-16 10:50:13 +04:00
2004-03-23 09:39:39 +03:00
# define NAME_SIZE 256
2004-03-23 09:22:20 +03:00
# define OWNER_SIZE 30
# define GROUP_SIZE 30
# define MODE_SIZE 8
2003-07-19 09:48:28 +04:00
2004-03-23 09:22:20 +03:00
# define ACTION_SIZE 30
# define DEVPATH_SIZE 255
# define SUBSYSTEM_SIZE 30
2004-02-27 06:40:32 +03:00
2004-02-13 09:51:44 +03:00
/* length of public data */
# define UDEVICE_LEN (offsetof(struct udevice, bus_id))
2003-10-21 09:48:44 +04:00
struct udevice {
char name [ NAME_SIZE ] ;
char owner [ OWNER_SIZE ] ;
char group [ GROUP_SIZE ] ;
char type ;
int major ;
int minor ;
2004-02-12 12:29:40 +03:00
unsigned int mode ; /* not mode_t due to conflicting definitions in different libcs */
2003-12-07 20:12:07 +03:00
char symlink [ NAME_SIZE ] ;
2004-02-17 08:44:28 +03:00
int partitions ;
[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 ] ;
[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
long config_uptime ;
2003-11-24 09:25:13 +03:00
2004-02-13 09:51:44 +03:00
/* private data that help us in building strings */
char bus_id [ SYSFS_NAME_LEN ] ;
char program_result [ NAME_SIZE ] ;
char kernel_number [ NAME_SIZE ] ;
char kernel_name [ NAME_SIZE ] ;
2003-10-21 09:48:44 +04:00
} ;
2004-02-13 07:19:21 +03:00
extern int udev_add_device ( char * path , char * subsystem , int fake ) ;
2003-10-21 09:48:44 +04:00
extern int udev_remove_device ( char * path , char * subsystem ) ;
2003-12-03 12:08:46 +03:00
extern void udev_init_config ( void ) ;
2004-01-27 06:21:58 +03:00
extern int parse_get_pair ( char * * orig_string , char * * left , char * * right ) ;
2004-04-01 12:59:58 +04:00
extern void dev_d_send ( struct udevice * dev , char * subsystem , char * devpath ) ;
2003-04-11 07:04:38 +04:00
2003-10-15 10:32:17 +04:00
extern char * * main_argv ;
extern char * * main_envp ;
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 ] ;
2003-10-22 07:19:09 +04:00
extern char udev_db_filename [ PATH_MAX + NAME_MAX ] ;
2003-12-03 19:13:11 +03:00
extern char udev_permissions_filename [ 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-01-20 06:44:24 +03:00
extern char default_mode_str [ MODE_SIZE ] ;
2004-01-20 06:42:42 +03:00
extern char default_owner_str [ OWNER_SIZE ] ;
extern char default_group_str [ GROUP_SIZE ] ;
2004-02-12 09:10:26 +03:00
extern int udev_log ;
2004-02-18 07:59:26 +03:00
extern int udev_sleep ;
[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 ;
2003-10-22 07:19:09 +04:00
2005-04-27 07:59:47 +04:00
# endif