Linuxでethxxデバイス名を変更します
アプリケーションシナリオ:
一部の企業はモジュールを賀州モジュールに交換したいと考えていますが、前のモジュールはUSBxxネットワークカードを示し、賀州モジュールはethxxであったため、アプリケーションがアプリケーションを変更することになり、非常に面倒でした。
変更方法:
方法1はスクリプトを変更します
1.找到文件/etc/udev/rules.d/70-persistent-net.rules幹SUBSYSTEM == "net"、ACTION == "add"、DRIVERS == "?*"、ATTR {address} == " ac:00:00:c9:1e:c5 "、ATTR {dev_id} ==" 0x0 "、ATTR {type} ==" 1 "、KERNEL ==" eth * "改成SUBSYSTEM ==" net "、ACTION == "add"、DRIVERS == "?*"、ATTR {address} == "ac:00:00:c9:1e:c5"、ATTR {dev_id} == "0x0"、ATTR {type} == "1"、KERNEL == "usb *"、
方法2はカーネルを変更します
ステップ1:
2.6.30より新しいLinuxカーネルバージョンの場合
ファイル:[ KERNEL ] / drivers / net / usb / usbnet.c
- usbnet_probe(struct usb_interface * udev、const struct usb_device_id * prod)
{
- net-> netdev_ops =&usbnet_netdev_ops;
- net-> watchdog_timeo = TX_TIMEOUT_JIFFIES;
- net-> ethtool_ops =&usbnet_ethtool_ops;
/ allow device-specific bind/init procedures
- //注net-> nameはまだ使用できません..。
- if(info-> bind){
status = info->bind (dev, udev);
- if(status <0)
- goto out1;
// heuristic: "usb%d" for links we know are two-host,
// else "eth%d" when there's reasonable doubt. userspace
// can rename the link if it knows better.
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
(net->dev_addr [0] & 0x02) == 0))
strcpy (net->name, "eth%d"); /**** 请将此处修改为
strcpy(net-> name、 "usb%d"); * //* WLAN devices should always be named "wlan%d" */
- if((dev-> driver_info-> flags&FLAG_WLAN)!= 0)
- strcpy(net-> name、 "wlan%d");
- / * WWANデバイスには常に「wwan%d」という名前を付ける必要があります* /
- if((dev-> driver_info-> flags&FLAG_WWAN)!= 0)
- strcpy(net-> name、 "wwan%d");
-
ステップ2:
ドライバーがusb M0およびM1をttyUSBデバイスとしてロードすることを禁止するには、usbシリアルドライバーを次のように変更する必要があります。
2.6.30
ファイルより新しいLinuxカーネルバージョンの場合:[KERNEL] /drivers/usb/serial/option.c
static int option_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
struct usb_interface_descriptor *iface_desc =
&serial->interface->cur_altsetting->desc;
struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
/* Never bind to the CD-Rom emulation interface */
if (iface_desc->bInterfaceClass == 0x08)
i return -ENODEV;
//+add by airm2m for Air72x
if(dev_desc->idVendor == cpu_to_le16(0x1286) &&
dev_desc->idProduct == cpu_to_le16(0x4e3d) &&
iface_desc->bInterfaceNumber <= 1)
return -ENODEV;
//-add by airm2m for Air72x
/*
* Don't bind reserved interfaces (like network ones) which often have
* the same class/subclass/protocol as the serial interfaces. Look at
* the Windows driver .INF files for reserved interface numbers.
*/
if (is_blacklisted(
iface_desc->bInterfaceNumber,
OPTION_BLACKLIST_RESERVED_IF,
(const struct option_blacklist_info *) id->driver_info))
return -ENODEV;
使用方法2