-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcmdtool.c
35 lines (33 loc) · 914 Bytes
/
cmdtool.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syslimits.h>
#include "roothide.h"
int main(int argc, const char * argv[])
{
if(strcmp(getprogname(),"jbrand")==0) {
printf("%016llX\n", jbrand());
}
else if(strcmp(getprogname(),"jbroot")==0) {
if(argc > 2) {
fprintf(stderr, "wrong arg count:%d\n", argc);
return -1;
}
const char* path = argc==2 ? argv[1] : "/";
printf("%s\n", jbroot(path));
} else if(strcmp(getprogname(),"rootfs")==0) {
if(argc != 2) {
fprintf(stderr, "wrong arg count:%d\n", argc);
return -1;
}
const char* path = argv[1];
printf("%s\n", rootfs(path));
} else {
fprintf(stderr, "wrong progname:%s\n", getprogname());
return -1;
}
return 0;
}