Skip to contentSkip to conversation

+rule: query device inode by Major and Minor - am i inventing brand

DISCUSSION Arioch 3 participants 11 messages Aug 15, 2005 – Aug 18, 2005

lore
Share & tools
lore

Arioch

author
#0 lore raw

Hello!

I made (and attached) a tiny rule, and hope it will be interesting to some of you. See attach.
Rule is very simple ( i think someone already did that, but i'm just offline and cannot check it )

I made it with two thought in background:

1) Some drivers with incomplete SYSFS support (namely, wbsd on my box) publiches major and minor, but not the device inode name :-( If i wantr to find it from script - how ? ls -lR | grep ? BRR! :-) Hate RegExp's :-)

2) On my box pktsetup (packet-mode CD-RW burning helper, part of udfhelper) creates two block device per drive! I wanted to catch this.
After all it seems that it creates second inode by mknod, not kernel call and UDEV. But surprisingly i saw a number of other duplicate inodes with the identical major-minor

So, as i want to be famous, would You, please, considering including this rule into UDEV examples ? :-)

Ouugh, almost forgot to state a wish:
Can there be on more key for rules ?
Similar to RETURN, but matching not string form stdout, but the return code of program ( $? ) ?

Why - cause i wanted to do if/else/then.
I run a program to check if a symlink already exists - then i run another program to check if it does not exists !

And i cannot use /bin/ls or /bin/readlink and then use RESULT - it puts its output onto stderr if file not found, which seems to make UDEV ignore that rule inn the future (i could not find this in man, but i guess it is said somewhere on some wiki - but i'm still offline) . As well, stderr is not intercepted and user sees that unpretty sign of my sillyness :) And i didn't want to create a separate file (bash script) for such a simple task.

To end this mindflow, if i mentioned man's, i'd like to say that i saw a typo in the "man udev".
When describing "=" operation, there is word "iNplicit" instead of "iMplicit". If it is not my English - it is is a typo :-)

Good luck and thank you all !

# mailto:[email protected], xmpp:[email protected]
#
# I want to be able to easily look for dev name by major and minor numbers
# for example - from scripts
# So i think of having dedicated folder for symlinks to devices
#
# I should check that symlinks are not overwitten - i saw udftools' pktsetup
# created 2 block dev-inodes per drive !
# After all, pktsetup creates its fantom by direct mknod w/o udev interaction,
# but i found a number of other dups

# PROGRAM="/bin/sh -c ' [ -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/DUP/major%M@minor%m_DUP%e"

# this rule makes easy check if any duplicate exist - dups are stored in separate dir
# enter with Midnight Commander / Nautilu / Konqueror etc - and if You can see DUP folder...

PROGRAM="/bin/sh -c ' [ -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/DUP/major%M@minor%m_DUP%e"

# this rule makes easy matching - scroll through symlinks - and all DUPs and 1st link are together

PROGRAM="/bin/sh -c ' [ ! -e %r/.lookup_by_numbers/major%M@minor%m ] ' ", SYMLINK+=".lookup_by_numbers/major%M@minor%m"

#1 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing brand new bycicle ?

Quoted 10 lines · Arioch

I made (and attached) a tiny rule, and hope it will be interesting to some of you.
See attach.

I made it with two thought in background:

1) Some drivers with incomplete SYSFS support (namely, wbsd on my box) publiches major and minor, but not the device inode name :-( If i wantr to find it from script - how ? ls -lR | grep ? BRR! :-) Hate RegExp's :-)

