Summary: Missing `.' fsck cannot fix.

From: Robert McLay (mclay@wilbur.ae.utexas.edu)
Date: Wed Mar 27 1991 - 10:32:42 CST


I have fixed my problem with the "missing `.' fsck cannot fix". I want
to thank the following people clearing up my confusion.

Ed Arnold
smb@ulysses.att.c
Stephane Tsacas
"Matt Crawford"
William LeFebvre
Harris A. Jaffee
dan@BBN.COM
Mike Raffety
Kevin Sheehan
tim@ben.dciem.dnd
klaus u schallhor
Harris A. Jaffee

To summarize, somehow I no longer had `.' as the first entry in the
directory for the partition. Several people mentioned using od to find
out what is there. Doing od -c /u4 gets

0000000 \0 \0 \0 002 \0 \f \0 001 377 \0 \0 \0 \0 \0 \0 002
0000020 \0 \f \0 002 . . \0 \0 \0 \0 \0 003 \0 024 \0 \n
0000040 l o s t + f o u n d \0 \0 \0 \0 006 \0
0000060 \0 \f \0 003 g n u \0 \0 \0 242 001 001 310 \0 005
0000100 l o c a l \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000120 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0001000

In comparing this to other directories it is clear that the 377 on the first
line should be a `.'

Using od on the raw disk I found out that the location of the inode
for the directory is at 074000:

od -c /dev/rsd2h | less ( and searched for /l o s t/ and
                                  backed up)

0740000 \0 \0 \0 002 \0 \f \0 001 377 \0 \0 \0 \0 \0 \0 002
0740020 \0 \f \0 002 . . \0 \0 \0 \0 \0 003 \0 024 \0 \n
0740040 l o s t + f o u n d \0 \0 \0 \0 006 \0
0740060 \0 \f \0 003 g n u \0 \0 \0 242 001 001 310 \0 005
0740100 l o c a l \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0740120 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

So at location 0740010 (octal) I want to put a `.'

How to fix it?

Well several people mentioned adb. and do something like:

------------------------------------------------------------------------
adb -w - /dev/rsd2h
0o0740010/x
                        (should produce "3c008: ff00".)

0o0740010/w 0x2e00
                        (should produce "3c008: 0xff00 = 0x2e00".)

$q
------------------------------------------------------------------------

Unfortunately, I keep getting "data not found" message from my sun
4/330(OS:4.1). However, when I tried the same on a SS2 (4/75) it
works fine. If anyone knows why please tell me.

A couple people mentions emacs. I don't think emacs will let root
edit the raw disk file. Anyway I couldn't get it to work.

A really cute solution is to use a dd; edit; dd trick as follows:
------------------------------------------------------------------------
        # dd if=/dev/rsd2h of=1sector bs=512 skip=480
        # <edit the file "1sector" with emacs or whatever>
        # dd if=1sector of=/dev/rsd2h bs=512 seek=480
------------------------------------------------------------------------

The solution I used was a C program. Many of you pointed out that I
had 074000 where I should have had 0740000. Here is the C program that
I used. Thanks to all of you.

------------------------------------------------------------------------
#include <stdio.h>
#include <fcntl.h>

main()
{
  int fd;
  int ja;
  int oc;
  unsigned char buf[2048];

  for(ja=0; ja<2048; buf[ja++] = '\0');

  fd = open ("/dev/rsd2h",O_RDWR,0);

  printf("fd : %d\n",fd);

  ja = get(fd,(long) 0740000,&buf[0],2048);

  printf("ja : %d\n",ja);
  
  for(ja = 0; ja < 24; ja++)
    {
      oc = buf[ja];
      printf("%d: %o\n",ja,oc);
    }
  buf[8] = '.';
  ja = put(fd,(long) 0740000,&buf[0],2048);
}
int get(int fd,long pos, unsigned char *buf, int n)
{
  int ls;
  if ((ls=lseek(fd,pos,0)) >= 0)
    {
      printf("ls from lseek %d\n",ls);
      ls = read(fd, buf, n);
      if (ls < 0) perror("read error");
      return ls;
    }
  else
    {
      perror("get error");
      return -1;
    }
}
int put(int fd,long pos, unsigned char *buf, int n)
{
  int ls;
  if ((ls=lseek(fd,pos,0)) >= 0)
    {
      printf("ls from lseek %d\n",ls);
      ls = write(fd, buf, n);
      if (ls < 0) perror("write error");
      return ls;
    }
  else
    {
      perror("get error");
      return -1;
    }
}

  

--

______________________________________________________________________________ Robert McLay | When you have a problem, put NO in front of Manager CFD Lab | it and you have: NO PROBLEM. Dept ASE-EM | University of Texas at Austin | -- Eric Beckman's 2nd Law | mclay@wilbur.ae.utexas.edu |



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:12 CDT