LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - Installation (https://www.linuxquestions.org/questions/slackware-installation-40/)
-   -   Is life without udev possible? (https://www.linuxquestions.org/questions/slackware-installation-40/is-life-without-udev-possible-4175528546/)

gearheadgeek 12-17-2014 08:48 AM

Is life without udev possible?
 
I'm not really a luddite - it is just that udev does nothing useful in my application and instead causes problems. Pat implies it it possible "with some tweaks". Does anyone know what those tweaks might be?

genss 12-17-2014 08:51 AM

get a ps2 keyboard and try it out :)

gearheadgeek 12-17-2014 09:37 AM

Quote:

Originally Posted by genss (Post 5286247)
get a ps2 keyboard and try it out :)

Huh? I don't follow. My application does not use a keyboard.

genss 12-17-2014 09:58 AM

the kernel itself makes most of the needed nodes in /dev

of the things that it doesn't here's what i got so far
what you look for depends on what your program needs

#/dev/X0R -> null
ln -s /proc/kcore /dev/core
ln -s /proc/self/fd /dev/fd
ln -s /input/mice /dev/mouse
#/dev/rtc -> rtc0
ln -s /proc/self/fd/2 /dev/stderr
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
(the two hashed i haven't looked at yet)

then there are modules for devices, something like

Code:

for i in /sys/block/*/device/modalias /sys/bus/*/devices/*/device/modalias /sys/bus/*/devices/*/device/modalias /sys/class/*/*/device/modalias
  do
    if [ -f $i ]
    then
      #echo "modprobe `cat $i`"
      modprobe `cat $i`
    fi
  done

to make nodes for block devices

Code:

for i in /sys/block/*/dev
  do
    if [ -f $i ]
    then
      MAJOR_MINOR=`sed 's/:*:/\ /' < $i`
      DEVNAME=`echo $i | sed -e 's@/dev@@' -e 's@.*/@@'`
      #echo `echo $i | cut -d \/ -f 4`
      #echo "mknod /dev/$DEVNAME b $MAJOR_MINOR"
      mknod /dev/$DEVNAME b $MAJOR_MINOR
    fi
  done
 
for i in /sys/block/*/*/dev
  do
    if [ -f $i ]
    then
      MAJOR_MINOR=`sed 's/:*:/\ /' < $i`
      DEVNAME=`echo $i | sed -e 's@/dev@@' -e 's@.*/@@'`
      #echo `echo $i | cut -d \/ -f 4`
      #echo "mknod /dev/$DEVNAME b $MAJOR_MINOR"
      mknod /dev/$DEVNAME b $MAJOR_MINOR
    fi
  done


maybe some more things, idk


PS i didn't put char devices as some have special directories in /dev

gearheadgeek 12-17-2014 11:16 AM

What is wrong with the /dev that you have to install to boot with before tmpsysfs overlays it? My application is static and uses no modules. I need to add to /dev for a touch screen, which, of course, doesn't work. Maybe I could learn udev rules but since the touch stuff lives outside the kernel, I don't think udev can help. In any case, not using udev is easier than learning how to make rules. I did an install without udev but tmpsysfs is still laid on top of /dev.

genss 12-17-2014 11:29 AM

/dev is a special kind of virtual fs, devfs
the kernel populates most of it automatically

what rules do you need ?
what are you doing anyway ?
do you use usb ?
do you know how to use modprobe and mknod ?

gearheadgeek 12-17-2014 12:38 PM

Quote:

Originally Posted by genss (Post 5286363)
/dev is a special kind of virtual fs, devfs
the kernel populates most of it automatically

I assumed as much, but the question is, what is wrong with the static version that gets hidden by devfs?
Quote:

what rules do you need ?
If I don't have udev, I don't need rules. What I need is a /dev entry for a touch screen that the kernel does know know about or understand.
Quote:

what are you doing anyway ?
Embedded systems.
Quote:

do you use usb ?
Yes, but that does not require udev.
Quote:

do you know how to use modprobe and mknod ?
Yes, but I don't use modprobe to because I compile all necessary pieces into the kernel and using mknod on tmpdevfs does not work.

I have been using Slack since 4.0, but these provisions to make desktop users lives easier are beginning to get in the way.

genss 12-17-2014 04:11 PM

all devices in /dev are nodes
before they were all made at boot, that lead to problems with some corner cases (not just desktop ones)
GKH decided it should be done by a userspace app (after HAL was hotplug then udev), despite other UNIX-es solving that problems properly

example of a /dev node:

bash-4.3# ls -l /dev/usbmon0
crw------- 1 root root 250, 0 Pro 17 15:14 /dev/usbmon0

c means it's a character device
250 is the major node number
0 is the minor node number

so to make this node i would run
mknod /dev/usbmon0 c 250 0
(system call is almost the same)

to find out that numbers you would look into sysfs's /sys/class/usbmon/usbmon0/dev file (or the uevent file)
bash-4.3# cat /sys/class/usbmon/usbmon0/dev
250:0


from what i know; (the documentation is non existent, as is usually the case with Kay Sievers and gang)
there are no static versions for dynamic devices, just for one of a kind ones
nothing that the kernel puts in devtmpfs gets replaced


so if all you need is the dev node, that should be easy to make at boot
bdw openwrt has it's own udev-like version, and hotplug is good documentation/example

ReaperX7 12-17-2014 04:29 PM

You don't need udev to have a functioning system, but it helps with hardware. Without udev you'll have to use mknod to statically assign device nodes in /dev manually, and rely on the kernel hotplugging system.

veerain 12-17-2014 10:16 PM

You can replace udev with:

1) eudev