You mean the device 'node', the file in /dev, right?
What does publish major/minor mean? That the driver does not create an entry in /sys/block/*?

Quoted 5 lines

2) On my box pktsetup (packet-mode CD-RW burning helper, part of udfhelper) creates two block device per drive! I wanted to catch this. After all it seems that it creates second inode by mknod, not kernel call and UDEV. But surprisingly i saw a number of other duplicate inodes with the identical major-minor

What nodes exactly have the same major/minor? That setup may need to be fixed.

Quoted 2 lines

So, as i want to be famous, would You, please, considering including this rule into UDEV examples ? :-)

We don't provide a dead example file anymore. Nobody cared about that file, it was outdated and some people expected this as "the default" udev file and complained about the entries, so I just deleted it. Instead we carry a lot of distro rules as examples now. So you need to convince a distro to ship your rule to get it included. Good luck! :)

Quoted 4 lines

Ouugh, almost forgot to state a wish:
Can there be on more key for rules ?
Similar to RETURN, but matching not string form stdout, but the return code of program ( $? ) ?

You mean similar to "RESULT"?

Quoted 3 lines

Why - cause i wanted to do if/else/then.
I run a program to check if a symlink already exists - then i run another program to check if it does not exists !

PROGRAM!="..." should catch non-zero exit's. You also can jump with GOTO="..." to a LABEL="..." line (see the persistent disk rules examples).

Quoted 8 lines

And i cannot use /bin/ls or /bin/readlink and then use RESULT - it puts its output onto stderr if file not found, which seems to make UDEV ignore that rule inn the future (i could not find this in man, but i guess it is said somewhere on some wiki - but i'm still offline) . As well, stderr is not intercepted and user sees that unpretty sign of my sillyness :)
And i didn't want to create a separate file (bash script) for such a simple task.

Yes stderr is ignored. You will need to fork a shell for that to catch.

Quoted 4 lines

To end this mindflow, if i mentioned man's, i'd like to say that i saw a typo in the "man udev".
When describing "=" operation, there is word "iNplicit" instead of "iMplicit". If it is not my English - it is is a typo :-)

Will fix that. Thanks!

Thanks,
Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#2 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

Kay Sievers пишет:

Quoted 9 lines · Arioch
Quoted 8 lines

I made (and attached) a tiny rule, and hope it will be interesting to some of you.
See attach.

I made it with two thought in background:

Quoted 7 lines
Quoted 4 lines

1) Some drivers with incomplete SYSFS support (namely, wbsd on my box) publiches major and minor, but not the device inode name :-( If i wantr to find it from script - how ? ls -lR | grep ? BRR! :-) Hate RegExp's :-)

You mean the device 'node', the file in /dev, right?

exactly.

Quoted 1 line

What does publish major/minor mean?

That mean by crawling through /sys i can learn what is major and minor for some dev-file. Yet the very name of the file is not the thing i can find in /SYS - since SYSFS is not the layer that creates such devices, and there seems to be no method, UDEV will tell device file name, and SYSFS would hear it and represent under /sys.

Quoted 3 lines

That the driver does not create an
entry in /sys/block/*?

AS: eraly drivers is only one example, where i want to find file under /dev, knowing only its major and minor. There can be more situations.

wbsd is driver for SD/MMC flash cards reader.
When i insert MMC card, it (or mmc-core.ko, or mmc-block.ko ) creates block devices /dev/mmcblk0 and /dev/mmcblk0p1 - for 1st (and only) partition. The very controller is not block device yet. There are SDIO cards, which, like CardBus ones, are devices, rather than disks.

zsh 4 % ls /sys/module/wbsd
parameters refcnt sections
zsh 5 % ls /sys/bus/pnp/drivers/wbsd -l
@00:07 -> ../../../../devices/pnp0/00:07

zsh 6 % ls /sys/bus/pnp/drivers/wbsd/00:07
bus driver id options power resources

This is without MMC card. With card there is added folder mmc0:0001 Yahoo! yesterday i updated kernel to 2.6.12 and driver seems to got updated too.

But ...

zsh/2 17 % pwd /sys/bus/pnp/drivers/wbsd/00:07/mmc0:0001/block zsh/2 18 % ls
dev device mmcblk0p1 queue range removable size stat zsh/2 20 % cat removable
0 # - WOW !!!!
zsh/2 19 % cat dev
253:0

That's all.

Since UDEV can move and rename device inodes wherever and however it is configured - how should i find it ?
At my box, for example, those devices are /dev/mmcblk0* - they are not moved into /dev/disks subfoolder to my HDD, nor to /dev/cdroms. I have not ZIP drive now and cannot check which device node it would be mapped to.

IMHO old FDD, ZIP and alike devices, memory cards (CF, MMC, USB flash drives) and even CD-RW in packet burning mode - they are same kind of
devices: block and removable. I wonder where they are to be grouped :-)

Quoted 8 lines
Quoted 5 lines

2) On my box pktsetup (packet-mode CD-RW burning helper, part of udfhelper) creates two block device per drive! I wanted to catch this. After all it seems that it creates second inode by mknod, not kernel call and UDEV. But surprisingly i saw a number of other duplicate inodes with the identical major-minor

What nodes exactly have the same major/minor? That setup may need to be fixed.

For now i put this in my distro bugzilla and hope it will get some attention in proper time.

This design might be affecting only my distro.

Out of my head - i saw a number of logs, sharing numbers with ram disks.

Did You tested those rules ? You can see, they are harmless and only add
a couple of symlinks. Next time You'd boot Your box (or if it is no
danger to You - service udevd restart) - You would know about Your system :-)

Quoted 8 lines
Quoted 2 lines

So, as i want to be famous, would You, please, considering including this rule into UDEV examples ? :-)

We don't provide a dead example file anymore. Nobody cared about that file, it was outdated and some people expected this as "the default" udev file and complained about the entries, so I just deleted it. Instead we carry a lot of distro rules as examples now. So you need to convince a distro to ship your rule to get it included. Good luck! :)

...and it would be distro-local ?

Guess, there i s to be some wiki or something of a kind. In such a place, different distro's could publish their rules and compare the benefits.

Or perhaps LSB is to care of those rules ?

Quoted 8 lines
Quoted 4 lines

Ouugh, almost forgot to state a wish:
Can there be on more key for rules ?
Similar to RETURN, but matching not string form stdout, but the return code of program ( $? ) ?

You mean similar to "RESULT"?

Sure, i was typing RESULT, but was thinking of RETURN CODE :-)

Quoted 7 lines
Quoted 3 lines

Why - cause i wanted to do if/else/then.
I run a program to check if a symlink already exists - then i run another program to check if it does not exists !

PROGRAM!="..." should catch non-zero exit's. You also can jump with GOTO="..." to a LABEL="..." line (see the persistent disk rules examples).

Where can i find such rules, if You do not ship Your own rulesets ? Article of righting UDEV rule is ether too basic or too outdated - there even no word about "+=" (Hmmm, how about -= ? :D )

PROGRAM != - is not solution.

Please, look at my rules. There're just two rules in the file. And they represent if-then-else choice.

If i would negate if-condition - i just swap then and else - but do not get rid of them. I still have to run the program twice, since in later rule i cannot refer to retcode of PROGRAM in prior rule.

I just do not want to run the program twice, nor to make quite dumb and auxillary script.

Quoted 1 line

Yes stderr is ignored. You will need to fork a shell for that to catch.

But since i cannot escape \" in PROGRAM argument (and i already used single quotes) - that makes pain :-)

To my experience, stderr output is
1) sent to user's tty
2) signals to UDEV to not try this rule any more (at list i saw that
output once, while otherwise i should see it for every device)

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#3 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

Kay Sievers пишет:

Quoted 2 lines

What nodes exactly have the same major/minor? That setup may need to be fixed.

Now i think that %M and %m macros are expanded somehow strangely:

$ pwd
/dev/.lookup_by_numbers

$for i in DUP/* ; do j=${i#*/}; h=${j%_*}; ls -l $h $i ; echo; done

