Jump to content











Photo
- - - - -

Extract USB functionality from a linux distro.


  • Please log in to reply
32 replies to this topic

#26 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 27 February 2013 - 11:30 AM

Cod,

  Again thank you; I'm getting ready for my torture session,so will have to wait a few hours to play with it, but I did download your ini.

I believe the trick is,in,menu.lst to use:  kernel (hdx,y) /path/to/initrd/scriptname ?

  I guess initshell refers to "the" initscript contained in the initrd?

  Drawing a blank on "vga=789; it has to do with a parameter in the init? I will study it later

I tried the ini and vm from geexbox, and it is very shallow compared to the one in tc minimal but there is indeed the smaller footprint.

Please furnish one example of a cat filter!

 

As for gpm, I have toyed with it. Very messy. Has a library 'lgpm'. Tried to compile the samples,includes broken. So I installed gpm

using package manager, copied out the lgpm compatible with the distro, and disinstalled the gpm. Now the samples could compile.

  In the simple demo prog, I stripped out most of the source code, and got the basic thing to work. Problem was the reporting of the mouse events stays on the screen,and worse yet, I couldn't grab tne values(I now believe I could have grabbed them by mounting

stdout as a partition,etc.)

 

PS,

The command lines I have been using for cpio:

 

cpio -id < /path/to/initrd ;and

 

find . | cpio --create --format='newc'  > //path/to/newini;

 

rename(mv) newini to initrd, use gzip initrd to repack it. I learned the hard way

to execute the first line from the target directory of the opened ini files; same with the other line, other wise you get a nice 4 GB initrd after watching paint dry. See u later.



#27 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 27 February 2013 - 11:39 AM

  •  

 

Cod,

  Again thank you; I'm getting ready for my torture session,so will have to wait a few hours to play with it, but I did download your ini.

I believe the trick is,in,menu.lst to use:  kernel (hdx,y) /path/to/initrd/scriptname ?

  I guess initshell refers to "the" initscript contained in the initrd?

  Drawing a blank on "vga=789; it has to do with a parameter in the init? I will study it later

I tried the ini and vm from geexbox, and it is very shallow compared to the one in tc minimal but there is indeed the smaller footprint.

Please furnish one example of a cat filter!

 

As for gpm, I have toyed with it. Very messy. Has a library 'lgpm'. Tried to compile the samples,includes broken. So I installed gpm

using package manager, copied out the lgpm compatible with the distro, and disinstalled the gpm. Now the samples could compile.

  In the simple demo prog, I stripped out most of the source code, and got the basic thing to work. Problem was the reporting of the mouse events stays on the screen,and worse yet, I couldn't grab tne values(I now believe I could have grabbed them by mounting

stdout as a partition,etc.)

 

PS,

The command lines I have been using for cpio:

 

cpio -id < /path/to/initrd ;and

 

find . | cpio --create --format='newc'  > //path/to/newini;

 

rename(mv) newini to initrd, use gzip initrd to repack it. I learned the hard way

to execute the first line from the target directory of the opened ini files; same with the other line, other wise you get a nice 4 GB initrd after watching paint dry. See u later.


 


#28 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 27 February 2013 - 11:46 AM


     
    United States

Posted A minute ago

     

Quote

 

Quote

Cod,

  Again thank you; I'm getting ready for my torture session,so will have to wait a few hours to play with it, but I did download your ini.

I believe the trick is,in,menu.lst to use:  kernel (hdx,y) /path/to/initrd/scriptname ?

  I guess initshell refers to "the" initscript contained in the initrd?

  Drawing a blank on "vga=789; it has to do with a parameter in the init? I will study it later

I tried the ini and vm from geexbox, and it is very shallow compared to the one in tc minimal but there is indeed the smaller footprint.

Please furnish one example of a cat filter!

 

As for gpm, I have toyed with it. Very messy. Has a library 'lgpm'. Tried to compile the samples,includes broken. So I installed gpm

using package manager, copied out the lgpm compatible with the distro, and disinstalled the gpm. Now the samples could compile.

  In the simple demo prog, I stripped out most of the source code, and got the basic thing to work. Problem was the reporting of the mouse events stays on the screen,and worse yet, I couldn't grab tne values(I now believe I could have grabbed them by mounting

stdout as a partition,etc.)

 

PS,

The command lines I have been using for cpio:

 

cpio -id < /path/to/initrd ;and

 

find . | cpio --create --format='newc'  > //path/to/newini;

 