2) mdev from busybox

3) hotplug from openwrt

Usually Udev gets event from kernel on device installation and udev creates neccessary device nodes in /dev

And devtmpfs doesn't handles it well.

Or you can create static device nodes on /dev directory itself. Only if devices don't get changed in each instance.

Didier Spaier 12-18-2014 12:03 AM

For your embedded system, mdev is the way to go. Just in case you didn't come across it yet, see also OpenEmbedded
and of course BusyBox.

gearheadgeek 12-19-2014 07:03 AM

Quote:

Originally Posted by genss (Post 5286558)
all devices in /dev are nodes
GKH decided it should be done by a userspace app (after HAL was hotplug then udev), despite other UNIX-es solving that problems properly

I have too much else to do to keep up with kernel development so I missed that. I have been using 2.6 kernels recently and this is my first go with a 3.x series. I can't find anything anywhere that explains tmpdevfs or how to use it.
Quote:

example of a /dev node:

bash-4.3# ls -l /dev/usbmon0
crw------- 1 root root 250, 0 Pro 17 15:14 /dev/usbmon0
As I mentioned, I have been using Slack in embedded since 4.0 (or maybe it was 3.4) so I actually do understand device nodes know how to make them.

gearheadgeek 12-19-2014 07:09 AM

Quote:

Originally Posted by ReaperX7 (Post 5286571)
You don't need udev to have a functioning system, but it helps with hardware.

You are right, it is possible. I worked it out and have it running. Thing is, I don't need (or want) help with hardware. That is the point.
Quote:

Without udev you'll have to use mknod to statically assign device nodes in /dev manually, and rely on the kernel hotplugging system.
I have learned in my 35 years of embedded that Murhpy always wins. Something WILL go wrong. So the approach is to keep things as simple as possible. Adding an unneeded hotplug system just to have device nodes that work just as well statically is tempting Murphy to screw around with you. If I need a device node, I can make it.

gearheadgeek 12-19-2014 07:12 AM

Quote:

Originally Posted by veerain (Post 5286731)
You can replace udev with:

1) eudev

2) mdev from busybox

3) hotplug from openwrt

Usually Udev gets event from kernel on device installation and udev creates neccessary device nodes in /dev

And devtmpfs doesn't handles it well.

Or you can create static device nodes on /dev directory itself. Only if devices don't get changed in each instance.

Thanks, but I have been using Slack in embedded successfully since long before busybox. *nix has worked fine with static device nodes for the whole time. Hot plugging is not useful to me and only represents another potential failure point.

veerain 12-19-2014 08:56 AM

Quote:

Originally Posted by gearheadgeek (Post 5287471)
I have too much else to do to keep up with kernel development so I missed that. I have been using 2.6 kernels recently and this is my first go with a 3.x series. I can't find anything anywhere that explains tmpdevfs or how to use it.

As I mentioned, I have been using Slack in embedded since 4.0 (or maybe it was 3.4) so I actually do understand device nodes know how to make them.

To use devtmpfs all you have to do is:

mount -t devtmpfs devtmpfs /dev

/dev may be empty beforehand if you like.

genss 12-19-2014 09:19 AM

Quote:

Originally Posted by gearheadgeek (Post 5287471)
I have too much else to do to keep up with kernel development so I missed that. I have been using 2.6 kernels recently and this is my first go with a 3.x series. I can't find anything anywhere that explains tmpdevfs or how to use it.

As I mentioned, I have been using Slack in embedded since 4.0 (or maybe it was 3.4) so I actually do understand device nodes know how to make them.

problem is that the whole udev thing is made by Kay Sievers with help from GKH
hence NO documentation, 0, nada
Kay is too smart to explain anything

the hotplug doc i linked is the best documentation there is

as for the /dev entries being nodes
afaik they always have been, at least since 2.6 (maybe in 2.4 they werent, idk)

gearheadgeek 12-19-2014 01:14 PM

Quote:

Originally Posted by genss (Post 5287533)
problem is that the whole udev thing is made by Kay Sievers with help from GKH
hence NO documentation, 0, nada
Kay is too smart to explain anything

Which, to me, is a very good reason to avoid udev.
Quote:

the hotplug doc i linked is the best documentation there is
I will take a look at that.

gearheadgeek 12-19-2014 01:19 PM

