Re: writing to a partition



Allan Adler wrote:
Kees Theunissen <theuniss@xxxxxxxx> writes:

Allan Adler wrote:
I then edited biosdata.S to produce a file dubiosdata.S in which all the
various capitalized strings are defined explicitly and also inserted an
#define BD_VERBOSE, etc., and also copied the routines say, dsk_do_rw,
pause and bout to dubiosdata.S, as well as the routine putc which bout
uses. The immediate goal of this editorial activity is to produce a
self-contained version of biosdata.S that I can, in principle, study
without having to think about the rest of the lilo source and without
having to use the Makefile and to process it using only techniques that
it would normally occur to me to use (although that palette will hopefully
be enlarged by these experiences).
Despite of the immediate _goal_,

Read "immediate" as "temporary".

when you take parts of complicated
programs out of context -editing some parts more or less at random
without understanding what you're doing-, the immediate _result_ will be
lots and lots of error messages.

I think you need to read the part of my posting where I showed how to solve
that problem in this case.

Yes you showed what you did to solve the problem. You also told that you
had to remove a few single quote chars (') by hand in an intermediate
file. The original Makefile didn't have that problem. Somehow you
introduced this error while trying to reduce the complexity of the part
you want to study. How can you be sure that you didn't also introduce
logical errors in the program? Building a program without errors is
one thing, making it do what it should do is a different thing.


As long as you don't understand the context, the global picture, the way
(Intel) PC's boot, any attempt to simplify LILO will only introduce
errors and complicate the whole thing.
If you want to understand a program you should study that program, not
a modified part of it.

I'm not trying to simplify LILO. If I were to make an analogy, it would
be like seeing a radio tube inside an old TV set, removing it and testing the
tube separately and studying its characteristics or of using it to build
another unrelated device. That is a respectable activity. It would be
incorrect to accuse someone who does that of trying to simply the television
set. Of course, there might be features of using the tube that depend on its
context in the TV set, and that is something one has to keep in mind. But it
is still a good thing to do.

Using/testing a tube or any other single component outside the TV set is
common practice. Trying to isolate a whole functional module like the
deflection system would be more complicated. Are you sure your simple
"radio tube" analogy is valid in this case?

However, since you have a definite opinion about the right way to study
the lilo source, which I'm interested in doing, and since I'm open to
other points of view, maybe you can answer some questions:

There is no single right way to study things (although there a lots of
wrong ways). It just doesn't make sense in my opinion to spend lots of
time in trimming down a complicated but working program if that only
introduces errors. Creating a simple study environment isn't a valid
argument in this case, as you need to study and understand the program
first in order to be able to trim it down in a proper way.

(1) TRUE OR FALSE: When you read a source code file, you read it from
beginning to end without first jumping into the middle of it to
find a part that looks like it might be easier to read or more
interesting. (I'm just guessing that you think the answer is TRUE).

FALSE. Mostly I start grepping to find the things I'm looking for.

(2) There are dozens of source files in the lilo-22.8 distribution.
What is the precise order in which you think they ought to be
read?

I hardly can imagine the need to read all of them. I normally start by
trying to get the big picture of the issue I'm looking for. Details
come later.

(3) Apart from (1) and (2), when you studied the lilo source, what was
your method of going through it and making sure you understood what
was going on?

I never studied the lilo source. But I repaired quite a lot of corrupted
dos/windows boot sectors with only a hex editor as primary tool.
If I would want to write some 'self booting application' like you want
to do, then I would spend most of my time studying the BIOS function
calls. At boot time the BIOS is the only way to interact with your
keyboard, screen and disks.
I would probably start with a simple program that only puts a string
on the screen and enters a infinite loop after that.
After that I would study how to access the disk. I would learn about
different BIOS versions, different extensions to the hard disk
interface, and the different ways to circumvent the hard disk size
limits of previous BIOS versions. I would study how to determine the
current BIOS capabilities and the best way to access the disk.
After that I would extend my program to load some disks sectors in
memory (I'll need some way to pass the location of my partition on
the hard disk, or at least which partition is booting, to the bootstrap
code in the partition's boot sector). While studying the mentioned
BIOS aspects I'll probably see several coding examples that can be used
as a starting point to my program. I might have a look at lilo's boot
sector and borrow some of its ideas and/or code but I would build my
program from scratch, adding functionality pace by pace. I would never
start by trimming a complex program down until just wanted functionality
is left (not sure if you're doing that).

And after spending some time with this I would certainly conclude that
it was a useful exercise, that I learned a lot, but that I want to use
a real operating system to get work done.

Scavenging is a perfectly legitimate activity and it has definite advantages,
both practical and pedagogical.

Your suggestion about reading boot sectors has some merit. I've actually
tried on more than one occasion and was unsuccessful. Maybe after the present
effort, I'll be better prepared to try it again in the future.

Regards,

Kees.

--
Kees Theunissen.
.



Relevant Pages

  • Re: How to use a corrupted hard drive as an external hard drive
    ... Do I just attach it and boot the computer like normal? ... Thank you in advance for any guidance you can give me as I am technically challenged and attaching all the cables correctly is a challenge. ... should see the identity string in the BIOS screen. ... as they exist on the disk). ...
    (microsoft.public.windowsxp.hardware)
  • Re: Grub hangs - two hard drives and a CD
    ... > What you wrote is all based on a wrong assumption that grub numbers drives ... > that the BIOS will call to boot an OS. ... The Bios calls to read disk require the register DL to ...
    (comp.os.linux.setup)
  • Re: maximum hard drive size in Latitude cpi
    ... > actually written a boot loader they won't be so adamant about how "Windows ... > of the disk, and while it is being read off of the disk the machine is ... > limitatoins of that BIOS. ... After that the kernel takes over. ...
    (comp.sys.laptops)
  • Re: Big-disk woes
    ... And shrink that / partition as well -- it should be as small as ... > of a bad disk. ... I was thinking bios all this time. ... grub only needs BIOS to find the boot dir to load the ...
    (comp.os.linux.setup)
  • Re: UEFI secure boot
    ... own boot sectors. ... the bios to sign code The flaw with this idea, I suppose, it might be ... medical mistake deaths in the US than there are accidental gun deaths. ...
    (Ubuntu)