rename(mv) newini to initrd, use gzip initrd to repack it. I learned the hard way

to execute the first line from the target directory of the opened ini files; same with the other line, other wise you get a nice 4 GB initrd after watching paint dry. See u later.


 
 



#29 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 28 February 2013 - 07:19 PM

Hello dense,

(1) I believe the trick is,in,menu.lst to use: kernel (hdx,y) /path/to/initrd/scriptname ?
(2) I guess initshell refers to "the" initscript contained in the initrd?

not quite correct.

(2) Script 'init' within 'initrd' is always processed. It's neither selectable nor avoidable. A kernel parameter 'init=...' exists, but it corresponds to the initial binary (not script) of 'rootfs' (the main program of GeeXBox; default value is '/sbin/init'). This is perhaps a way to integrate an additional script 'in the middle' after loading the squashfile 'rootfs' (by 'init' script), but before using it.
Usage of  'initshell' means "use the shell within 'init' and do not proceed". You may not allocate a variable, a path or whatsoever to this parameter. Exit to shell happens just when kernel parameters are parsed by 'init' as soon as 'initshell' appears in the sequence.

(1) Answered by (2). The common way would be 'init=/anywhere/myowninit' as kernel processed parameter, but you have to compile a kernel with this ability first. Kernel 'vmlinuz' from GeeXBox distro doesn't take notice. It just passes the whole commandline to the basic initrd system ( file '/proc/cmdline') and script 'init' processes and uses it.'vga=789' is an example for a kernel used parameter (chooses 1024x768 pixel screen, AFAIK). With 'vga=ask' you normally get a list of all available modes (in hex: 0x315=789d)
 

Please furnish one example of a cat filter!

1. Example with 'cat'
cat /proc/partitions | grep sda[0-9] | sed -e 's#^.*\ s#s#g'

Result:


sda1
sda2
sda5
sda6

