2

I am trying to modify Mint 13(ubuntu derivative)'s initrd. The main idea is for a program I am making to be run by the local-top script. That is - when the kernel is started and loads the initrd, my program has to be in that initrd and run before the initrd is unloaded from the ram. Basically I want to show windows and use some of the ncurses lib functions, but I get an error. I have included the library in my initrd file ofcourse. The error I get is: Error opening terminal: linux.

Perhaps someone here has an idea on how to fix that?

M. Ivanov
  • 283
  • 1
  • 2
  • 13

1 Answers1

4

It is not enough. Ncurses has a lot of terminal files, they are probably in /etc/terminfo. The actual terminal type is stored always in the TERM environment variable, this is probably "linux" by you. The goal of this structure is to make the ncurses applications compatible, or at least usable anywhere. For example, a wyse terminal (ancient terminal from the antediluvian era) has absolutely different control sequences, as a linux or a freebsd console.

Only copying the library isn't enough, you need to copy /etc/terminfo/l/linux as well.

Maybe further files can be needed, this can you test with a strace command (if you can't interpret its output, google is your friend or we are waiting your next question). The syntax:

strace -s 200 -f -o sux.txt ./theCommandToTest

It will dump the kernel call log of the ./theCommandToTest into the sux.txt text file.

Anyway, to test this thing, the best solution if you boot your linux in a command shell (f.e. use the init=/bin/bash boot option, or you call a simple bash from the local-top). So you will be able to run this strace, and play with this, to find out, what can be yet needed.

Good luck!

peterh
  • 11,875
  • 18
  • 85
  • 108
  • 1
    Hello, many thanks for the information you've provided me with. I just tried adding the terminfo files(I did not know that older terminals used different seqs). The result is I no longer get that error, but I get a freeze(currently local-top automatically starts my app). Also it's not exactly a freeze, as I clicked multiple times where the window should be(but apparently is not shown) and got an message stating that some program might be trying to access hardware devices directly. Tomorrow I will try using strace as well so I can get more of an idea what's exactly happening. – M. Ivanov Dec 12 '13 at 22:59
  • Click? On character console? It is possible (google for: gpm console linux), but it is not really probable. – peterh Dec 13 '13 at 08:39
  • Ok, so now I can run ncurses apps in initramfs enviroment, but I still can't use the mouse. So currently I am trying to figure out how to put gpm or something else in my initrd and load it.(I tried just copying the gpm binary but it didn't worked as expected or perhaps I did something wrong). – M. Ivanov Dec 14 '13 at 21:53
  • gpm needs some config, too. It is better to tune gpm on a running system first, and only as a secondary step migrate this to your initrd. But you are doing well! Exactly so well, as the russian(?) programmers can do. :-) I am sure, you could learn this strace-thing (and with it, he unix kernel api) fast. Ncurses has connectivity to mouse, it can handle mouse clicks from gpm on the char console, or also running in a xterm window, although I never programmed it. – peterh Dec 14 '13 at 22:42
  • Thank you for all your help, I appreciate it. Now I know how do all this, but I am opting for more - I want to use graphics, ncurses is not enough my purposes. I learned how to use SDL - it has mouse and keyboard support out of the box. Problem is - it uses /dev/fb0 and I can't seem to understand the concept behind it. I can get it to appear by passing vesafb:mtrr,ywrap vga=0x319 to the kernel, but I heard that's deprecated. Also using module files like /etc/modules, blacklists, etc. The real problem is when I use Xen. I can't get /deb/fb0 to appear at all. – M. Ivanov Dec 20 '13 at 21:35
  • In your place I used an Xvfb (X virtual frame buffer), running SDL on it, and contacted this through vnc. It could work everywhere, in a vm or also on a host OS, although required the cooperation of 3 complex systems. – peterh Dec 21 '13 at 00:24
  • I understand how that works, but I am not sure if it will help. I get it that by using Xvfb I can use a virtual buffer and do stuff with it, but to display it I still need a real one connected to my screen. If I had 2 systems - one with Xvfb, x11vnc for example, and another with real x11 server and vnc client, that would work. But I need everything to be on one machine(laptop with no support for VT-D(also called IOMMU)). Also I still can't understand how does the x11-server works without /dev/fb0 device, yet everything else - SDL,DirectFB,etc. fails. – M. Ivanov Dec 21 '13 at 14:05
  • paravirtualized xen has only char console, and so. It has not graphical card. It is effective a very sophisticated chroot/jail. In your place I used vmware, because with it you have better chance for goodpaid jobs. Although as a hobbyproject I used virtualbox, because it is opensource and much better, although not so userfriendly. – peterh Dec 21 '13 at 21:50
  • Well, I know I can use VirtualBox, but the idea to use Xen is to increase security without wasting hardware resources. Perhaps you have read about Qubes OS. It's a Linux based on the idea of using multiple Doms for different apps to create isolation. The problem is my laptop doesn't support IOMMU, so Qubes OS is not an option really(it can work, but has too many problems, Qubes is much more than Linux with Xen). So I am trying to create the following: Grub boots Xen, Xen boots Kernel, Initrd is loaded, a graphic application is started, then it's killed,initrd fs is unloaded, real fs is mounted – M. Ivanov Dec 21 '13 at 22:00