From mboxrd@z Thu Jan 1 00:00:00 1970 From: ron minnich To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] getting sdC0/nvram right in /bootdir Date: Fri, 7 Nov 2003 22:19:20 -0700 Topicbox-Message-UUID: 82e3632a-eacc-11e9-9e20-41e7f4b1d025 Recap: I am loading Plan 9 direct from linuxbios, no 9load. Factotum, run out of bootdir, is not seeing disk partitions, in particular #sdC0/nvram, as no one has set them up to be seen. Normally, 9load sets them up; 9load is not there. Something needs to do that setup. Options are: - rip the code out of 9load to do this - rip the code out of disk/fdisk and disk/prep to do this - something else I looked at 9load, to see how it gets disk partitions set up for factotum to find. Messy, it has to go dig around the disk looking for things. I looked at ripping out bits of fdisk and prep to do the job, essentially having a fdiskprep program in bootdir. Messy, got to rip them here and there and put them back together. Frankencode. Although I must say the way fdisk and prep work and share code is quite slick. So, it seems to me: once I load plan 9 from linuxbios from flash, and we're coming up, we've got all the Plan 9 power there, including the ability to put arbitrary programs into bootdir and run them. What I have found is that writing the program in C that is equivalent to that 'set up the partitions' script in termrc and cpurc is about 20 lines of C code. The code looks like this: - fd = open /dev/sdC0/ctl - if fails, exits - fork, dup(fd, 1), exec disk/fdisk -p /dev/sdC0/data - fails, exits - fork, dup(fd, 1), exec disk/prep -p /dev/sdC0/plan9 That's it. Itsy C program, tested, works fine. So why not: - put disk/fdisk in bootdir, disk/prep in bootdir, and the little program in bootdir - have the little program start right before factotum, and call disk/fdisk and disk/prep Sure, it's more memory. My $8 CF parts are 32MB. Who cares. Is there any real reason not to do it this way? It's easy, that's for sure. Making it iterate over all the devices in nvramtab (in readnvram.c) is trivial. The other option, not taken, is the new linux approach of actually running shell scripts in bootdir (which in linux is called initrd). I think I'd rather wait to do this ... do we really want /bin/rc in bootdir? ron