Unfixable UFS2 corruption

Eugene Grosbein egrosbein at rdtc.ru
Wed Aug 31 14:57:02 UTC 2011


Hi!

Please CC: me as I'm not in the list.

Long story short: my /usr/local UFS2 filesystem somehow got corrupted
and "fsck -y" in single user mode does not fix it.

Explanation:

# ls -al /usr/local/obj/usr/local/src/secure/lib/libssh
ls: : No such file or directory
total 8
drwxr-xr-x  2 root  wheel  4608 Aug 30 01:28 .
drwxr-xr-x  3 root  wheel   512 Aug 30 01:28 ..

# rm -rf /usr/local/obj/usr/local/src/secure/lib/libssh
rm: /usr/local/obj/usr/local/src/secure/lib/libssh: Directory not empty

As I've said, I cold booted this FreeBSD 8.2-STABLE system to single user mode
where all file systems are not mounted (except root) and ran fsck -y /usr/local
It found no errors and said it is CLEAN. The problem still persists.

I've written small program and it said me this directory contains third file
(besides <.> and <..> entries) having zero file length.

I got contents of the directory to plain file with
"cat /usr/local/obj/usr/local/src/secure/lib/libssh > /tmp/libssh" and put it online:
http://www.grosbein.net/crash/corruption/libssh

Please help. The program and its output follow:

#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <stdio.h>

int main(int argc, char* argv[])
{

  DIR		*dirp;
  struct dirent *dp;
  unsigned	i;

  if (argc<2)
	return 1;

  if ( (dirp = opendir(argv[1])) == NULL )
	err (1, "opendir");

  i = 0;
  while ((dp = readdir(dirp)) != NULL) {
    i++;
    printf("Entry %u:\n"
	   "d_fileno=%u\n"
           "d_reclen=%u\n"
	   "d_type=%u\n"
	   "d_namlen=%u\n"
	   "d_name=<%s>\n\n",
	   i, (unsigned) dp->d_fileno, (unsigned) dp->d_reclen,
	   (unsigned) dp->d_type, (unsigned) dp->d_namlen,
	   (char *) dp->d_name);
  }
  return closedir(dirp);
}

# # ./readdir /usr/local/obj/usr/local/src/secure/lib/libssh
Entry 1:
d_fileno=1531227
d_reclen=12
d_type=4
d_namlen=1
d_name=<.>

Entry 2:
d_fileno=1389650
d_reclen=500
d_type=4
d_namlen=2
d_name=<..>

Entry 3:
d_fileno=24
d_reclen=512
d_type=8
d_namlen=0
d_name=<>


More information about the freebsd-fs mailing list