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.


沒有留言: