A TWO-HAMBURGER PROBLEM

Copyright Dr Alan Solomon (1986-1995)

I've  been  around.   I  know  DOS.  I've seen things that'd curl your
whiskers;  I've seen some disks, all kinds  of  disks,  disks  that've
suffered  total  trashing.   I've  seen it all, screwed up FATs, disks
that've somehow lost their Format, but ...  I've never  seen  anything
like  it,  never seen anything like it, never seen anything like it in
the world.

When Phil phoned me up and said he had a file with  a  four  character
extension,  I was surprised.  I thought that DOS had played its entire
repertoire of tricks on me - this was a new one.  I often repair disks
for people;  usually it takes me a few hours, and people are delighted
to pay for not having to rekey weeks of work.  So I've seen  disks  in
all states.  The commonest are disks that have been completely deleted
- the common disk repair utilities like Norton or my own UnDelete only
work if all files are contiguous, which is rarely the case.  And it is
usual that the most important file on the disk is fragmented,  and  it
needs RI (real intelligence, as distinct from AI, the artificial kind)
to piece things together again.  But I've also had disks in which  the
directory  was  overwritten  by a third copy of the FAT (don't tell me
that's impossible;  I know).  I've had  a  disk  containing  one  file
called ARTHUR, which was 0 bytes long, and which Norton couldn't touch
(nor would my own Undelete), and which needed RI to fix.   I've  often
wondered why disks have two copies of the FAT;  if one gets corrupted,
DOS doesn't know which one is correct.  Why aren't there three?   I've
seen  a disk with one copy of the FAT corrupted, and one OK - I had to
decide which one was the real FAT.

I've been hugged by people who thought they'd never see 25 MB of names
and  addresses  again, I've seen tears on the eyes of a man who'd been
developing a program for 7 months, saved the latest  version  to  disk
and  was  told  that the disk was corrupt, so immediately did the same
thing to his only backup.  When he saw his program  scrolling  up  the
screen again, he wept with relief.

But  I've  never  seen  a  four character extension before.  I've seen
disks with two files with the same name, I've seen  files  with  names
that DOS won't recognise, I've seen ...  well, I've seen it all.

I  packed  my  little black bag (yes, it really is black) with my most
powerful disk repair toolkits, and  went  to  visit  Phil.   Phil,  of
course, was running a LAN.  I'm not going to say which one, because it
doesn't matter - this could have happened to any LAN.  We fired up the
IBM  XT,  logged  on  as  system  supervisor,  went  into the relevant
subdirectory, and did a DIR.  There were four files, of which one  was
called  SHARES.WR1.  "That's it", Phil said.  I tried to TYPE it;  DOS
came back FILE NOT FOUND.  DOS was showing me  the  file's  name,  but
didn't  recognise  the name when I used it.  Funny, I thought.  I used
the most powerful disk repair utility of all to start with - DEBUG.  I
tried  to  load  the file into DEBUG;  DOS said the file didn't exist.
OK, I thought, there's obviously something funny about the directory -
let's  look at that.  I tried to load the directory - DOS wouldn't let
me.  Fair enough, I though, that's as it should  be.   But  I  know  a
trick  or  three;   with DEBUG you can load a numbered sector from the
disk.  With a little snooping around, you can find the root directory,
and from there you can find your way down the tree of sub-directories;
it always works, as DEBUG can always read a sector, no matter how  bad
the  logical  damage  is (physical damage is another thing - there are
some things I refuse to put into a floppy drive).  But it didn't  work
this  time;   DEBUG  refused to read a sector from the disk.  In fact,
DEBUG wouldn't read any sector from the disk.  And if DEBUG can't read
a  sector, you can forget about Norton, Undelete or any of the others.

"Manual", I said, holding out my hand.  Phil got the LAN manual.  Lots
of stuff about how to copy  a  file,  but  nothing  at  a  low  level.
Nothing  about  the device drivers, nothing about the BIOS - just lots
of pretty pictures of boxes, and how to copy a file.  "Right", I said,
"there are two ways to do this, the hard way and the easy way."

"What's  the difference", Phil said.  "The easy way is you get someone
from the people who sold you the LAN, you get them to fetch a full set
of  technical  manuals, and I come back when that's all set up." "That
actually sounds rather difficult - the LAN  man  doesn't  seem  to  be
interested.  He says it's a bug in Symphony.  What's the hard way?"

"No way can it be a bug in  Symphony.   The  hard  way  is  I  reverse
engineer  this  thing.  The reason why it's hard is it takes me a very
long time, and so it costs you a LOT of money.  Get the manuals."

Phil phoned me back a couple of days later.  "The LAN man won't  come,
and  there  are  no  manuals."  "Oh  goodie," I said, "I do like doing
jigsaw puzzles without any picture."

I came round again with my little black  bag.   This  time  I  brought
Turbo  Pascal  and  the  Macro  Assembler  -  I wanted to be ready for
anything.  Phil was waiting for  me,  together  with  the  unfortunate
character  who  was supposed to look after the network.  "Jim wants to
see how you fix it, so that he can do it in future".  I didn't see why
I  should pass on the experience of years quite so easily, but I could
see no way out.  "How do you  know  the  file  has  a  four  character
extension?",  I  asked.   Phil  showed  me.  He fired up Symphony, and
brought up the files menu;  sure enough, there it was  -  SHARES.WR1S.
I  gazed at it in admiration;  it was a bit like a four leaved clover,
only rarer, and not so lucky.  "I've never seen anything like  it",  I
said.

I  wondered  if  I  could  duplicate  the  problem.   I  saved a blank
spreadsheet under the name ABC.DEFG, and it worked.   I  came  out  of
Symphony,  and  did  a  DIR;   it  showed me ABC.DEF.  I tried to TYPE
ABC.DEF, and DOS said file not found.  So I tried TYPE ABC.DEFG  -  it
worked.  "Yahoo", I yahooed - Phil looked at me in surprise.

"This  is  definitely a two-hamburger problem", I said.  I don't think
Phil has read Conan Doyle, because he took me literally, and left  for
the nearest MacDonalds.  But the ruse worked - now only Techie Jim was
watching me.  "I need a printer", I said.  This  seemed  a  reasonable
enough  request,  if  you ignored the fact that the PC had no parallel
port, so Techie Jim went off to fetch  one.   While  he  was  gone,  I
worked  quickly.   To  appreciate what I did, I'll have to give you my
reasoning about the situation;  that'll look like it took a long time,
but actually was very fast.

The  LAN  was  running  its  own  brand of DOS (call it LAN-DOS), so I
assumed that there was some slight bug in it.  Suppose, I reasoned, in
LAN-DOS,  there  is  no  separate filename and extension;  suppose the
whole  thing  is  stored  as  one  word,  including   the   dot,   and
re-interpreted  by LAN-DOS.  Then a filename that was shorter that the
allowed eight characters, could have an extension that was longer than
the  allowed three characters, provided the whole thing, including the
dot, was twelve characters or less.  Suppose some of the DOS functions
can  cope  with  this,  but  others  (perhaps  written  by a different
programmer) choke on it.  Clearly, DIR doesn't like it,  but  the  DOS
write function used by Symphony is happy.

Why  did I make this guess instead of some other idea?  That's hard to
say.  I've written a lot of low-level  stuff,  and  reverse-engineered
and  rewritten various bits of DOS, so I have a feel for how it works.
I also know how people write programs, and  what  the  line  of  least
resistance  is  likely  to  be.   I  suppose I'm saying that I used my
experience.

Anyhow, the next thing was to do something about the file.  While  Jim
Techie  was  off  fetching the printer, I TYPEd it, and redirected the
output to another file - that was the reason  for  my  earlier  Yahoo.
Then  I  rapidly deleted the old file with the four character filename
(DEL didn't work, but I'll let you work out  how  I  did  the  delete,
because  it was certainly obvious to me), and sat back looking pleased
with myself.

At that point Phil arrived with the hamburgers, and Techie Jim arrived
with the printer.  While Jim poked around the back wondering where the
parallel port had gone, Phil and I ate  our  hamburgers.   We  chatted
about  things  of little import, like how come there was a copy of one
of my programs on each of his machines when he  had  only  bought  one
copy,  and  how  much  I  was going to invoice him for a site licence.
Phil's idea was that he should give them all back, but  I  fell  about
laughing  at  that.   As  I munched my way through my second hamburger
(traditional programmer's food) Phil asked me if I thought I could fix
the  problem.  I grinned at him - "Already done it", I said, through a
mouthful of bun.  Phil looked across at Techie Jim, who tried to  look
intelligent.  "How did you do it?", he said.

Now,  any  magician  will  tell you that if you explain how a trick is
done, it spoils the magic.  People always say,  "Oh  yes,  of  course,
that's  easy".   So  we  members  of  the  Inner Circle swear never to
explain how a trick works.  I took off my glasses,  and  frowned,  and
looked  earnest.   "Function  1F hexadecimal of DOS function call soft
interrupt 21 hexadecimal", I  began.  I looked up at Techie Jim  -  it
was  clear  I'd  left him behind already.  "Do you really want to hear
all this?", I said.  "No," said Phil, "I don't suppose I'd  understand
it".   He  didn't  know  that  Techie  Jim  had been away fetching the
printer when I actually did the job, and thought that young Jim  would
be able to repeat the feat.

I  wonder  how  Techie  Jim will explain to Phil about not watching me
closely enough?  It isn't his fault really - even the LAN-man couldn't
work  out  how to fix the file, and once I'd worked out my simple fix,
there was no way I'd let anyone see how it worked - that  would  spoil
the magic.

Phil has his important file back, so he's happy.  Techie Jim now knows
someone he can call in when he has other problems with his network, so
he's  happy.   My reputation as a magician is preserved, so I'm happy.
I think networks are great - they cause more problems than the rest of
computing put together.