linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: md@Linux.IT (Marco d'Itri)
To: linux-hotplug@vger.kernel.org
Subject: Re: net interface renaming issue (+fix?)
Date: Thu, 13 Apr 2006 10:36:27 +0000	[thread overview]
Message-ID: <20060413103627.GA6818@wonderland.linux.it> (raw)
In-Reply-To: <20060409192140.73644723@eusebe>

[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]

On Apr 13, Kay Sievers <kay.sievers@vrfy.org> wrote:

> But right, the longer term goal is that the notion of "physical devices"
> and "virtual devices" should not be exported that way by the kernel
> and therefore the use of these values, or the "device" link, or the
> <subsystem:kernel_name> symlinks, or a hardcoded sequence of sysfs parent
> devices must be avoided for other things than temporary workarounds.

How should I rewrite this code then?

device_description() {
  local bus=$(sysreadlink device/bus)
  bus=${bus##*/}

  if   [ "$bus" = pci ]; then
    local vendor_id=$(sysread device/vendor)
    local device_id=$(sysread device/device)
    echo -n "PCI device ${vendor_id#0x}:${device_id#0x}"
  elif [ "$bus" = usb ]; then
    local device=$(sysreadlink device)
    if [ "$device" -a -e $device/../idVendor ]; then
      local idVendor idProduct
      read idVendor  < $device/../idVendor  || true
      read idProduct < $device/../idProduct || true
      printf 'USB device %x/%x' 0x$idVendor 0x$idProduct
    else
      echo -n "UNKNOWN USB device ($DEVPATH)"
    fi
  elif [ "$bus" ]; then
    echo -n "UNKNOWN $bus device ($DEVPATH)"
  else
    echo -n "UNKNOWN device ($DEVPATH)"
  fi

  local driver=$(sysreadlink device/driver)
  if [ "$driver" ]; then echo -n " (${driver##*/})"; fi
}

-- 
ciao,
Marco

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2006-04-13 10:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-09 17:21 net interface renaming issue (+fix?) Thomas de Grenier de Latour
2006-04-09 17:56 ` Sergey Vlasov
2006-04-09 18:00 ` Andrey Borzenkov
2006-04-09 19:28 ` Thomas de Grenier de Latour
2006-04-13  8:39 ` Marco d'Itri
2006-04-13  9:06 ` Thomas de Grenier de Latour
2006-04-13 10:29 ` Kay Sievers
2006-04-13 10:36 ` Marco d'Itri [this message]
2006-04-13 11:10 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060413103627.GA6818@wonderland.linux.it \
    --to=md@linux.it \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).