DiskStation> vi /etc/ssh/sshd_config
DiskStation> vi /etc.defaults/ssh/sshd_config
2014年9月2日 星期二
2014年4月24日 星期四
[Linux]How to execute reboot in the Linux driver module
void rebootBMC(void) {
int ret;
char *cmd[2], *path[4];
cmd[0] = "/sbin/reboot";
cmd[1] = NULL;
path[0] = "HOME=/";
path[1] = "PWD=/";
path[2] = "PATH=/sbin";
path[3] = NULL;
ret = call_usermodehelper(cnd[0], cnd, path, 0);
printk(KERN_INFO "reboot to enable SMBus Sideband LAN (ret = %d).\n", ret);
}
You can fill the parameter into cmd[1] and the cmd and path arrays should end with "NULL.
int ret;
char *cmd[2], *path[4];
cmd[0] = "/sbin/reboot";
cmd[1] = NULL;
path[0] = "HOME=/";
path[1] = "PWD=/";
path[2] = "PATH=/sbin";
path[3] = NULL;
ret = call_usermodehelper(cnd[0], cnd, path, 0);
printk(KERN_INFO "reboot to enable SMBus Sideband LAN (ret = %d).\n", ret);
}
You can fill the parameter into cmd[1] and the cmd and path arrays should end with "NULL.
2014年4月10日 星期四
[Linux]Redirect stderr into stdout
Add 2>&1 in the command line.
e.g. ipmitool -H 10.99.6.8 -U USERID -P PASSW0RD sel 2>&1 | awk 'NR==1{print $2}'
2014年4月8日 星期二
[Linux]Read/Write config file in the driver module
#include linux/string.h
static int WriteBondConfToNCSI(void){
struct file *fp;
char buf[128], *substring;
int indexofsubstring = 0;
mm_segment_t fs;
fp=filp_open("/conf/bond.conf",O_RDONLY,0);
fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());
memset(buf, 0, sizeof(buf));
// Read the file
fp->f_op->read(fp, buf, 128, &fp->f_pos);
set_fs(fs);
filp_close(fp,NULL);
fp=filp_open("/conf/bond.conf",O_WRONLY | O_TRUNC,0);
substring = strstr(buf, "eth");
indexofsubstring = substring - buf;
buf[indexofsubstring+3] = '0';
fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());
fp->f_op->write(fp, (char *)buf, strlen(buf), &fp->f_pos);
set_fs(fs);
filp_close(fp,NULL);
return 0;
}
如果想判斷某檔案是否存在,可利用下列方式:
filep=filp_open("/tmp/aa",O_RDONLY,0);
if(IS_ERR(filep)){
//Not exist
}
else{
//Exist
}
不可使用if(filep == NULL){}
static int WriteBondConfToNCSI(void){
struct file *fp;
char buf[128], *substring;
int indexofsubstring = 0;
mm_segment_t fs;
fp=filp_open("/conf/bond.conf",O_RDONLY,0);
fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());
memset(buf, 0, sizeof(buf));
// Read the file
fp->f_op->read(fp, buf, 128, &fp->f_pos);
set_fs(fs);
filp_close(fp,NULL);
fp=filp_open("/conf/bond.conf",O_WRONLY | O_TRUNC,0);
substring = strstr(buf, "eth");
indexofsubstring = substring - buf;
buf[indexofsubstring+3] = '0';
fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());
fp->f_op->write(fp, (char *)buf, strlen(buf), &fp->f_pos);
set_fs(fs);
filp_close(fp,NULL);
return 0;
}
如果想判斷某檔案是否存在,可利用下列方式:
filep=filp_open("/tmp/aa",O_RDONLY,0);
if(IS_ERR(filep)){
//Not exist
}
else{
//Exist
}
不可使用if(filep == NULL){}
2014年3月3日 星期一
[Linux]Mount the image file with jffs2 file system in the Linux OS.
1. modprobe mtdblock
2. modprobe mtdram total_size=512k erase_size=64k
3. dd if=jffs2.img of=/dev/mtdblock0
4. mount -t jffs2 /dev/mtdblock0 /mnt/
2014年2月5日 星期三
2013年9月5日 星期四
[LINUX]Something for ipmi driver and ipmitool
1. ipmi driver的source code放置於/usr/src/kernels/3.10.4-19_00032_g982b172/driver/char/ipmi下。
2.於/usr/src/kernels/3.10.4-19_00032_g982b172/使用下面command可以complie ipmi driver
make M=driver/char/ipmi
3. ipmi driver不允許user直接送下列的raw commnd,
raw 0x06 0x33 - Get Message
raw 0x06 0x34 - Send Message
raw 0x06 0x35 - Read Event Message Buffer - 可使用ipmiutil getevent取得event
4. 如果要使用ipmitool -t 0x2c -b 6 raw 0x06 0x01,則必須建立nmchannel.i,因為ipmi driver在啟動時,會送Get Channel Info command去scan all channel,如果沒有nm channel的info,ipmi driver即不會傳送bridge command to BMC。
2.於/usr/src/kernels/3.10.4-19_00032_g982b172/使用下面command可以complie ipmi driver
make M=driver/char/ipmi
3. ipmi driver不允許user直接送下列的raw commnd,
raw 0x06 0x33 - Get Message
raw 0x06 0x34 - Send Message
raw 0x06 0x35 - Read Event Message Buffer - 可使用ipmiutil getevent取得event
4. 如果要使用ipmitool -t 0x2c -b 6 raw 0x06 0x01,則必須建立nmchannel.i,因為ipmi driver在啟動時,會送Get Channel Info command去scan all channel,如果沒有nm channel的info,ipmi driver即不會傳送bridge command to BMC。
訂閱:
文章 (Atom)