Chinaunix首页 | 论坛 | 博客
  • 博客访问: 862431
  • 博文数量: 286
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1841
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-09 16:26
文章分类

全部博文(286)

文章存档

2016年(38)

2015年(248)

我的朋友

分类: LINUX

2015-06-11 10:28:24


点击(此处)折叠或打开

  1. 启动时候会执行target/linux/ramips/base-files/lib/preinit/06_set_iface_mac

  2. 比如内容为:
  3. all0256n |\
  4. 33 fonera20n |\
  5. 34 rt-n13 |\
  6. 35 hg255d |\
  7. 36 ap8100rt |\
  8. 37 wap120nf |\
  9. 38 hw550-3g |\
  10. 39 nbg-419n |\
  11. 40 omni-emb |\
  12. 41 w306r-v20 |\
  13. 42 w502u |\
  14. 43 wl-330n |\
  15. 44 wl-330n3g |\
  16. 45 wr6202 |\
  17. 46 xdxrn502j)
  18. 47 mac=$(ramips_get_mac_binary factory 40)
  19. 48 ifconfig eth0 hw ether $mac 2>/dev/null

  20. 他执行了ramips_get_mac_binary factory 40

  21. 我们找到ramips_get_mac_binary在/lib/ramips.sh中定义的
  22. ramips_get_mac_binary()
  23. {
  24.         local mtdname="$1"
  25.         local seek="$2"
  26.         local part

  27.         . /lib/functions.sh

  28.         part=$(find_mtd_part "$mtdname")
  29.         if [ -z "$part" ]; then
  30.                 echo "ramips_get_mac_binary: partition $mtdname not found!" >&2
  31.                 return
  32.         fi

  33.         dd bs=1 skip=$seek count=6 if=$part 2>/dev/null | /usr/sbin/maccalc bin2
  34. }

  35. 原来他通过这个程序找到mac所在的mtd分区,然后通过dd地址位方法找到的mac地址



  36. 而find_mtd_part 是在/lib/functions.sh中定义的


  37. openwrt启动顺序:
  38. 1.bootloader
  39. 2.linux
  40. 3./etc/preinit
  41. 4./sbin/init
  42. 5./etc/inittab
  43. 6./etc/init.d/rcS
  44. 7./etc/rc.d/S*


阅读(3680) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~