01:30.36 | *** join/#elinux planetbeing (~planetbei@c-71-236-164-204.hsd1.or.comcast.net) |
01:31.17 | planetbeing | whoa, hey pytey. |
01:31.30 | planetbeing | and roxfan |
01:36.48 | *** join/#elinux linac (~lin@117.25.50.239) |
04:27.22 | *** join/#elinux ZeZu (~null@in-67-236-122-199.dhcp.embarqhsd.net) |
04:39.58 | pytey | planetbeing: hey o/ |
04:43.18 | planetbeing | Quiet here. :) |
04:47.50 | *** join/#elinux linac (~lin@117.25.50.239) |
07:14.32 | *** join/#elinux lyakh (~lyakh@p57BD1C95.dip0.t-ipconnect.de) |
07:14.32 | *** join/#elinux roxfan (dunno@195.216-200-80.adsl-dyn.isp.belgacom.be) |
07:14.32 | *** join/#elinux janinge (j@ninge.net) |
07:14.32 | *** join/#elinux lewellyn (~lewellyn@greenviolet/lewellyn) |
07:14.32 | *** join/#elinux markl_ (~mark@tpsit.com) |
07:14.32 | *** join/#elinux ashes (ashes@modemcable076.241-176-173.mc.videotron.ca) |
07:14.32 | *** join/#elinux CIA-21 (cia@208.69.182.149) |
07:14.32 | *** join/#elinux Aim__ (~frank@office.aivd.net) |
07:14.33 | *** join/#elinux file (~file@asterisk/developer-and-muffin-lover/file) |
07:14.33 | *** join/#elinux Kmarc (kari@kallio.biz) |
07:14.33 | *** join/#elinux ChanServ (ChanServ@services.) |
07:14.33 | *** mode/#elinux [+vo file ChanServ] by farmer.freenode.net |
07:22.34 | *** join/#elinux hw_ (~hw@p578b3905.dip0.t-ipconnect.de) |
07:33.01 | *** join/#elinux hw_ (~hw@p578b3905.dip0.t-ipconnect.de) |
10:21.17 | *** join/#elinux pirho (debian-tor@gateway/tor-sasl/pirho) |
11:21.52 | *** join/#elinux krushia (~krushia@h69-131-86-88.cntcnh.dsl.dynamic.tds.net) |
11:39.56 | *** join/#elinux linac (~lin@122.90.134.22) |
12:05.24 | *** join/#elinux likewise (~likewise@82-171-51-231.ip.telfort.nl) |
12:47.33 | *** join/#elinux gustavoz (~gustavoz@201.253.240.226) |
12:49.26 | *** join/#elinux likewhoa (~likewhoa@ool-45717734.dyn.optonline.net) |
12:53.49 | *** join/#elinux flavioribeiro (~flavio@187.64.42.101) |
13:21.27 | wmat | planetbeing: the chatter comes in waves ;) |
13:21.32 | *** join/#elinux bzzbzz (~franco@modemcable240.34-83-70.mc.videotron.ca) |
13:22.15 | *** join/#elinux pirho (debian-tor@gateway/tor-sasl/pirho) |
13:29.07 | *** join/#elinux linac (~lin@122.90.103.33) |
14:56.17 | *** join/#elinux mnemoc (~amery@shell.opensde.net) |
15:43.57 | *** join/#elinux Pupuser402 (~puppy@pd95b6ec5.dip0.t-ipconnect.de) |
15:47.07 | *** part/#elinux Pupuser402 (~puppy@pd95b6ec5.dip0.t-ipconnect.de) |
15:48.39 | *** join/#elinux markl (~mark@tpsit.com) |
16:35.15 | *** join/#elinux GPSFan (~kenm@64.92.145.112) |
17:23.56 | *** join/#elinux ibot (ibot@rikers.org) |
17:23.56 | *** topic/#elinux is Embedded Linux || http://eLinux.org/ || cross compile, uClibc, busybox, handhelds, post-sale linux installs ;-), etc. |
17:23.58 | *** mode/#elinux [+o ibot] by ChanServ |
17:34.58 | *** join/#elinux roxfan (dunno@91.181.60.178) |
17:49.59 | *** join/#elinux toi (~toi@d54C2A96D.access.telenet.be) |
17:58.26 | *** join/#elinux ersin (~quassel@c-76-100-172-199.hsd1.md.comcast.net) |
17:58.33 | ersin | hi everyone |
17:58.40 | ersin | i've got a question about init |
17:58.45 | ersin | specifically, busybox init |
17:59.03 | ersin | busybox has an option for building init without support for inittab |
17:59.40 | ersin | ideally, i want to avoid using init at all; i've actually been trying to just use an init script that boots straight into single user mode w/ a shell |
17:59.58 | ersin | but that hasn't been working because i can't get job control, which is why i'm now trying to use a real init program |
18:00.09 | ersin | however, i would really, really like to avoid using an inittab file |
18:00.14 | ersin | and busybox seems to support this |
18:00.27 | ersin | my question is, how on earth does an init program work w/o an inittab file =P? |
18:00.52 | ersin | can i somehow just tell it to run a shell...? |
18:10.57 | *** join/#elinux pirho (debian-tor@gateway/tor-sasl/pirho) |
18:16.38 | planetbeing | ersin, I'm not very familiar with this myself, but what's wrong with writing an inittab? |
18:17.35 | ersin | aesthetic concerns...i'm creating a small experimental distro to test out some ideas i have about distro design and i'm trying to avoid files in /etc |
18:17.46 | ersin | so...nothing technical, lol |
18:18.43 | ersin | the weird part is that i just tried using busybox's init applet without the inittab support compiled in, and when i don't have a symbolic link from /bin/sh to /bin/ash it complains that "-/bin/sh" failed to run |
18:18.52 | ersin | which means that it's trying to run it by default, which would be fine for me |
18:18.53 | ersin | but |
18:19.15 | ersin | when i DO put in the symbolic link or rename ash to sh, it does what you'd expect: absolutely nothing |
18:20.05 | planetbeing | Hmm. |
18:20.09 | ersin | sorry, i should be more specific here |
18:20.18 | planetbeing | What I don't get is why it doesn't work if you just have bash BE init. |
18:20.31 | ersin | right |
18:20.38 | ersin | well, not bash but busybox's ash |
18:20.38 | planetbeing | The kernel just executes whatever program is named that and gives it /dev/console. |
18:20.52 | planetbeing | Right. Which might take cues from the command line on what to do. |
18:20.52 | ersin | well according to many e-mails on the busybox list |
18:21.08 | ersin | giving /dev/console is incorrect and results in "no job control" errors |
18:21.23 | ersin | instead, i'm supposed to give a "controlling tty" like /dev/tty1 or some such |
18:21.33 | ersin | but i can't seem to do that w/o an init program |
18:22.13 | planetbeing | You'd need a wrapper that opens up the /dev/tty1 and gives that console to bash. |
18:23.01 | ersin | not sure what that might look like...(i should note that there is something in busybox called "cttyhack" that i think does something similar to what you're proposing, but it doesn't work for me) |
18:23.18 | planetbeing | Hmm, what if you just have a shell script execute: /sbin/getty 38400 tty1? |
18:23.22 | planetbeing | as your init. |
18:23.38 | ersin | doesn't getty usually require a login? |
18:23.50 | planetbeing | Yes. |
18:23.59 | ersin | =) |
18:24.06 | ersin | that won't do, then |
18:24.08 | planetbeing | You just want something without a login? |
18:24.10 | ersin | all single user |
18:24.10 | ersin | yep |
18:25.23 | planetbeing | How about /sbin/getty -l /bin/ash 38400 tty1? |
18:25.34 | planetbeing | Use /bin/ash as the login prompt. :P A bit hacky but worth a try. |
18:25.39 | ersin | lol |
18:25.44 | ersin | i'll try it, just a sec |
18:26.42 | planetbeing | If that doesn't work, you might just change inittab to add the -l /bin/ash argument, if the main thing you're going for is no login prompt. |
18:27.06 | ersin | nope, kind of have to have both |
18:27.10 | *** join/#elinux Kmarc (kari@kallio.biz) |
18:27.19 | ersin | i'm really surprised that there isn't some simpler way... |
18:28.03 | planetbeing | I wonder if you can just directly have a shell script do something like /bin/ash &> /dev/tty1 < /dev/tty1 |
18:28.25 | ersin | i've tried that, too |
18:28.34 | ersin | still get job control errors |
18:29.01 | planetbeing | Perhaps it fails because ash is required for the shell script to work and ash will refuse to work when given /dev/console as stdin/stdout. |
18:29.13 | ersin | yes yes, i was wondering that myself |
18:29.29 | planetbeing | I'm just speculating, but I thought you might at least want SOMEONE to respond instead of just talking to yourself. :) |
18:29.46 | ersin | haha, i appreciate it, thank you |
18:29.49 | ersin | ok firing up virtualbox... |
18:30.20 | ersin | lol |
18:30.24 | ersin | i got a login =( |
18:31.26 | ersin | ok so about the ash being the shell that executes the script thing |
18:31.51 | ersin | i tried making my own init program that does a few system calls to run the appropriate programs, basically just rewriting my script in c |
18:31.56 | planetbeing | Right. |
18:32.04 | ersin | when i compiled statically and put it in my initramfs, however, it just didn't run at all |
18:32.09 | ersin | and i chmod 755 and all |
18:32.26 | planetbeing | You sure it compiles correctly? |
18:32.39 | ersin | yep, it ran fine on my host machine |
18:32.54 | planetbeing | Have you tried running it from the device? |
18:33.02 | *** join/#elinux GPSFan (~kenm@64.92.145.112) |
18:33.05 | ersin | yeah...well, in virtual box |
18:33.40 | ersin | haven't yet tested anything on actual hardware...well, i was using real hardware a long time ago, and i had the exact same problems w/ job control, so i know that it's not a hardware issue |
18:33.59 | planetbeing | Can you pastie the source to the program? |
18:34.08 | ersin | yep, one sec |
18:34.13 | planetbeing | It might be best to start off with a simple printf and then while(1); to make sure SOMETHING runs. |
18:35.05 | ersin | http://pastie.org/875862 |
18:35.22 | ersin | compiled with "gcc -static ./init.c" |
18:35.26 | planetbeing | Oh no, system won't work at all. |
18:35.30 | planetbeing | That depends on a shell being present. |
18:35.34 | ersin | haha |
18:35.38 | ersin | alright, what do i use? |
18:35.41 | planetbeing | Use execv. |
18:35.45 | ersin | aha |
18:35.47 | planetbeing | It's a bit. Complex. |
18:35.56 | planetbeing | Well, more complex to use than system. |
18:35.58 | ersin | looks up |
18:39.02 | planetbeing | Here's some code I wrote once to be like init: http://code.google.com/p/independence/source/browse/trunk/iNdependence/Other+Files/RAMdisk/boost.c?r=308 |
18:39.09 | planetbeing | It's for a BSD-ish OS, but principles should be the same. |
18:40.13 | planetbeing | It's a little more involved (with assembly syscalls) since I couldn't depend on even libc being available. |
18:42.36 | planetbeing | In utilities.c there's a cmd_system that you can use. You have to separate the arguments out into an array of strings. There's usage examples in jailbreak.c. Should be the same for LInux |
18:42.54 | planetbeing | I guess it might be easier than figuring out the syscalls required for mounting in Linux. |
18:43.20 | ersin | hmm |
18:43.37 | ersin | i'm trying out the execv thing right now, but i will take a look at utilities.c, too |
18:44.03 | planetbeing | execv will replace your current process. |
18:44.16 | ersin | oh |
18:44.19 | planetbeing | So once you run it, you don't get back control. You have to use fork() to start a new process first. |
18:44.35 | ersin | i see |
18:44.51 | ersin | man this feels way more hardcore than i thought it would be |
18:45.05 | planetbeing | There's probably a simple solution we're missing. :) |
18:45.11 | ersin | i'm really surprised that my usage case doesn't come up more often |
18:45.14 | ersin | yeah lol |
18:45.37 | planetbeing | But sometimes things are like that. I still for the life of me can't figure out how to disable the "feature" that Linux has of blanking the framebuffer console when there has been inactivity. |
18:45.50 | ersin | hahaha |
18:46.20 | planetbeing | Believe it or not, I think that's hardcoded into the kernel for some ungodly reason. |
18:48.14 | ersin | so for utilities.c, is it as simple as separating the arguments and passing it to cmd_system? |
18:50.00 | ersin | oh silly me |
18:50.07 | ersin | this is basically a wrapper to do the forking for me =) |
18:51.38 | planetbeing | Yes. :) |
18:55.39 | planetbeing | Okay, I just solved my problem btw with LXR. echo 0 > /sys/module/kernel/parameters/consoleblank. Though it does sort of suck that the source is oftentimes the only documentation. |
18:55.59 | ersin | oh, congrats! i'll have to keep that in mind |
18:56.09 | ersin | the focus of the distro i'm making is going to be on framebuffer apps =) |
18:57.02 | planetbeing | According to the source, that particular feature is in drivers/char/vt.c, and it'll only attempt to do that if the console is in "text mode". So it might not affect you depending on what you're doing. :) |
19:00.44 | ersin | doh lol |
19:01.07 | ersin | hey, do you know what to do about "exec" calls in my script...? |
19:01.13 | ersin | i mean...are those just execv calls...? |
19:01.30 | ersin | like i have "exec </dev/tty0 >/dev/tty0 2>/dev/tty0" |
19:01.48 | ersin | would i just pass cmd_system four separate arguments in the array? |
19:02.09 | planetbeing | Hmm, you would open /dev/tty0 |
19:02.14 | planetbeing | with the open syscall. |
19:02.24 | planetbeing | And then dup those file descriptors over stdin, stdout and stderr. |
19:02.31 | planetbeing | And then execv ash or whatever. |
19:02.41 | ersin | O_O i feel like such a noob |
19:03.56 | planetbeing | haha. Well. The idea is that when you fork(), the resulting process is a "child" process of the original process you forked from. It's also an exact clone and it inherits all the file descriptors its parent has. |
19:04.29 | planetbeing | stdin, stdout, and stderr are just file descriptor numbers 0, 1 and 2. |
19:04.46 | ersin | oh...so then when i fork ash it will inherit the three |
19:04.52 | ersin | which are "linked" to tty |
19:05.07 | *** join/#elinux likewise_ (~likewise@82-171-51-231.ip.telfort.nl) |
19:05.20 | planetbeing | Right. The tty is opened as a file (and you might want to use ioctl to assign the baud rate, etc. at this point) |
19:05.29 | planetbeing | And then you fork to whatever other process you want. |
19:06.15 | ersin | i see. so then i'd just use something like dup2(ttyfd, 2)? |
19:07.31 | planetbeing | Yes. |
19:08.30 | planetbeing | Theoretically, at any rate. I've only tried to do it with files. |
19:11.59 | ersin | err...hmm |
19:12.19 | ersin | i'm getting errors like WNOHANG undeclared, SIGCHLD undeclared... |
19:12.39 | ersin | i'm including all the files that are included in utilities.c, save for the corefoundation stuff |
19:13.08 | planetbeing | #include <sys/wait.h> probably. |
19:13.16 | planetbeing | The headers'd be different for BSD and Linux. |
19:13.18 | planetbeing | http://www.delorie.com/gnu/docs/glibc/libc_569.html |
19:13.58 | ersin | aha, thanks |
19:24.41 | ersin | planetbeing: lol well none of that worked, i got a whole bunch of errors |