views:

33

answers:

2

Hi, Is there a possibility that I can hardcode interface name(say eth1) to a specific interface in the linux driver code?

This is in a controlled environemnt only, so breaking from default linux way(dynamically assigning name) is ok.

+1  A: 

You may not need to do that; you could instead just fiddle with the dynamic assignment mechanism. udev has configuration files that control how names are assigned to devices, and if I remember it will also allow you to create links with handy names for given device names... so you can probably achieve your effect by re-configuring rather than re-coding.

Check out the man page and docs for udev.

Carl Smotricz
But i don't use udev. any other way in code?
kumar
Are you not *consciously* using udev, or is your system really not using udev? i.e. do you have an "old" or custom "slim" Linux distro? If there's no udev in the system then I don't have any other advice, as I don't know my way around the code.
Carl Smotricz
its a custom made embedded linux system.I got the way...Just I need to do { strcpy(dev->name,"eth1");}
kumar
A: 

You can rename network devices which are not up using the "ifconfig" command or the ioctl it uses. I strongly recommend that you don't :)

MarkR