[... list skipped - there is longer and more detailed one below ...]

I was intrigued by duplicating of /dev/null.
Was this device created twice ???

$ls -l ../ram3 ../nu*
crw-rw-rw- 1 root root 1, 3 Авг 16 19:47 ../null
brw-rw---- 1 root disk 1, 3 Авг 16 19:47 ../ram3

You see, it seems character and block devices with same major|minor can easily co-exist!

$for i in {1,2,3,4,5}; do ls ../hda$i ../pty/s$i -l ; done

brw-rw----  1 root root 3,   1 Авг 16 19:47 ../hda1
crw-rw----  1 root tty  3, 161 Авг 16 19:47 ../pty/s1
brw-rw----  1 root root 3,   2 Авг 16 19:47 ../hda2
crw-rw----  1 root tty  3, 162 Авг 16 19:47 ../pty/s2
brw-rw----  1 root root 3,   3 Авг 16 19:47 ../hda3
crw-rw----  1 root tty  3, 163 Авг 16 19:47 ../pty/s3
brw-rw----  1 root root 3,   4 Авг 16 19:47 ../hda4
crw-rw----  1 root tty  3, 164 Авг 16 19:47 ../pty/s4
brw-rw----  1 root root 3,   5 Авг 16 19:47 ../hda5

You see, on one hand we again see mixing block and char devices. On the othe hands, it seems that when %m was expanded - it subtrcted 160 from it's value. 160=32*5 - so was minor masked with 2:00011111 ?

