2005-04-27 10:59:47 +07:00
|
|
|
/*
|
|
|
|
* udev.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
|
2005-03-05 03:33:57 +07:00
|
|
|
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
|
2005-04-27 10:59:47 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-03-23 13:22:20 +07:00
|
|
|
#ifndef _UDEV_H_
|
|
|
|
#define _UDEV_H_
|
2005-04-27 10:59:47 +07:00
|
|
|
|
2005-02-09 10:37:32 +07:00
|
|
|
#include <sys/types.h>
|
2003-12-02 15:26:46 +07:00
|
|
|
#include <sys/param.h>
|
2004-03-23 13:22:20 +07:00
|
|
|
#include "libsysfs/sysfs/libsysfs.h"
|
2005-02-21 20:48:12 +07:00
|
|
|
#include "list.h"
|
2005-04-27 10:59:47 +07:00
|
|
|
|
2003-12-03 16:08:46 +07:00
|
|
|
#define COMMENT_CHARACTER '#'
|
2005-11-16 10:14:15 +07:00
|
|
|
#define PATH_TO_NAME_CHAR '@'
|
2005-03-05 03:13:18 +07:00
|
|
|
#define LINE_SIZE 512
|
2005-03-07 10:29:43 +07:00
|
|
|
#define NAME_SIZE 128
|
|
|
|
#define PATH_SIZE 256
|
2004-11-29 19:44:01 +07:00
|
|
|
#define USER_SIZE 32
|
2004-09-05 23:05:29 +07:00
|
|
|
#define SEQNUM_SIZE 32
|
2005-03-07 10:29:43 +07:00
|
|
|
#define VALUE_SIZE 128
|
2004-02-27 10:40:32 +07:00
|
|
|
|
2005-02-09 14:43:18 +07:00
|
|
|
#define DEFAULT_PARTITIONS_COUNT 15
|
2005-11-07 08:22:44 +07:00
|
|
|
#define UDEV_ALARM_TIMEOUT 180
|
2005-02-09 14:43:18 +07:00
|
|
|
|
2005-11-16 10:14:15 +07:00
|
|
|
#define DB_DIR ".udev/db"
|
|
|
|
|
2005-07-22 23:35:58 +07:00
|
|
|
struct udev_rules;
|
|
|
|
|
2005-02-21 19:45:04 +07:00
|
|
|
enum device_type {
|
2005-03-13 03:41:57 +07:00
|
|
|
DEV_UNKNOWN,
|
|
|
|
DEV_CLASS,
|
|
|
|
DEV_BLOCK,
|
|
|
|
DEV_NET,
|
|
|
|
DEV_DEVICE,
|
2005-02-21 19:45:04 +07:00
|
|
|
};
|
|
|
|
|
2003-10-21 12:48:44 +07:00
|
|
|
struct udevice {
|
2005-03-07 10:29:43 +07:00
|
|
|
char devpath[PATH_SIZE];
|
|
|
|
char subsystem[NAME_SIZE];
|
2005-04-02 22:45:35 +07:00
|
|
|
char action[NAME_SIZE];
|
2004-11-29 08:15:55 +07:00
|
|
|
|
2005-03-13 03:41:57 +07:00
|
|
|
enum device_type type;
|
2005-03-07 10:29:43 +07:00
|
|
|
char name[PATH_SIZE];
|
|
|
|
char devname[PATH_SIZE];
|
2005-03-05 11:35:31 +07:00
|
|
|
struct list_head symlink_list;
|
2005-06-05 09:57:03 +07:00
|
|
|
int symlink_final;
|
2004-11-29 19:44:01 +07:00
|
|
|
char owner[USER_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
int owner_final;
|
2004-11-29 19:44:01 +07:00
|
|
|
char group[USER_SIZE];
|
2005-06-05 09:57:03 +07:00
|
|
|
int group_final;
|
2004-11-29 08:15:55 +07:00
|
|
|
mode_t mode;
|
2005-06-05 09:57:03 +07:00
|
|
|
int mode_final;
|
2005-02-21 19:44:39 +07:00
|
|
|
dev_t devt;
|
2005-04-02 22:45:35 +07:00
|
|
|
struct list_head run_list;
|
2005-06-05 09:57:03 +07:00
|
|
|
int run_final;
|
2005-06-26 23:55:24 +07:00
|
|
|
struct list_head env_list;
|
2004-11-29 08:15:55 +07:00
|
|
|
|
2005-03-07 10:29:43 +07:00
|
|
|
char tmp_node[PATH_SIZE];
|
2004-02-17 12:44:28 +07:00
|
|
|
int partitions;
|
2005-04-02 22:45:35 +07:00
|
|
|
int ignore_device;
|
2004-11-13 20:43:24 +07: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 09:24:25 +07:00
|
|
|
int config_line;
|
2005-03-07 10:29:43 +07:00
|
|
|
char config_file[PATH_SIZE];
|
|
|
|
char bus_id[NAME_SIZE];
|
|
|
|
char program_result[PATH_SIZE];
|
2004-02-13 13:51:44 +07:00
|
|
|
char kernel_number[NAME_SIZE];
|
|
|
|
char kernel_name[NAME_SIZE];
|
2004-10-19 09:11:51 +07:00
|
|
|
int test_run;
|
2003-10-21 12:48:44 +07:00
|
|
|
};
|
|
|
|
|
2005-07-22 23:35:58 +07:00
|
|
|
extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action);
|
|
|
|
extern void udev_cleanup_device(struct udevice *udev);
|
2005-11-12 10:17:48 +07:00
|
|
|
extern dev_t get_devt(struct sysfs_class_device *class_dev);
|
2005-07-22 23:35:58 +07:00
|
|
|
extern int udev_process_event(struct udev_rules *rules, struct udevice *udev);
|
2004-10-19 09:11:51 +07: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 16:08:46 +07: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 14:50:21 +07:00
|
|
|
extern int udev_start(void);
|
2005-02-21 19:44:39 +07: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 10:04:38 +07:00
|
|
|
|
2005-11-16 10:14:15 +07:00
|
|
|
extern int udev_db_add_device(struct udevice *dev);
|
|
|
|
extern int udev_db_delete_device(struct udevice *dev);
|
|
|
|
extern int udev_db_get_device(struct udevice *udev, const char *devpath);
|
|
|
|
extern int udev_db_lookup_name(const char *name, char *devpath, size_t len);
|
|
|
|
extern int udev_db_get_all_entries(struct list_head *name_list);
|
|
|
|
|
2005-03-07 10:29:43 +07:00
|
|
|
extern char sysfs_path[PATH_SIZE];
|
|
|
|
extern char udev_root[PATH_SIZE];
|
|
|
|
extern char udev_config_filename[PATH_SIZE];
|
|
|
|
extern char udev_rules_filename[PATH_SIZE];
|
2005-03-27 06:11:03 +07:00
|
|
|
extern int udev_log_priority;
|
2005-04-02 22:45:35 +07:00
|
|
|
extern int udev_run;
|
2003-10-22 10:19:09 +07:00
|
|
|
|
2005-04-27 10:59:47 +07:00
|
|
|
#endif
|