:: Re: [DNG] vdev - udev is a dead end
Page principale
Supprimer ce message
Répondre à ce message
Auteur: karl
Date:  
À: dng
Sujet: Re: [DNG] vdev - udev is a dead end
Didier:
...
>     Erratum again. The devices are accessible through symlinks in 
> /sys/dev/char and /sys/dev/block. The name of each symlink apparently 
> duplicates the contents of the dev file in the directory it points to. Eg:

>
> /sys/dev/char/4:0 --> /sys/devices/virtual/tty/tty0/
> and /sys/devices/virtual/tty/tty0/dev contains "4:0", meaning the
> device file should be created with
> 'mknod /dev/tty0 c 4 0'


So something like this whould suffice to populate /dev

#!/usr/bin/perl -w

use strict;

my $char = "/sys/dev/char";
my $block = "/sys/dev/block";

sub run_dir($$) {
    my $dir = shift;
    my $type = shift;


    opendir(my $dh, $dir) || return;
    while(readdir $dh) {
    next unless m/^\d+:\d+$/;
    my $file = "$dir/$_";
    my ($maj,$min) = split(/:/);


    my $name = readlink($file);
    next unless (defined($name));
    $name =~ s|.*/||;
    print "mknod $name $type $maj $min\n";
    }
    closedir $dh;
}


sub main() {
    run_dir($char, "c");
    run_dir($block, "b");
}


main();

It woouldn't be hard to convert that to a shell script.

Regards,
/Karl Hammar

-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57