WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Magical research?  (Read 3158 times)

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Magical research?
« on: October 14, 2011, 08:48:22 PM »
I'm interested in how the "magic" in files is determined and at what level of the os this happens.

In particular, where is the shebang detected for an executable script?
Is this a function of the shell or of the kernel or something else?
Is it configurable via some config file or will I have to recompile something?

The problem I am trying to solve is that I have an interpreted language (mumps) that I would like to use for scripting, but it uses the semicolon and not the hash symbol as a comment marker.
So I'll need to use a shebang like
Code: [Select]
;!/path/to/interpreterinstead of
Code: [Select]
#!/path/to/interpreterGT-M mumps is in the 1.x tce repo as gtm5.tce.  ( The maintainer of that extension -really- needs to update it.  :)  )

Can anyone point me to what I need to change?

(No, I haven't yet asked the GT-M devs about changing the interpreter to accommodate starting a script directly.)
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline vitex

  • Full Member
  • ***
  • Posts: 113
Re: Magical research?
« Reply #1 on: October 15, 2011, 12:10:06 AM »
One mechanism is via the kernel.  See binfmt_misc and Kernel Support for miscellaneous (your favourite) Binary Formats v1.1.

I have used this capability to cross-develop an embedded ARM file system on x86 Linux by telling the x86 kernel to execute ARM programs by passing those programs to an x86-hosted version of qemu that emulates the ARM processor.



Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Magical research?
« Reply #2 on: October 15, 2011, 02:25:36 AM »
libc, I suppose. binfmt_misc is disabled in our builds.
The only barriers that can stop you are the ones you create yourself.

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: Magical research?
« Reply #3 on: October 15, 2011, 06:01:59 PM »
Quote
binfmt_misc is disabled in our builds

That would explain why I got nowhere with it (well, that and my utter lack of knowing what I was doing).

The links posted by vitex were informative and seemed to be taking me right where I needed to go.

Any likelihood of seeing binfmt_misc in a future tc kernel?  I don't know if there might be some large impact on size, or performance (or stability or security...)

32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Magical research?
« Reply #4 on: October 16, 2011, 03:26:28 AM »
Well, I believe there's a small overhead on every binary exec with it enabled, to check whether the binary is special.
The only barriers that can stop you are the ones you create yourself.