2. Example without 'cat'
(copy script to a file 'script1' and make it executable with 'chmod +x ./script1'
 

 

#!/bin/sh

while read a b size name; do
  [ -z $name ] && continue
  [ "$name" = "name" ] && continue
  [ "`echo $name | grep -v 'sda'`" != "" ] && continue
  echo -e size=$size    name=$name '\n'
done < /proc/partitions

Result on my system ( size unit is kiB ):

 

size=293036184   name=sda

 

size=147099141   name=sda1

...

 

size=3799341   name=sda6

 

For informations on parameters and syntax of the involved Linux commands, use manpages. 'PartedMagic' for instance offers an online access to http://www.linuxmanpages.com from within the shell prompt ( e.g  'man sed')
 



#30 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 01 March 2013 - 02:51 PM

COD11,

I tried the initrd you posted, and reboot did nothing at all;shudown did nothing at all;even exit did nothing, but at least no kernel panic!.

 

As for passing startup from grub4dos, I have to say recompiling the kernel *seems* a bit much.(maybe not)

 

I tried gpm again, and the situation is even messier. While still using ubu10, I was able to "steal" some measure of it's functionality.

   Now,at least with mint14, I can't even see a 'libgpm' explicitly; it used to be an ar archive, but is now only an .so2 link, and worse,

there is no target for the link listed with 'properties'.

  In fact, even back then, the sample code would say: "cannot be run in console mode" , meaning it requires heavy xterm,ncurses,etc;

this certainly defeats my purpose.

 

  This leaves mc, or do without the mouse. It's just that I'm irqed(pun?) by the fact that I can choose to make mouse-function with a few

kilobytes in dos, but need at least ten to twenty times that in linux.

  The mouse used to be simple in linux, but was changed for *security reasons*!!: the old style arrangment furnished a vector for malware

by way of the browser through the old way of handling mouse events. So modern linux is a nanny-state with no option for playtime. Oh well.

 

  I confess that I have been only hal-assed in the art of linux, and had ignored grep and such; I have to admit that grep eliminates quite a

few lines of c code! Also, I did not realize how "high level" *nix script could be, perhaps rivaling c code at times. Looks like I have some

studying to do.

 

  BTW, I really like that mediafire stuff;gotta get me some.



#31 COD11

COD11

    Member

  • Members
  • 63 posts
  •  
    Germany

Posted 01 March 2013 - 06:01 PM

Hello dense,

I tried the initrd you posted, and reboot did nothing at all;shudown did nothing at all;even exit did nothing, but at least no kernel panic!.

My bad, there was a wrong path to 'fn' in 'shutdown'. When I stripped off my debug echoes I  accidentaly removed more than I wanted ... and didn't test it afterwards.

 

So here is hopefully a working 'initrd1' :http://www.mediafire...zlvvz8gkz9my6b6

 

Now,at least with mint14, I can't even see a 'libgpm' explicitly; it used to be an ar archive, but is now only an .so2 link, and worse, there is no target for the link listed with 'properties'.

 

'mc' shows the link target in the status line if you highlight the link ... and the target is of course a bigger lib-file.

Or use 'ls -L' at the prompt (resp. in a terminal window). Note, that Linux is CaSe SeNsItIvE (ls -L = lower L lower S  [space] minus upper L). There are several common lib-directories ( /lib, /usr/lib, /usr/share/lib) ... and programs may use their own location anywhere.

 

This leaves mc, or do without the mouse.

 Ok, you noticed that 'mc' works with the 'gpm' mouse.  I'm no c-programmer, neither in DOS/Windows nor Linux although my computer roots origin from DOS in the late '80s ( a little bit x86-Assembler with use of DOS-Interrupts, BASIC and script languages under Windows ... and Linux scripts since a few years). Therefore I can give you no hints for the mouse integration.

 

Is it really necessary to have a working mouse at the shell prompt ?  What for ? Isn't it a sideshow ? Writing of scripts for testing is possible with the built-in editor of 'mc'. Copy actions, renaming or deleting files/folders are a domain of 'mc'. I thought, you looked for a way to automatically copy something to a USB connected storage medium, but not to do it manually (or on mouse paws) from the Linux shell. If it's not top secret or with criminal intent, I would appreciate to get your workflow sketched.



#32 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 03 March 2013 - 06:28 PM

COD11,

  I tried your 'initrd1' and it would only do a cold reboot, so I will have to study what you did;

 

As for the need for the mouse, I used to type reasonanly well years ago(to copy high speed morse); but find that lately, I am rather "fat-fingered" , so I like to minimize the use of the keyboard.

 

Speaking of the mouse, I booted up the minimal tinycore, did" sudo mount /dev/input/  /mnt/mows (after mkdir mows in /mnt);

cd mnt

cd input/

cd mows, and found "mouse0" . then:

 

sudo sh ./mows, and the system responded to the mouse!; unfortunately,it just put gibberish on the screen and eventually broke something, necessitating a reboot.

  So I mounted the ext4 from the mint, and copied the "mouse0" to there for further study; unfortunately, it was empty, suggesting it has to be written up by something in the rootfs, the kernel, or both.

  I couldn't even copy it to the xp partition for analysis of it's header with a hex editor, got message "can't open specicial file".

I am reasonably certain that the tc system implements the mouse with some form of xtemr-ncurses, which would make it useless for the purpose, which is a lite mouse event function. Finally, I  tried to back in from the file "getmouseevent.c" in GPM but was quickly stumped by refeences to structs and such which are evidently buried all over the place in share libraries.

 

  I suppose I could make the light gui to use the arrow keys as a "touchpad" of sorts...

Finally, I am about to do the mediafire thing, and if you like, I could post a copy of the dos executable, which requires nothing more than a simple '98 type startup disk to run. The source will have to wait a bit, since in it.s present form, it is like assebly code-nee spaghetti thrown at the wall; I have to clean it up, with better commenting. -dense



#33 dense

dense

    Member

  • Members
  • 56 posts
  •  
    United States

Posted 06 March 2013 - 03:45 AM

COD11,

Forgive the delay; spent the last three days obcessed with this:

A tiny footprint program rquiring no xterm-ncurses-gpm-etc;runs in raw console mode or gui terminal window, and reports all mouse events!

 

 

The only thing holding it up is to get the events clutched to a cursor. No "gotoxy()" in linux; It is in "gconio.h" for linux, but it also has an

"fflush()"  which does not work properly, and it's the one which gets invoked by the mouse program.

Got the core of it from a gentleman at the tinycore forums.

 

  Have a mediafire deal now, and will shoot you the lite gui for dos, after I rectify a nasty bug I just noticed concerning drive letters:

It will warn you to insert media or abort; but if a drive(say logical) doesn't exist, it gives no warning if the code expects it from

use on another machine. I have to clean this up, but if you tell me the drive letter of your cdrom in dos terms I can whack it in there

ad hoc so you can get an idea of the thing.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users