Systemd/udev.h
kay.sievers@vrfy.org 54988802b7 [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
2005-04-26 21:13:17 -07:00

73 lines
1.9 KiB
C

/*
* 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 02139, USA.
*
*/
#ifndef UDEV_H
#define UDEV_H
#include "libsysfs/libsysfs.h"
#include <sys/param.h>
#define COMMENT_CHARACTER '#'
#define NAME_SIZE 100
#define OWNER_SIZE 30
#define GROUP_SIZE 30
struct udevice {
char name[NAME_SIZE];
char owner[OWNER_SIZE];
char group[GROUP_SIZE];
char type;
int major;
int minor;
mode_t mode;
char symlink[NAME_SIZE];
/* fields that help us in building strings */
unsigned char bus_id[SYSFS_NAME_LEN];
unsigned char program_result[NAME_SIZE];
unsigned char kernel_number[NAME_SIZE];
unsigned char kernel_name[NAME_SIZE];
};
#define strfieldcpy(to, from) \
do { \
to[sizeof(to)-1] = '\0'; \
strncpy(to, from, sizeof(to)-1); \
} while (0)
extern int udev_add_device(char *path, char *subsystem);
extern int udev_remove_device(char *path, char *subsystem);
extern void udev_init_config(void);
extern char **main_argv;
extern char **main_envp;
extern char sysfs_path[SYSFS_PATH_MAX];
extern char udev_root[PATH_MAX];
extern char udev_db_filename[PATH_MAX+NAME_MAX];
extern char udev_permissions_filename[PATH_MAX+NAME_MAX];
extern char udev_config_filename[PATH_MAX+NAME_MAX];
extern char udev_rules_filename[PATH_MAX+NAME_MAX];
extern char default_mode_str[NAME_MAX];
#endif