Coder Social home page Coder Social logo

udev-examples's Introduction

udev-examples

libudev API examples

  • udev_example1.c: using libudev API we get basic information for network device 'eth0'.

example:

    [user@linux ~]$ ./udev_example1 eth0
    I: DEVNAME=eth0
    I: DEVPATH=/devices/pci0000:00/0000:00:19.0/net/eth0
    I: MACADDR=18:03:73:db:c3:31
    I: DRIVER=e1000
  • udev_example2.c: using libudev API we enumerate all devices under 'block' subsystem that are not 'partitions' or 'loop' devices.

example:

    [user@linux ~]$ ./udev_example2
    I: DEVNODE=/dev/sda
    I: KERNEL=sda
    I: DEVPATH=/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
    I: DEVTYPE=disk
    I: DEVSIZE=500 GB
    I: DEVNODE=/dev/sr0
    I: KERNEL=sr0
    I: DEVPATH=/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sr0
    I: DEVTYPE=disk
    I: DEVSIZE=n/a
  • udev_example3.c: using libudev API we monitor 'net' subsystem for events.

example:

    [user@linux ~]$ ./udev_example3
    I: ACTION=remove
    I: DEVNAME=net0
    I: DEVPATH=/devices/pci0000:00/0000:00:19.0/net/net0
    I: MACADDR=(null)
    ---
    I: ACTION=add
    I: DEVNAME=net0
    I: DEVPATH=/devices/pci0000:00/0000:00:19.0/net/net0
    I: MACADDR=d4:be:d9:2b:86:7c

udev-examples's People

Contributors

robertalks avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.