2003-07-17 15:24:51 +07:00
|
|
|
/*
|
2005-03-13 04:36:32 +07:00
|
|
|
* udev_rules.h
|
2003-07-17 15:24:51 +07:00
|
|
|
*
|
|
|
|
* Userspace devfs
|
|
|
|
*
|
2004-01-27 10:21:58 +07:00
|
|
|
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
|
2003-07-17 15:24:51 +07: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 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-03-13 13:14:49 +07:00
|
|
|
#ifndef UDEV_RULES_H
|
|
|
|
#define UDEV_RULES_H
|
2003-07-17 15:24:51 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
#include "libsysfs/sysfs/libsysfs.h"
|
2003-08-06 13:57:23 +07:00
|
|
|
#include "udev.h"
|
2003-07-24 05:56:56 +07:00
|
|
|
#include "list.h"
|
|
|
|
|
2003-07-19 19:06:55 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
#define KEY_KERNEL "KERNEL"
|
|
|
|
#define KEY_SUBSYSTEM "SUBSYSTEM"
|
2005-04-02 22:45:35 +07:00
|
|
|
#define KEY_ACTION "ACTION"
|
2005-06-20 05:29:38 +07:00
|
|
|
#define KEY_DEVPATH "DEVPATH"
|
2005-03-13 11:46:31 +07:00
|
|
|
#define KEY_BUS "BUS"
|
|
|
|
#define KEY_ID "ID"
|
|
|
|
#define KEY_PROGRAM "PROGRAM"
|
|
|
|
#define KEY_RESULT "RESULT"
|
|
|
|
#define KEY_DRIVER "DRIVER"
|
2005-03-13 17:40:32 +07:00
|
|
|
#define KEY_SYSFS "SYSFS"
|
|
|
|
#define KEY_ENV "ENV"
|
2005-06-20 05:29:38 +07:00
|
|
|
#define KEY_MODALIAS "MODALIAS"
|
2005-03-13 11:46:31 +07:00
|
|
|
#define KEY_NAME "NAME"
|
|
|
|
#define KEY_SYMLINK "SYMLINK"
|
|
|
|
#define KEY_OWNER "OWNER"
|
|
|
|
#define KEY_GROUP "GROUP"
|
|
|
|
#define KEY_MODE "MODE"
|
2005-04-02 22:45:35 +07:00
|
|
|
#define KEY_RUN "RUN"
|
2005-03-13 11:46:31 +07:00
|
|
|
#define KEY_OPTIONS "OPTIONS"
|
2004-02-17 12:44:28 +07:00
|
|
|
|
2005-03-13 04:55:08 +07:00
|
|
|
#define OPTION_LAST_RULE "last_rule"
|
2005-03-05 03:00:43 +07:00
|
|
|
#define OPTION_IGNORE_DEVICE "ignore_device"
|
|
|
|
#define OPTION_IGNORE_REMOVE "ignore_remove"
|
|
|
|
#define OPTION_PARTITIONS "all_partitions"
|
2004-02-17 12:44:28 +07:00
|
|
|
|
2005-03-13 14:15:10 +07:00
|
|
|
#define KEY_SYSFS_PAIRS_MAX 5
|
2005-03-13 17:40:32 +07:00
|
|
|
#define KEY_ENV_PAIRS_MAX 5
|
2003-12-23 13:31:35 +07:00
|
|
|
|
2004-03-27 16:21:46 +07:00
|
|
|
#define RULEFILE_SUFFIX ".rules"
|
2004-02-24 10:31:14 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation {
|
2005-03-28 17:20:05 +07:00
|
|
|
KEY_OP_UNSET,
|
2005-03-13 11:46:31 +07:00
|
|
|
KEY_OP_MATCH,
|
|
|
|
KEY_OP_NOMATCH,
|
|
|
|
KEY_OP_ADD,
|
|
|
|
KEY_OP_ASSIGN,
|
2005-06-05 09:57:03 +07:00
|
|
|
KEY_OP_ASSIGN_FINAL,
|
2005-03-13 11:46:31 +07:00
|
|
|
};
|
|
|
|
|
2005-03-13 14:15:10 +07:00
|
|
|
struct key_pair {
|
|
|
|
char name[NAME_SIZE];
|
2003-12-23 13:31:35 +07:00
|
|
|
char value[VALUE_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation operation;
|
2003-12-23 13:31:35 +07:00
|
|
|
};
|
2003-07-24 05:56:56 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
struct udev_rule {
|
2003-07-24 05:56:56 +07:00
|
|
|
struct list_head node;
|
|
|
|
|
2005-02-21 20:01:23 +07:00
|
|
|
char kernel[NAME_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation kernel_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char subsystem[NAME_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation subsystem_operation;
|
2005-04-02 22:45:35 +07:00
|
|
|
char action[NAME_SIZE];
|
|
|
|
enum key_operation action_operation;
|
2005-06-20 05:29:38 +07:00
|
|
|
char devpath[PATH_SIZE];
|
|
|
|
enum key_operation devpath_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char bus[NAME_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation bus_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char id[NAME_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation id_operation;
|
|
|
|
char driver[NAME_SIZE];
|
|
|
|
enum key_operation driver_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char program[PATH_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation program_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char result[PATH_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
enum key_operation result_operation;
|
2005-03-13 14:15:10 +07:00
|
|
|
struct key_pair sysfs_pair[KEY_SYSFS_PAIRS_MAX];
|
|
|
|
int sysfs_pair_count;
|
2005-03-13 17:40:32 +07:00
|
|
|
struct key_pair env_pair[KEY_ENV_PAIRS_MAX];
|
|
|
|
int env_pair_count;
|
2005-06-20 05:29:38 +07:00
|
|
|
enum key_operation modalias_operation;
|
|
|
|
char modalias[PATH_SIZE];
|
2005-03-13 11:46:31 +07:00
|
|
|
|
2005-03-07 10:29:43 +07:00
|
|
|
char name[PATH_SIZE];
|
2005-06-05 20:55:29 +07:00
|
|
|
enum key_operation name_operation;
|
2005-03-07 10:29:43 +07:00
|
|
|
char symlink[PATH_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
enum key_operation symlink_operation;
|
2004-11-29 19:44:01 +07:00
|
|
|
char owner[USER_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
enum key_operation owner_operation;
|
2004-11-29 19:44:01 +07:00
|
|
|
char group[USER_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
enum key_operation group_operation;
|
2004-11-29 19:44:01 +07:00
|
|
|
mode_t mode;
|
2005-06-05 09:57:03 +07:00
|
|
|
enum key_operation mode_operation;
|
2005-04-02 22:45:35 +07:00
|
|
|
char run[PATH_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
enum key_operation run_operation;
|
2005-02-14 12:03:06 +07:00
|
|
|
|
2005-03-13 04:55:08 +07:00
|
|
|
int last_rule;
|
2005-02-14 12:03:06 +07:00
|
|
|
int ignore_device;
|
2004-11-13 20:43:24 +07:00
|
|
|
int ignore_remove;
|
2005-03-13 04:55:08 +07:00
|
|
|
int partitions;
|
2005-02-14 12:03:06 +07:00
|
|
|
|
2005-03-07 10:29:43 +07: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 12:53:20 +07:00
|
|
|
int config_line;
|
2003-12-04 09:33:58 +07:00
|
|
|
};
|
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
extern struct list_head udev_rule_list;
|
2003-07-24 05:56:56 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
extern int udev_rules_init(void);
|
|
|
|
extern int udev_rules_get_name(struct udevice *udev, struct sysfs_class_device *class_dev);
|
2005-06-05 20:55:29 +07:00
|
|
|
extern int udev_rules_get_run(struct udevice *udev, struct sysfs_device *sysfs_device);
|
2005-03-13 04:36:32 +07:00
|
|
|
extern void udev_rules_close(void);
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2003-07-17 15:24:51 +07:00
|
|
|
#endif
|