Or can major|minor be silently changed later, after symlink already created ?

To be more generic, and more longer

    $for i in  DUP/*  ; do j=${i#*/}; h=${j%_*}; ls -l $i ;ls -l 

readlink -e $i; ls -l $h; ls -l readlink -e $h; echo; done

lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor11_DUP -> ../../kmsg
crw-rw----  1 root root 1, 11 Авг 16 19:47 /dev/kmsg
lrwxrwxrwx  1 root root 8 Авг 16 19:47 major1@minor11 -> ../ram11
brw-rw----  1 root disk 1, 11 Авг 16 19:47 /dev/ram11
lrwxrwxrwx  1 root root 9 Авг 16 19:47 DUP/major1@minor1_DUP -> ../../mem
crw-r-----  1 root root 1, 1 Авг 16 19:47 /dev/mem
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor1 -> ../ram1
brw-rw----  1 root disk 1, 1 Авг 16 19:47 /dev/ram1
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor2_DUP -> ../../kmem
crw-r-----  1 root root 1, 2 Авг 16 19:47 /dev/kmem
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor2 -> ../ram2
brw-rw----  1 root disk 1, 2 Авг 16 19:47 /dev/ram2
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor3_DUP -> ../../ram3
brw-rw----  1 root disk 1, 3 Авг 16 19:47 /dev/ram3
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor3 -> ../null
crw-rw-rw-  1 root root 1, 3 Авг 16 19:47 /dev/null
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor3_DUP1 -> ../../null
crw-rw-rw-  1 root root 1, 3 Авг 16 19:47 /dev/null
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor3 -> ../null
crw-rw-rw-  1 root root 1, 3 Авг 16 19:47 /dev/null
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor4_DUP -> ../../port
crw-r-----  1 root root 1, 4 Авг 16 19:47 /dev/port
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor4 -> ../ram4
brw-rw----  1 root disk 1, 4 Авг 16 19:47 /dev/ram4
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor5_DUP -> ../../zero
crw-rw-rw-  1 root root 1, 5 Авг 16 19:47 /dev/zero
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor5 -> ../ram5
brw-rw----  1 root disk 1, 5 Авг 16 19:47 /dev/ram5
lrwxrwxrwx  1 root root 10 Авг 16 19:47 DUP/major1@minor7_DUP -> ../../full
crw-rw-rw-  1 root root 1, 7 Авг 16 19:47 /dev/full
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor7 -> ../ram7
brw-rw----  1 root disk 1, 7 Авг 16 19:47 /dev/ram7

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major1@minor8_DUP -> ../../random

crw-rw-rw-  1 root root 1, 8 Авг 16 19:47 /dev/random
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor8 -> ../ram8
brw-rw----  1 root disk 1, 8 Авг 16 19:47 /dev/ram8

lrwxrwxrwx 1 root root 13 Авг 16 19:47 DUP/major1@minor9_DUP -> ../../urandom

