:: Re: [DNG] Mini init script written …
Kezdőlap
Delete this message
Reply to this message
Szerző: Adam Borowski
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] Mini init script written in Perl boots.
On Thu, Jun 16, 2016 at 10:47:42PM +0200, Irrwahn wrote:
> For the record: Should I ever find myself sitting at a
> machine running a Perl interpreter for PID1, I'd either
> immediately kill myself or drink the SystemD Kool-Aid
> by the gallon. (The net effect not being that different.)

On Thu, Jun 16, 2016 at 02:14:48PM -1000, Joel Roth wrote:
> I did a test with Memory::Usage, that reports the
> interpreter's virtual memory size as 22MB. Seems cheap
> to me.


Yeah, we need to use an efficient language!

.globl _start
.data
nopid1:    .ascii "No pid 1, no fun.\n"
command: .ascii "/sbin/osloader.sh"
norc: .ascii "Starting /sbin/osloader.sh failed!\n"
.text
_start:
    mov    $39, %rax    # getpid
    syscall
    cmp    $1, %rax
    je    pid1
    mov    $1, %rax    # write
    mov    $1, %rdi
    mov    $nopid1, %rsi
    mov    $18, %rdx
    syscall
    mov    $60, %rax    # _exit
    mov    $1, %rdi
    syscall
pid1:
    mov    $57, %rax    # fork
    syscall
    cmp    $0, %rax
    jne    child
parent:
    mov    $61, %rax    # wait4
    mov    $-1, %rdi
    xor    %rsi, %rsi
    xor    %rdx, %rdx
    syscall
    jmp    parent
child:
    mov    $59, %rax    # execve
    mov    $command, %rdi
    xor    %rsi, %rsi
    xor    %rdx, %rdx
    syscall
    mov    $1, %rax    # write
    mov    $1, %rdi
    mov    $norc, %rsi
    mov    $36, %rdx
    syscall
    mov    $60, %rax    # _exit
    mov    $1, %rdi
    syscall


Hmmm... I think I'd go with Perl after all.

Meow!
--
An imaginary friend squared is a real enemy.