2003-07-17 12:24:51 +04:00
/*
2005-03-13 00:36:32 +03:00
* udev_rules . h
2003-07-17 12:24:51 +04:00
*
* Userspace devfs
*
2004-01-27 06:21:58 +03:00
* Copyright ( C ) 2003 , 2004 Greg Kroah - Hartman < greg @ kroah . com >
2003-07-17 12:24:51 +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 .
*
*/
2005-03-13 09:14:49 +03:00
# ifndef UDEV_RULES_H
# define UDEV_RULES_H
2003-07-17 12:24:51 +04:00
2005-03-13 00:36:32 +03:00
# include "libsysfs/sysfs/libsysfs.h"
2003-08-06 10:57:23 +04:00
# include "udev.h"
2003-07-24 02:56:56 +04:00
# include "list.h"
2003-07-19 16:06:55 +04:00
2005-03-13 07:46:31 +03:00
# define KEY_KERNEL "KERNEL"
# define KEY_SUBSYSTEM "SUBSYSTEM"
2005-04-02 19:45:35 +04:00
# define KEY_ACTION "ACTION"
2005-06-20 02:29:38 +04:00
# define KEY_DEVPATH "DEVPATH"
2005-03-13 07:46:31 +03:00
# define KEY_BUS "BUS"
# define KEY_ID "ID"
# define KEY_PROGRAM "PROGRAM"
# define KEY_RESULT "RESULT"
# define KEY_DRIVER "DRIVER"
2005-03-13 13:40:32 +03:00
# define KEY_SYSFS "SYSFS"
# define KEY_ENV "ENV"
2005-06-20 02:29:38 +04:00
# define KEY_MODALIAS "MODALIAS"
2005-03-13 07:46:31 +03:00
# define KEY_NAME "NAME"
# define KEY_SYMLINK "SYMLINK"
# define KEY_OWNER "OWNER"
# define KEY_GROUP "GROUP"
# define KEY_MODE "MODE"
2005-04-02 19:45:35 +04:00
# define KEY_RUN "RUN"
2005-03-13 07:46:31 +03:00
# define KEY_OPTIONS "OPTIONS"
2004-02-17 08:44:28 +03:00
2005-03-13 00:55:08 +03:00
# define OPTION_LAST_RULE "last_rule"
2005-03-04 23:00:43 +03:00
# define OPTION_IGNORE_DEVICE "ignore_device"
# define OPTION_IGNORE_REMOVE "ignore_remove"
# define OPTION_PARTITIONS "all_partitions"
2004-02-17 08:44:28 +03:00
2005-03-13 10:15:10 +03:00
# define KEY_SYSFS_PAIRS_MAX 5
2005-03-13 13:40:32 +03:00
# define KEY_ENV_PAIRS_MAX 5
2003-12-23 09:31:35 +03:00
2004-03-27 12:21:46 +03:00
# define RULEFILE_SUFFIX ".rules"
2004-02-24 06:31:14 +03:00
2005-03-13 07:46:31 +03:00
enum key_operation {
2005-03-28 14:20:05 +04:00
KEY_OP_UNSET ,
2005-03-13 07:46:31 +03:00
KEY_OP_MATCH ,
KEY_OP_NOMATCH ,
KEY_OP_ADD ,
KEY_OP_ASSIGN ,
2005-06-05 06:57:03 +04:00
KEY_OP_ASSIGN_FINAL ,
2005-03-13 07:46:31 +03:00
} ;
2005-03-13 10:15:10 +03:00
struct key_pair {
char name [ NAME_SIZE ] ;
2003-12-23 09:31:35 +03:00
char value [ VALUE_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation operation ;
2003-12-23 09:31:35 +03:00
} ;
2003-07-24 02:56:56 +04:00
2005-03-13 00:36:32 +03:00
struct udev_rule {
2003-07-24 02:56:56 +04:00
struct list_head node ;
2005-02-21 16:01:23 +03:00
char kernel [ NAME_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation kernel_operation ;
2005-03-07 06:29:43 +03:00
char subsystem [ NAME_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation subsystem_operation ;
2005-04-02 19:45:35 +04:00
char action [ NAME_SIZE ] ;
enum key_operation action_operation ;
2005-06-20 02:29:38 +04:00
char devpath [ PATH_SIZE ] ;
enum key_operation devpath_operation ;
2005-03-07 06:29:43 +03:00
char bus [ NAME_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation bus_operation ;
2005-03-07 06:29:43 +03:00
char id [ NAME_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation id_operation ;
char driver [ NAME_SIZE ] ;
enum key_operation driver_operation ;
2005-03-07 06:29:43 +03:00
char program [ PATH_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation program_operation ;
2005-03-07 06:29:43 +03:00
char result [ PATH_SIZE ] ;
2005-03-13 07:46:31 +03:00
enum key_operation result_operation ;
2005-03-13 10:15:10 +03:00
struct key_pair sysfs_pair [ KEY_SYSFS_PAIRS_MAX ] ;
int sysfs_pair_count ;
2005-03-13 13:40:32 +03:00
struct key_pair env_pair [ KEY_ENV_PAIRS_MAX ] ;
int env_pair_count ;
2005-06-20 02:29:38 +04:00
enum key_operation modalias_operation ;
char modalias [ PATH_SIZE ] ;
2005-03-13 07:46:31 +03:00
2005-03-07 06:29:43 +03:00
char name [ PATH_SIZE ] ;
2005-06-05 17:55:29 +04:00
enum key_operation name_operation ;
2005-03-07 06:29:43 +03:00
char symlink [ PATH_SIZE ] ;
2005-06-05 06:57:03 +04:00
enum key_operation symlink_operation ;
2004-11-29 15:44:01 +03:00
char owner [ USER_SIZE ] ;
2005-06-05 06:57:03 +04:00
enum key_operation owner_operation ;
2004-11-29 15:44:01 +03:00
char group [ USER_SIZE ] ;
2005-06-05 06:57:03 +04:00
enum key_operation group_operation ;
2004-11-29 15:44:01 +03:00
mode_t mode ;
2005-06-05 06:57:03 +04:00
enum key_operation mode_operation ;
2005-04-02 19:45:35 +04:00
char run [ PATH_SIZE ] ;
2005-06-05 06:57:03 +04:00
enum key_operation run_operation ;
2005-02-14 08:03:06 +03:00
2005-03-13 00:55:08 +03:00
int last_rule ;
2005-02-14 08:03:06 +03:00
int ignore_device ;
2004-11-13 16:43:24 +03:00
int ignore_remove ;
2005-03-13 00:55:08 +03:00
int partitions ;
2005-02-14 08:03:06 +03:00
2005-03-07 06:29:43 +03:00
char config_file [ PATH_SIZE ] ;
[PATCH] add udev logging to info log
On Thu, Jan 15, 2004 at 05:14:16AM +0100, Kay Sievers wrote:
> On Wed, Jan 14, 2004 at 01:10:43PM -0800, Greg KH wrote:
> > On Wed, Jan 14, 2004 at 02:34:26PM -0600, Clay Haapala wrote:
> > > On Wed, 14 Jan 2004, Chris Friesen spake thusly:
> > > >
> > > > Maybe for ones with a matching rule, you could print something like:
> > > >
> > > >
> > > Is the act of printing/syslogging a rule in an of itself?
> >
> > No, as currently the only way stuff ends up in the syslog is if
> > DEBUG=true is used on the build line.
> >
> > But it's sounding like we might want to change that... :)
>
> How about this in the syslog after connect/disconnect?
>
> Jan 15 05:07:45 pim udev[28007]: configured rule in '/etc/udev/udev.rules' at line 17 applied, 'video*' becomes 'video/webcam%n'
> Jan 15 05:07:45 pim udev[28007]: creating device node '/udev/video/webcam0'
> Jan 15 05:07:47 pim udev[28015]: removing device node '/udev/video/webcam0'
Here is a slightly better version. I've created a logging.h file and
moved the debug macros from udev.h in there.
If you type:
'make' - you will get a binary that prints one or two lines to syslog
if a device node is created or deleted
'make LOG=false' - you get a binary that prints asolutely nothing
'make DEBUG=true' - the same as today, it will print all debug lines
2004-01-16 08:53:20 +03:00
int config_line ;
2003-12-04 05:33:58 +03:00
} ;
2005-03-13 00:36:32 +03:00
extern int udev_rules_init ( void ) ;
2005-06-24 20:05:32 +04:00
extern void udev_rules_close ( void ) ;
extern int udev_rules_iter_init ( void ) ;
extern struct udev_rule * udev_rules_iter_next ( void ) ;
2005-03-13 00:36:32 +03:00
extern int udev_rules_get_name ( struct udevice * udev , struct sysfs_class_device * class_dev ) ;
2005-06-05 17:55:29 +04:00
extern int udev_rules_get_run ( struct udevice * udev , struct sysfs_device * sysfs_device ) ;
2003-12-03 05:38:30 +03:00
2003-07-17 12:24:51 +04:00
# endif