Linux 初始化出错,这是为什么?
答案:2 悬赏:80 手机版
解决时间 2021-01-26 23:49
- 提问者网友:风月客
- 2021-01-26 01:33
Linux 初始化的时候显示Running phymouthd,这是为什么?
最佳答案
- 五星知识达人网友:千夜
- 2021-01-26 02:03
只有这两处,一个段错误,一个initializing,
编译,连接都没有warning和error,
代码如下:
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include
#include
#include
#include
#include
#include
#define ETH_P_PRO 0x8889
int testsend_init_module(void)
{
char mac[6]={'0','9','b','3','7','f'};
int i,j ;
struct sk_buff *skb,*skb1;
struct net_device *tem_dev;
struct ethhdr *eth;
tem_dev=dev_get_by_name("eth1");
if((skb=alloc_skb(1024+ETH_HLEN,GFP_ATOMIC))==NULL){
printk("alloc_skb() fail in send");
return -1;
}
skb_put(skb,1024+ETH_HLEN);
eth=(struct ethhdr *)skb->data;
memcpy(eth->h_dest,mac,ETH_ALEN);
memcpy(eth->h_source,tem_dev->dev_addr,ETH_ALEN);
eth->h_proto=htons(ETH_P_PRO);
memcpy(skb->data+ETH_HLEN,0,1024);
skb->len=1024+ETH_HLEN;
skb->protocol=htons(ETH_P_PRO);
skb->dev=tem_dev;
skb1=skb_clone(skb,GFP_ATOMIC);
for(i=0;i<10000;i++){
j=dev_queue_xmit(skb1);
printk("the output is %d\n",j);
}
printk("come here\n");
return 0;
}
void testsend_cleanup_module(void)
{
// kfree(skb);
}
module_init(testsend_init_module);
module_exit(testsend_cleanup_module);
MODULE_LICENSE("GPL");
目的是验证一下函数的功能,其中自己设定的目的mac地址,数据报的内容都设成0,然后发送
编译,连接都没有warning和error,
代码如下:
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include
#include
#include
#include
#include
#include
#define ETH_P_PRO 0x8889
int testsend_init_module(void)
{
char mac[6]={'0','9','b','3','7','f'};
int i,j ;
struct sk_buff *skb,*skb1;
struct net_device *tem_dev;
struct ethhdr *eth;
tem_dev=dev_get_by_name("eth1");
if((skb=alloc_skb(1024+ETH_HLEN,GFP_ATOMIC))==NULL){
printk("alloc_skb() fail in send");
return -1;
}
skb_put(skb,1024+ETH_HLEN);
eth=(struct ethhdr *)skb->data;
memcpy(eth->h_dest,mac,ETH_ALEN);
memcpy(eth->h_source,tem_dev->dev_addr,ETH_ALEN);
eth->h_proto=htons(ETH_P_PRO);
memcpy(skb->data+ETH_HLEN,0,1024);
skb->len=1024+ETH_HLEN;
skb->protocol=htons(ETH_P_PRO);
skb->dev=tem_dev;
skb1=skb_clone(skb,GFP_ATOMIC);
for(i=0;i<10000;i++){
j=dev_queue_xmit(skb1);
printk("the output is %d\n",j);
}
printk("come here\n");
return 0;
}
void testsend_cleanup_module(void)
{
// kfree(skb);
}
module_init(testsend_init_module);
module_exit(testsend_cleanup_module);
MODULE_LICENSE("GPL");
目的是验证一下函数的功能,其中自己设定的目的mac地址,数据报的内容都设成0,然后发送
全部回答
- 1楼网友:风格不统一
- 2021-01-26 02:44
<p>给你一份文档,先利用这份文档的方法进入单用户模式,然后修改/etc/inittab,找到</p> <p>
# default runlevel. the runlevels used by rhs are:
# 0 - halt (do not set initdefault to this)
# 1 - single user mode
# 2 - multiuser, without nfs (the same as 3, if you do not have networking)
# 3 - full multiuser mode
# 4 - unused
# 5 - x11
# 6 - reboot (do not set initdefault to this)
#
id:5:initdefault:
</p> <p>把id改成从5改成3,然后重启</p>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