關於cli的處理 啟動引數

2021-09-30 15:17:22 字數 1051 閱讀 1427

commandoptions options = new commandoptions();

option option = new option("a", "tianjia");

option.setlongopt("add");

option.setrequired(true);

option.setargs(1);

option.setargname("tianjia");

optiongroup group = new optiongroup();

option option1 = new option("a1", "tianjia");

option1.setlongopt("add1");

option1.setrequired(true);

option1.setargs(2);

option1.setargname("tianjia1");

option option2 = new option("a2", "tianjia");

option2.setlongopt("add2");

option2.setrequired(true);

option2.setargs(2);

option2.setargname("tianjia2");

options.addoption(option);

group.addoption(option1);

group.addoption(option2);

group.setrequired(true);

options.addoptiongroup(group);

commandlineparser parser = new posixparser();

if (null == args)

try catch (parseexception e)

//在option中設定的元素是基於-xx *** 格式

//在group中設定的元素只能出現組中其中乙個,不能同時出現

//如果在設定乙個啟動引數的時候,該引數內部沒有採用

Linux Kernel啟動中引數的處理

1.在bootloader中會以taglist的形式儲存板子mem cmdline cmdline中也可以定義mem資訊 等相關資訊,cmdline通過getenv從環境變數取得 該環境變數是之前使用setenv以字串形式配置 addr和size。跳轉到kernel前,r0 0,r1 proc ty...

關於核心引數的處理

今天無意中想到,我們在bootload中新增到核心中的引數是如何在核心中處理的 比如console ttys0 root dev nfs nfsroot opt nfsroot 等等 原來,這些引數是通過 setup與early param 來實現的 比如核心nfsroot.c中的 setup nf...

核心啟動時怎麼處理啟動引數

關鍵點 parse args setup巨集 linux允許使用者通過bootloader傳遞核心配置選項給核心,例如 console ttys1,115200n8 androidboot.hardware eee 701 vga 788 核心在初始化過程中呼叫parse args函式對這些選項進行...