From owner-freebsd-hackers Tue Jun 13 7:20:20 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.ptd.net (mail1.ha-net.ptd.net [207.44.96.65]) by hub.freebsd.org (Postfix) with SMTP id 7854B37BDE4 for ; Tue, 13 Jun 2000 07:20:17 -0700 (PDT) (envelope-from tms2@mail.ptd.net) Received: (qmail 15872 invoked from network); 13 Jun 2000 14:20:17 -0000 Received: from du72.cli.ptd.net (HELO mail.ptd.net) (204.186.33.72) by mail.ptd.net with SMTP; 13 Jun 2000 14:20:17 -0000 Message-ID: <39464301.4CDA218E@mail.ptd.net> Date: Tue, 13 Jun 2000 10:19:45 -0400 From: "Thomas M. Sommers" Organization: None X-Mailer: Mozilla 4.72 [en] (X11; I; FreeBSD 4.0-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Sergey Babkin Cc: "Gary T. Corcoran" , "Jordan K. Hubbard" , hackers@FreeBSD.ORG Subject: Re: Way off-topic, but anybody know how to resurrect files from FAT-12? References: <200006121452.HAA74024@zippy.cdrom.com> <39453A78.565BDECC@lucent.com> <39456F52.BC507026@bellatlantic.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Sergey Babkin wrote: > > "Gary T. Corcoran" wrote: > > > > "Jordan K. Hubbard" wrote: > > > > > > I'm sitting here in Seoul, Korea (which is very nice, by the way) and > > > I've just managed to delete all 82 images of Kyoto off the FAT-12 format > > > Smartcard they were on. Waaaah! > > > > > > > Way back in the Dark Ages I used to hack on FAT-12 code... > > Going *way* back in the archives - (had to find a 5-1/4 inch floppy > > drive!) it looks as if there are directory entry attributes at the byte > > at dirptr+11, and the lower bits (ANDed with 0x1C) should be 0. Otherwise, > > if I recall (don't have reference books here), there is a bit saying > > the file is deleted (other bits say subdirectory, system file, etc.) > > So you may just have to change that one byte (per file) to recover them > > (in addition to changing the first byte of the file name which you > > already did). > > The clusters in the FAT have to be re-connected. The number of the > first cluster is still stored in the directory entry, as well as > directory file size. Then hoping that the files were written sequentially > you start from that cluster and link together as many free clusters going > sequentially after it to cover this file size. FAT-12 is an array of > 12-bit entries, each corresponding to a cluster. An entry contains the > number of the next cluster in file. The last cluster in a file has some > special value in its FAT entry, something like 0xFFF or 0xFFE, can't The last cluster is indicated by any value from 0xff8 to 0xfff. 0xff7 indicates a bad cluster. 0xff0 - 0xff6 mark reserved clusters. > remember exactly. The unallocated clusters have value like 000 in their > entries. The cluster size for FAT-12 will probably be equal to one > sector, that is 512 bytes. At least that's true for diskettes but may be > different for the Smartcard. The cluster size is at offset 0xd in the boot sector. Also, there are usually 2 copies of the FAT, both of which should be fixed. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message