Att bygga en kärna

SysFS och udevinfo

Ett sätt att extrahera hårdvaruinformation.

Det här är information, som kan användas till konfiguration. Av externa komponenter.

Hårdvaran hanteras och laddas, in i ett tmpfs av udevd. Den daemon som dynamiskt, hanterar /dev i ett 2.6 baserat system.

Informationen lagras i /sys och förmedlas via sysfs. /sys är sökbar med udevinfo.

bash-3.00$ udevinfo -a -p /sys/block/sda

udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.

device '/sys/block/sda' has major:minor 8:0
  looking at class device '/sys/block/sda':
    SUBSYSTEM=="block"
    SYSFS{dev}=="8:0"
    SYSFS{range}=="16"
    SYSFS{removable}=="0"
    SYSFS{size}=="156301488"
    SYSFS{stat}=="    9425    47560   380002   346908    16769    32793   396336   863540        0    86204  1210476"

follow the "device"-link to the physical device:
  looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:01:07.0/host2/target2:0:0/2:0:0:0':
    BUS=="scsi"
    ID=="2:0:0:0"
    DRIVER=="sd"
    SYSFS{device_blocked}=="0"
    SYSFS{iocounterbits}=="32"
    SYSFS{iodone_cnt}=="0x665d"
    SYSFS{ioerr_cnt}=="0x0"
    SYSFS{iorequest_cnt}=="0x665d"
    SYSFS{model}=="FUJITSU MHT2080B"
    SYSFS{queue_depth}=="1"
    SYSFS{queue_type}=="none"
    SYSFS{rev}=="0000"
    SYSFS{scsi_level}=="6"
    SYSFS{state}=="running"
    SYSFS{timeout}=="30"
    SYSFS{type}=="0"
    SYSFS{vendor}=="ATA     "

  looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:01:07.0/host2/target2:0:0':
    BUS==""
    ID=="target2:0:0"
    DRIVER=="unknown"

  looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:01:07.0/host2':
    BUS==""
    ID=="host2"
    DRIVER=="unknown"

  looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:01:07.0':
    BUS=="pci"
ID=="0000:01:07.0"
    DRIVER=="sata_via"
    SYSFS{class}=="0x010400"
    SYSFS{device}=="0x3249"
    SYSFS{irq}=="10"
    SYSFS{local_cpus}=="1"
    SYSFS{modalias}=="pci:v00001106d00003249sv00001734sd0000107Cbc01sc04i00"
    SYSFS{subsystem_device}=="0x107c"
    SYSFS{subsystem_vendor}=="0x1734"
    SYSFS{vendor}=="0x1106"

  looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0':
    BUS=="pci"
    ID=="0000:00:1e.0"
    DRIVER=="unknown"
    SYSFS{class}=="0x060401"
    SYSFS{device}=="0x2448"
    SYSFS{irq}=="0"
    SYSFS{local_cpus}=="1"
    SYSFS{modalias}=="pci:v00008086d00002448sv00000000sd00000000bc06sc04i01"
    SYSFS{subsystem_device}=="0x0000"
    SYSFS{subsystem_vendor}=="0x0000"
    SYSFS{vendor}=="0x8086"

  looking at the device chain at '/sys/devices/pci0000:00':
    BUS==""
    ID=="pci0000:00"
    DRIVER=="unknown"

bash-3.00$ 
Tillbaka

copyleft   Valid XHTML 1.0!

Slackware® Linux is a Registered Trademark of Patrick J. Volkerding (Slackware inc.).
Linux® i a Registered Trademark of Linus Torvalds.
Copyright© 2005 GNU/fdl Jens Odsvall
(Legal Notice)