diff --git a/doc/booting.puml b/doc/booting.puml new file mode 100644 index 0000000..14bb492 --- /dev/null +++ b/doc/booting.puml @@ -0,0 +1,15 @@ +@startuml +participant init +participant Service +participant "Service Started" as C +participant "Command" as D + +init -> Service: +ueventd +Service -> C: ueventd started + +init -> Service: +apexd-bootstrap +Service -> C: apexd-bootstrap started + +init -> D !!: 'mkdir /acct/uid' +init -> D: update_linker_config +@enduml diff --git a/lazybox/src/main/kotlin/cfig/lazybox/App.kt b/lazybox/src/main/kotlin/cfig/lazybox/App.kt index 9e2fc34..7bdc38d 100644 --- a/lazybox/src/main/kotlin/cfig/lazybox/App.kt +++ b/lazybox/src/main/kotlin/cfig/lazybox/App.kt @@ -79,4 +79,8 @@ fun main(args: Array) { if (args[0] == "mount") { MountAnalyzer().run() } + if (args[0] == "booting") { + //BootingParser.run() + BootingParser.run2() + } } diff --git a/lazybox/src/main/kotlin/cfig/lazybox/BootingParser.kt b/lazybox/src/main/kotlin/cfig/lazybox/BootingParser.kt new file mode 100644 index 0000000..94c66b3 --- /dev/null +++ b/lazybox/src/main/kotlin/cfig/lazybox/BootingParser.kt @@ -0,0 +1,90 @@ +package cfig.lazybox + +import org.slf4j.LoggerFactory +import java.io.File +import java.util.regex.Pattern + +class BootingParser { + companion object { + private val log = LoggerFactory.getLogger(BootingParser::class.java) + fun run() { + val logLines = File("booting.log").readLines() + val regex = Pattern.compile("""\[([^]]+)] \[\s*([0-9.]+)]\[\s*(T\d+)] init: starting service '([^']+)'.*""") + for (line in logLines) { + val matcher = regex.matcher(line) + if (matcher.find()) { + val timestamp = matcher.group(1) + val kernelTime = matcher.group(2) + val tLevel = matcher.group(3) + val serviceName = matcher.group(4) + + println("Timestamp: $timestamp, Kernel Time: $kernelTime, T-Level: $tLevel, Service Name: $serviceName") + } + } + } + + fun run2() { + val logLines = File("booting.log2").readLines() + + + val actionRegex = Pattern.compile("""\[([^]]+)] \[\s*([0-9.]+)]\[\s*(T\d+)] init: processing action \(([^)]+)\) from \(([^)]+)\).*""") + val commandRegex = Pattern.compile("""\[([^]]+)] \[\s*([0-9.]+)]\[\s*(T\d+)] init: Command '([^']+)' action=([^\(]+) \(([^)]+)\) took (\d+)ms and (succeeded|failed)(.*)?""") + val svcExecRegex = Pattern.compile("""\[([^]]+)] \[\s*([0-9.]+)]\[\s*(T\d+)] init: SVC_EXEC service '([^']+)' pid (\d+) \(([^)]+)\) started; waiting\.""") + val serviceStartRegex = Pattern.compile("""\[([^]]+)] \[\s*([0-9.]+)]\[\s*(T\d+)] init: starting service '([^']+)'.*""") + + for (line in logLines) { + val actionMatcher = actionRegex.matcher(line) + if (actionMatcher.find()) { + val timestamp = actionMatcher.group(1) + val kernelTime = actionMatcher.group(2) + val tLevel = actionMatcher.group(3) + val actionName = actionMatcher.group(4) + val fromComponent = actionMatcher.group(5) + + println("Timestamp: $timestamp, Kernel Time: $kernelTime, T-Level: $tLevel, Action Name: $actionName, From: $fromComponent") + } + + val commandMatcher = commandRegex.matcher(line) + if (commandMatcher.find()) { + val timestamp = commandMatcher.group(1) + val kernelTime = commandMatcher.group(2) + val tLevel = commandMatcher.group(3) + val command = commandMatcher.group(4) + val action = commandMatcher.group(5).trim() + val fromComponent = commandMatcher.group(6) + val duration = commandMatcher.group(7) + val status = commandMatcher.group(8) + val failReason = commandMatcher.group(9)?.trim() + + println("Timestamp: $timestamp, Kernel Time: $kernelTime, T-Level: $tLevel, Command: $command, Action: $action, From: $fromComponent, Duration: ${duration}ms, Status: $status${if (failReason != null) ", Reason: $failReason" else ""}") + } + + val svcExecMatcher = svcExecRegex.matcher(line) + if (svcExecMatcher.find()) { + val timestamp = svcExecMatcher.group(1) + val kernelTime = svcExecMatcher.group(2) + val tLevel = svcExecMatcher.group(3) + val serviceName = svcExecMatcher.group(4) + val pid = svcExecMatcher.group(5) + val context = svcExecMatcher.group(6) + + println("Timestamp: $timestamp, Kernel Time: $kernelTime, T-Level: $tLevel, Service Name: $serviceName, PID: $pid, Context: $context") + } + + val serviceStartMatcher = serviceStartRegex.matcher(line) + if (serviceStartMatcher.find()) { + val timestamp = serviceStartMatcher.group(1) + val kernelTime = serviceStartMatcher.group(2) + val tLevel = serviceStartMatcher.group(3) + val serviceName = serviceStartMatcher.group(4) + + println("Timestamp: $timestamp, Kernel Time: $kernelTime, T-Level: $tLevel, Service Name: $serviceName") + } + } + + + + + } // end-of-fun + } // end-of-companion +} \ No newline at end of file diff --git a/tools/local/bin/abe b/tools/local/bin/abe index ed14df1..afc8f53 100755 --- a/tools/local/bin/abe +++ b/tools/local/bin/abe @@ -14,13 +14,16 @@ operation=$1 echo arg num: $# echo "args: $0 $1 $2" +source_code_dir=/home/yu/work/boot # Determine which operation to perform +set -x case $operation in "unpack") + cd ${source_code_dir} + pwd if [[ $# -eq 2 ]]; then file=`realpath $2` dir=`realpath out` - cd ${baseDir}/../../../ gradle unpack --args="unpackInternal $file $dir" elif [[ $# -eq 3 ]]; then file=`realpath $2` @@ -33,13 +36,16 @@ case $operation in fi ;; "pack") + pwd if [[ $# -eq 3 ]]; then dir=`realpath $2` file=`realpath $3` - cd ${baseDir}/../../../ + #cd ${baseDir}/../../../ + cd ${source_code_dir} gradle pack --args="packInternal $dir $file" else - cd ${baseDir}/../../../ + #cd ${baseDir}/../../../ + cd ${source_code_dir} gradle pack fi ;;