更新kpmmgr
This commit is contained in:
@@ -13,13 +13,36 @@
|
|||||||
#define CMD_KPM_CONTROL_MAX 7
|
#define CMD_KPM_CONTROL_MAX 7
|
||||||
|
|
||||||
// 控制代码
|
// 控制代码
|
||||||
#define SUKISU_KPM_LOAD 1
|
// prctl(xxx, 28, "PATH", "ARGS")
|
||||||
#define SUKISU_KPM_UNLOAD 2
|
// success return 0, error return -N
|
||||||
#define SUKISU_KPM_NUM 3
|
#define SUKISU_KPM_LOAD 28
|
||||||
#define SUKISU_KPM_LIST 4
|
|
||||||
#define SUKISU_KPM_INFO 5
|
// prctl(xxx, 29, "NAME")
|
||||||
#define SUKISU_KPM_CONTROL 6
|
// success return 0, error return -N
|
||||||
#define SUKISU_KPM_PRINT 7
|
#define SUKISU_KPM_UNLOAD 29
|
||||||
|
|
||||||
|
// num = prctl(xxx, 30)
|
||||||
|
// error return -N
|
||||||
|
// success return +num or 0
|
||||||
|
#define SUKISU_KPM_NUM 30
|
||||||
|
|
||||||
|
// prctl(xxx, 31, Buffer, BufferSize)
|
||||||
|
// success return +out, error return -N
|
||||||
|
#define SUKISU_KPM_LIST 31
|
||||||
|
|
||||||
|
// prctl(xxx, 32, "NAME", Buffer[256])
|
||||||
|
// success return +out, error return -N
|
||||||
|
#define SUKISU_KPM_INFO 32
|
||||||
|
|
||||||
|
// prctl(xxx, 33, "NAME", "ARGS")
|
||||||
|
// success return KPM's result value
|
||||||
|
// error return -N
|
||||||
|
#define SUKISU_KPM_CONTROL 33
|
||||||
|
|
||||||
|
// prctl(xxx, 34, buffer, bufferSize)
|
||||||
|
// success return KPM's result value
|
||||||
|
// error return -N
|
||||||
|
#define SUKISU_KPM_VERSION 34
|
||||||
|
|
||||||
#define CONTROL_CODE(n) (CMD_KPM_CONTROL + n - 1)
|
#define CONTROL_CODE(n) (CMD_KPM_CONTROL + n - 1)
|
||||||
|
|
||||||
@@ -32,7 +55,7 @@ void print_usage(const char *prog) {
|
|||||||
printf(" list List loaded KPM modules\n");
|
printf(" list List loaded KPM modules\n");
|
||||||
printf(" info <name> Get info of a KPM module\n");
|
printf(" info <name> Get info of a KPM module\n");
|
||||||
printf(" control <name> <args> Send control command to a KPM module\n");
|
printf(" control <name> <args> Send control command to a KPM module\n");
|
||||||
printf(" print Print KPM module list to stdout\n");
|
printf(" version Print KPM Loader version\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@@ -72,9 +95,12 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if (strcmp(argv[1], "control") == 0 && argc >= 4) {
|
} else if (strcmp(argv[1], "control") == 0 && argc >= 4) {
|
||||||
// 控制 KPM 模块
|
// 控制 KPM 模块
|
||||||
ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_CONTROL), argv[2], argv[3], &out);
|
ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_CONTROL), argv[2], argv[3], &out);
|
||||||
} else if (strcmp(argv[1], "print") == 0) {
|
} else if (strcmp(argv[1], "version") == 0) {
|
||||||
// 在 stdout 输出 KPM 列表
|
char buffer[1024] = {0};
|
||||||
ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_PRINT), NULL, NULL, &out);
|
ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_VERSION), buffer, sizeof(buffer), &out);
|
||||||
|
if (ret >= 0) {
|
||||||
|
printf("%s", buffer);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user