cr--r--r--  1 root root 1, 9 Авг 16 19:47 /dev/urandom
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major1@minor9 -> ../ram9
brw-rw----  1 root disk 1, 9 Авг 16 19:47 /dev/ram9

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor0_DUP -> ../../pty/s0

crw-rw----  1 root tty 3, 160 Авг 16 19:47 /dev/pty/s0
lrwxrwxrwx  1 root root 6 Авг 16 19:47 major3@minor0 -> ../hda
brw-rw----  1 root root 3, 0 Авг 16 19:47 /dev/hda

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor1_DUP -> ../../pty/s1

crw-rw----  1 root tty 3, 161 Авг 16 19:47 /dev/pty/s1
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major3@minor1 -> ../hda1
brw-rw----  1 root root 3, 1 Авг 16 19:47 /dev/hda1

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor2_DUP -> ../../pty/s2

crw-rw----  1 root tty 3, 162 Авг 16 19:47 /dev/pty/s2
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major3@minor2 -> ../hda2
brw-rw----  1 root root 3, 2 Авг 16 19:47 /dev/hda2

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor3_DUP -> ../../pty/s3

crw-rw----  1 root tty 3, 163 Авг 16 19:47 /dev/pty/s3
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major3@minor3 -> ../hda3
brw-rw----  1 root root 3, 3 Авг 16 19:47 /dev/hda3

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor4_DUP -> ../../pty/s4

crw-rw----  1 root tty 3, 164 Авг 16 19:47 /dev/pty/s4
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major3@minor4 -> ../hda4
brw-rw----  1 root root 3, 4 Авг 16 19:47 /dev/hda4

lrwxrwxrwx 1 root root 12 Авг 16 19:47 DUP/major3@minor5_DUP -> ../../pty/s5

crw-rw----  1 root tty 3, 165 Авг 16 19:47 /dev/pty/s5
lrwxrwxrwx  1 root root 7 Авг 16 19:47 major3@minor5 -> ../hda5
brw-rw----  1 root root 3, 5 Авг 16 19:47 /dev/hda5

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#4 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

So, it seems that there are two misfeatures:
UDEV does not provide block/char %-macro, like it does with %M and %m

And something strange happened to /dev/pty/* - minors like 16? were truncated to last number in %m :-(

BTW, since udevtest needs to be tolf of block/character device type, does it mean, that sysfs does not export this info ?

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing brand new bycicle ?

In reply to Arioch
Quoted 2 lines · Arioch

So, it seems that there are two misfeatures:
UDEV does not provide block/char %-macro, like it does with %M and %m

No, it doesn't. But you can use a script or make different rules that match against SUBSYSTEM="block" or DEVPATH="/block/*" ...

Quoted 2 lines

And something strange happened to /dev/pty/* - minors like 16? were truncated to last number in %m :-(

No idea! Better get rid of the dead devfs scheme. :)

Quoted 2 lines

BTW, since udevtest needs to be tolf of block/character device type, does it mean, that sysfs does not export this info ?

DEVPATH=/block/* are block nodes, DEVPATH=/class/* are char nodes. That information is only in the path of the device not in the "dev" file.

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#6 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

Kay Sievers пишет:

Quoted 5 lines
Quoted 2 lines

And something strange happened to /dev/pty/* - minors like 16? were truncated to last number in %m :-(

No idea! Better get rid of the dead devfs scheme. :)

That scheme has its advantages.

For example, kppp doesn't know my modem and i need to make symlink /dev/modem -> /dev/ttySLM0 after each boot.
If all modems could be found in /dev/dialup, then there was no this trouble ;)

And at least that should not affect %m value :-P

Quoted 7 lines
Quoted 3 lines

BTW, since udevtest needs to be tolf of block/character device type, does it mean, that sysfs does not export this info ?

DEVPATH=/block/* are block nodes, DEVPATH=/class/* are char nodes. That information is only in the path of the device not in the "dev" file.

If that is so simple, i wonder why udevtest requests subsystem as a parameter? I'm looking at article "How to write udev rules" v.0.6 - and there udevtest is runned with the only param.

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing brand new bycicle ?

In reply to Arioch
Quoted 19 lines · Arioch

Kay Sievers ??????????:

Quoted 2 lines

What nodes exactly have the same major/minor? That setup may need to be fixed.

Now i think that %M and %m macros are expanded somehow strangely:

$ pwd
/dev/.lookup_by_numbers

$for i in DUP/* ; do j=${i#*/}; h=${j%_*}; ls -l $h $i ; echo; done