Quote:

Originally Posted by veerain (Post 5287521)
To use devtmpfs all you have to do is:

mount -t devtmpfs devtmpfs /dev

Apparently it is not that simple. The kernel seems to populate /dev with what it finds at boot, but needs some hotplug mechanism (udev/mdev/etc) to find anything that is added later. In my case, the only thing added is a thumb drive to get data off the device. That works fine with a static /dev but not with devtmpfs.

gearheadgeek 12-19-2014 01:22 PM

As a postscript to this, I am happy. I have 14.1 running without udev and with a monolithic kernel (no modules or initrd) and it is booting in about 12 seconds and everything works.

Didier Spaier 12-19-2014 02:26 PM

Quote:

Originally Posted by genss (Post 5287533)
problem is that the whole udev thing is made by Kay Sievers with help from GKH
hence NO documentation, 0, nada
Kay is too smart to explain anything

Really? What about the man page? the reference manual? If you miss something, please state what. But maybe you've found something wrong, inaccurate, or not up to date in the documentation: please tell us what. Till then, I'll assume that you are just spreading FUD.

ReaperX7 12-19-2014 08:33 PM

Using mdev as an alternative to udev will require some heavy work.

I've been tinkering with a SlackBuild to build a working mdev solution for a few weeks now, but I need to get the rc.mdev init script crafted before I can try to test the package. Be heavily forewarned, mdev does not have rule-based auto-loading of modules. All it does is creates an instance of the device node and attempts to populate it based on it's configuration.

If you want additional rule-based assignment of devices, such as input devices, you'll need haldaemon (hal with hal-info). Also, if you decide to disable udev, do NOT uninstall it. Several projects rely on libudev as a dependency, but don't actively use it. Plus, you'll need to use the xf86-input-keyboard/mouse/joystick drivers for input devices if you go with mdev.

genss 12-20-2014 04:20 PM

Quote:

Originally Posted by Didier Spaier (Post 5287689)
Really? What about the man page? the reference manual? If you miss something, please state what. But maybe you've found something wrong, inaccurate, or not up to date in the documentation: please tell us what. Till then, I'll assume that you are just spreading FUD.

you can assume whatever you want

that is not documentation on udev, but on writing against udev
udev does A LOT of things that you don't know about and even the things you do know about (making nodes, loading firmware) are never explained in any way
like that udev sends events to xorg-server

you can also go check the source code to find almost no comments and absolutely non existent function naming convention
(i counted 3 styles, one of them OO)

in short it's about just a little less documented then X
and it matters for udev more then your avg program in that there is only one way to do what it does
not to mention that a page of ascii art drawings and half a page of text could explain it all



anyway we were not here talking about udev api, but about what udev does to make those dev nodes




PS if you can find me documentation on how logind/console-kit does anything, id be grateful
PPS look at the udev's device struct to see something funny

John VV 12-20-2014 04:42 PM

Quote:

As a postscript to this, I am happy. I have 14.1 running without udev and with a monolithic kernel (no modules or initrd) and it is booting in about 12 seconds and everything works.
now ,plug in that kindle fire that is under the tree and see it it works
or
the usb laser Virtual keyboard

mlslk31 12-22-2014 10:29 PM

You might go the devtmpfs route, really. It makes little difference in boot memory or kernel size, but you do have to set custom permissions after boot.

If you must go static, there's Documentation/devices.txt in the kernel source, which tells your where the devices are supposed to be. Use mknod if you have to do so. Also, /proc/devices can give a hint on where devices are located. There are also files in /sys that tell you about the nodes. For a command like `find /sys -name dev`, the actual contents of those dev files are the major and minor numbers for the device. You might have to figure out if the device is a block device, character device, or something else.

Slackware can be done without udev, easily. But yeah, it helps to have a PS/2 keyboard. I think I'll find that reply and mod it up. A bit of precaution: You might look at the /dev directory of your system by booting from a utility disk, just to be sure that the static devs are still there. Also, if you want to slack off, you could just tar the devtmpfs /dev from a running system, then restore it as static devs from a utility disk, to have a nice starting point. Reboot using a devtmpfs-free kernel, and you should be good to go.

gearheadgeek 12-23-2014 03:58 PM

Quote:

Originally Posted by John VV (Post 5288238)
now ,plug in that kindle fire that is under the tree and see it it works
or
the usb laser Virtual keyboard

Apparently you haven't been paying attention. Neither of those get plugged into my embedded device.

ReaperX7 12-25-2014 04:55 AM

LFS has a good section on setting up static devices also:

http://linuxfromscratch.org/blfs/vie...s/devices.html

gearheadgeek 01-02-2015 07:06 AM

Quote:

Originally Posted by ReaperX7 (Post 5290282)
LFS has a good section on setting up static devices also:

http://linuxfromscratch.org/blfs/vie...s/devices.html

Thanks. Interesting that they recommend static devices on servers.


All times are GMT -5. The time now is 03:05 AM.