IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
On Sun, Jan 18, 2004 at 07:30:50AM +0100, Kay Sievers wrote:
> Hi,
> here is a small program to query all attributes of a device and
> print these in the udev key format. It may help to get the keys to
> define a rule.
Fixed a typo - the sysfs_device is right now.
USB FLash Reader:
kay@pim:~/src/udev.kay$ extras/udevinfo/udevinfo /sys/block/sda/sda1
device '/sys/block/sda/sda1' has major:minor 8:1
looking at class device '/sys/block/sda/sda1':
SYSFS_dev="8:1"
SYSFS_start="32"
SYSFS_size="160"
SYSFS_stat=" 0 0 0 0"
follow class device's "device" link '/sys/block/sda':
BUS="scsi"
ID="57:0:0:0"
SYSFS_detach_state="0"
SYSFS_type="0"
SYSFS_device_blocked="0"
SYSFS_queue_depth="1"
SYSFS_scsi_level="3"
SYSFS_vendor="SMSC "
SYSFS_model="USB 2 HS-CF"
SYSFS_rev="1.25"
SYSFS_online="1"
I've edited the man page today, so this is alreay included :)
Also a few more trivials:
o added the defaults to udev.conf.in
o removed class_dev from get_default_mode(), to match with Hanna's
o changed size of mode_str to MODE_SIZE
o changed a few char compares from from 0x00 to '\0'
This patch fixes a bug where the udev database stored empty strings
for Owner and Group if they were default. This patch stores the default
value into the database if not set otherwise. See example output:
crw------- 1 root root 4, 65 Jan 16 11:13 ttyS1
P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root
This is a bit of a hack. However, until udev supports setting the
o/g values they will be root/root anyway so the database might as
well reflect the truth instead of empty strings.
Here we get the ability to query with the name of the node instead of
the device path. It uses a linear search over the whole database.
kay@pim:~/src/udev.kay$ ./udev -q path -n video/webcam0
/class/video4linux/video0
New version, with better function return codes for error handling.
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
I've attached a patch that adds a few rules to udev.rules.devfs, making it
look a little more like devfs on my system. (I have the sysfs patches from
2.6.1-rc1-mm2) I added rules for oss, misc, floppy, and input devices. The
oss rules look like trouble with a wildcard at the end of each name, but I'm
not sure how I can make it any better.
Devfs has a bunch of other devices in the floppy directory for floppies
formatted in unusual ways, but I don't see them in udev. Not that I ever used
them, since they're usually automatically detected.
On Mon, Jan 12, 2004 at 05:04:45PM -0800, Greg KH wrote:
> Very nice, applied. But I did have to make one small change to get the
> code to build properly with klibc:
>
> > +static void print_record(char *path, struct udevice *dev)
> > +{
> > + printf("P: %s\n", path);
> > + printf("N: %s\n", dev->name);
> > + printf("S: %s\n", dev->symlink);
> > + printf("O: %s\n", dev->owner);
> > + printf("G: %s\n", dev->group);
> > + printf("\n");
> > +}
>
> Turns out that gcc likes to convert single character printf() calls to
> putchar() which is only defined in klibc as a macro :(
Just for information. This seems to fix the gcc with klibc :)
Optimize the scripts reflecting the now more powerful rule logic,
cause we can combine all known fields now in any order:
The ide-devfs.sh is only executed if the kernel name matches with 'hd*':
BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c"
The name_cdrom.pl is only executed for ide and scsi devices, but not for a partition.
It exits with nonzero to skip the rule if the CD is not found:
KERNEL="[hs]d[a-z]", PROGRAM="name_cdrom.pl %M %m", NAME="%1c", SYMLINK="cdrom"
This patch adds a '%' to the format char list, so that a external
program may called with a non expanded '%' like:
PROGRAM="/bin/date +%%s"
Olaf Hering asked for the feature.
A tricky test is also added :)
> Hi,
> as promised yesterday, here is a patch that drops the explicit methods
> given in the udev config and implement only one type of rule.
>
> A rule now consists only of a number of keys to match. All known keys
> are valid in any combination. The former configs should work with a few
> changes:
>
> o the "<METHOD>, " at the beginning of the line should be removed
>
> o the result of the externel program is matched with RESULT= instead if ID=
> the PROGRAM= key is only valid if the program exits with zero
> (just exit with nozero in a script if the rule should not match)
>
> o rules are processed in order they appear in the file, no priority
>
> o if NAME="" is given, udev is instructed to ignore this device,
> no node will be created
>
>
> EXAMPLE:
>
> # combined BUS, SYSFS and KERNEL
> BUS="usb", KERNEL="video*", SYSFS_model="Creative Labs WebCam*", NAME="test/webcam%n"
>
> # exec script only for the first ide drive (hda), all other will be skipped
> BUS="ide", KERNEL="hda*", PROGRAM="/home/kay/src/udev.kay/extras/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%1c", SYMLINK="%2c %3c"
>
>
> The udev-test.pl and test.block works fine here.
> Please adapt your config and give it a try.
>
Here is a slightly better version of the patch.
After a conversation with Patrick, we are now able to execute the PROGRAM
and also match in all following rules with the RESULT value from this exec.
EXAMPLE:
We have 7 rules with RESULT and 2 with PROGRAM.
Only the 5th rule matches with the callout result from the exec in the 4th rule.
RULES:
PROGRAM="/bin/echo abc", RESULT="no_match", NAME="web-no-2"
KERNEL="video*", RESULT="123", NAME="web-no-3"
KERNEL="video*", RESULT="123", NAME="web-no-4"
PROGRAM="/bin/echo 123", RESULT="no_match", NAME="web-no-5"
KERNEL="video*", RESULT="123", NAME="web-yes"
RESULT:
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM
Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo abc'
Jan 11 23:36:52 pim udev[26050]: execute_program: result is 'abc'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='abc'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM
Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo 123'
Jan 11 23:36:52 pim udev[26050]: execute_program: result is '123'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='123'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='123'
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT matches
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: found matching rule, 'video*' becomes ''
Jan 11 23:36:52 pim udev[26050]: namedev_name_device: name, 'web-yes' is going to have owner='', group='', mode = 0600
This patch improves the user options for udev.
It is possible now to query for the name, the symlinks or owner/group.
If asked for the name of the node we are able to prepend the udev_root
with the -r option.
SAMPLE:
kay@pim:~/src/udev.test$ ./udev -V
udev, version 012_bk
kay@pim:~/src/udev.test$ ./udev -h
Usage: [-qrVh]
-q <name> query database for the specified value
-p <path> device path used for query
-r print udev root
-V print udev version
-h print this help text
kay@pim:~/src/udev.test$ ./udev -r
/udev/
kay@pim:~/src/udev.test$ ./udev -q name -p /class/video4linux/video0
video/webcam0
kay@pim:~/src/udev.test$ ./udev -q symlink -p /class/video4linux/video0
camera0 kamera0
kay@pim:~/src/udev.test$ ./udev -q owner -p /class/video4linux/video0
501
kay@pim:~/src/udev.test$ ./udev -r -q name -p /class/video4linux/video0
/udev/video/webcam0
I get the following error on install:
pim:/home/kay/src/udev.test# make install
sed -e "s:@udevdir@:/udev:" < etc/udev/udev.conf.in > etc/udev/udev.conf
/usr/bin/install -c -d /etc/udev/
/usr/bin/install -c -d /udev
/usr/bin/install -c -d /etc/hotplug.d/default
/usr/bin/install -c -D udev /sbin/udev
/bin/sh: -c: line 2: syntax error: unexpected end of file
make: *** [install] Error 2
I had too much time during the holidays, so I played a bit with udev. The
changes are like last time mostly on the init stuff. I'm sending you this as
a great diff which is just for comments.
What it does:
-fix a typo in Makefile
-use only one "grep -v" instead of many
-don't include BK-Files into release (shrinks the stuff to 30%!)
-add a new init script which is LSB compliant
-add some flags to choose which one to use
-use /etc/udev/udev.conf in Redhat init script as the source for the udev
directory. If this is not done then the init script may create a directory
which udev itself isn't using (I changed /udev to /Udev to avoid collisions
with /usr and ran into this)
-first check for sysfs_dir before creating udev_root (maybe someone else has
already fixed this, I saw this discussion on lkml)