[... list skipped - there is longer and more detailed one below ...]

I was intrigued by duplicating of /dev/null.
Was this device created twice ???

Quoted 6 lines

$ls -l ../ram3 ../nu*
crw-rw-rw- 1 root root 1, 3 ?????? 16 19:47 ../null brw-rw---- 1 root disk 1, 3 ?????? 16 19:47 ../ram3

You see, it seems character and block devices with same major|minor can easily co-exist!

Of course they can. For further examples, see Documentation/devices.txt for all of the reserved major/minor numbers for character and block devices. Remember, character and block devices are totally separate "namespaces". The major/minor number is only unique within a character, or a block "namespace".

thanks,

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#8 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

Greg KH пишет:

Quoted 5 lines
Quoted 2 lines

You see, it seems character and block devices with same major|minor can easily co-exist!

Of course they can. For further examples, see Documentation/devices.txt

Thanks. I was already pointed too.

Quoted 4 lines

for all of the reserved major/minor numbers for character and block devices. Remember, character and block devices are totally separate "namespaces". The major/minor number is only unique within a character, or a block "namespace".

But now, when UDEV seems toconfigure network devices as well, how can i distinguish them ?
SUBSYSTEM=="block" - that is to tell block devices.
But what should tell character devices from, say, network interfaces ? eth0 should have no major and minor, but trying to catch it makes rule more and more complex.
Alas, i don't know where to et list of subsystems :-(

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#9 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing brand new bycicle ?

In reply to Arioch
Quoted 4 lines · Arioch

But now, when UDEV seems toconfigure network devices as well, how can i distinguish them ?
SUBSYSTEM="block" - that is to tell block devices.
But what should tell character devices from, say, network interfaces ?

Perhaps SUBSYSTEM="net"? :)

Quoted 3 lines

eth0 should have no major and minor, but trying to catch it makes rule more and more complex.
Alas, i don't know where to et list of subsystems :-(

'ls /sys/class/' is a good place to start (becides the block subsystem, which is still in /sys/block/ due to a whole bunch of kernel coding reasons...)

Hope this helps.

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#10 lore raw

Re: +rule: query device inode by Major and Minor - am i inventing

In reply to Arioch

Greg KH пишет:

Quoted 2 lines
Quoted 1 line

But what should tell character devices from, say, network interfaces ?

Perhaps SUBSYSTEM=="net"? :)

way to fragile rules.

SUBSYSTEM!="block", SUBSYSTEM!="net", ....

...and tomorrow this script would be run on another platform, that has subsystem i did not have. Or just new subsystem was invented. And the rule immediately fails.

Those matches, they do not tell character devices from subsystem, but they tell knon (to me) subsystems from the unknown rest (which i believe to be character devices and nothing else).

Guess i also can dp something like PROGRAM="/bin/file %P", Result=="*character*" but...
...then i again can stumble upon stderr
...and i cannot call another program

Oh, i guess i can determine something, then ENV{tmp_xxx}:='flag', then use it later. (i remember i heard that ENV can be LValue now) Or again i can use scripts.

but that seems that rather simple task needs rather complex actions to implement :-)

Quoted 5 lines
Quoted 1 line

Alas, i don't know where to et list of subsystems :-(

'ls /sys/class/' is a good place to start (becides the block subsystem, which is still in /sys/block/ due to a whole bunch of kernel coding reasons...)

...assuming my kernel has all of them.
kernel docs sysfs.txt and kobject.txt are written for oldschool
kernel hacker introducing him to new concepts. I wish to see someday
SYSFS in 30 days for users ;)

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel