Browse Source

After a day of figuring that only strstr was required, this new change

will set things so that nested umls can work with a tt host
kernel. Since everything looks like skas under a uml even if the host
kernel is tt.  So /proc/cmdline is looked at since skas-or-tt
automatically adds the mode={tt,skas} option.
master
freesource 22 years ago
parent
commit
f845aab17f
  1. 45
      skas-or-tt/skas-or-tt.c

45
skas-or-tt/skas-or-tt.c

@ -21,7 +21,7 @@ process.c. This is a good way to learn about clone() and ptrace().
int main(void) int main(void)
{ {
int n, pid, ret = 1; int n, pid, ret = 1, cmdline_value;
void *stack; void *stack;
struct ptrace_faultinfo { struct ptrace_faultinfo {
@ -32,6 +32,17 @@ int main(void)
struct ptrace_faultinfo fi; struct ptrace_faultinfo fi;
cmdline_value = host_cmdline();
if ( cmdline_value == 1 ) {
printf("Checking for the skas3 patch in the host...not found\nChecking for /proc/mm...not found\n");
return(0);
}
else if ( cmdline_value == 2 ) {
printf("Checking for the skas3 patch in the host...found\nChecking for /proc/mm...found\n");
return(0);
}
printf("Checking for the skas3 patch in the host..."); printf("Checking for the skas3 patch in the host...");
pid = start_ptraced_child(&stack); pid = start_ptraced_child(&stack);
@ -58,10 +69,36 @@ int main(void)
} }
int threadFunction( void* argument ) int host_cmdline (void)
{ {
printf( "child thread exiting\n" );
exit(0); char s[500]; /* should be the max cmdline size */
FILE *f;
char *tt = "mode=tt";
char *skas = "mode=skas";
char *ptt, *pskas;
f = fopen("/proc/cmdline","r");
if ( f == NULL ) {
printf("Error: unable to open /proc/cmdline for reading\n");
return(0);
}
if (fgets(s, sizeof s, f) != NULL) {
ptt = strstr(s, tt);
pskas = strstr(s, skas);
if ( ptt != NULL )
return(1);
else if ( pskas != NULL )
return(2);
else
return(0);
}
return(1); /* safety default */
} }

Loading…
Cancel
Save