Re: Multiple files with same filename on FAT




The holy grail, though, is a way to get the files out without writing
anything to the disk, to be sure it's still recognized by the PVR as
if it never was extracted. But I could well undo the editing before
returning the drive to the PVR...

Now to automate this, all I need is sample C code to read/write raw
sectors on a hard disk (bypassing the filesystem). Anybody has some
pointer ?


I would try the following:

1) Create a raw dump of your whole disk in a file; you can use DD on linux, or WinHex (need registration) or similar utilities; you could also try rawcopy.zip from http://www.ltr-data.se/opencode.html#ImDisk, which is free. I didn't try that.

2) From the link above, use ImDisk to mount your image file as a a virtual drive. I used the control panel, but you can do by command line also.

3) You can access the virtual drive using low level functions (sector by serctor) from WinXP using CreateFileA(), ReadFile and WriteFile().

Have a look to: http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5765/

the code is similar to:

// drive: 0=A
char unitName[] = "A:";
char _devicename[] = "\\\\.\\A:";
assert('A' <= DRIVE_LETTER && DRIVE_LETTER <= 'Z');
unitName[0] = toupper(DRIVE_LETTER);
// Creating a handle to disk drive using CreateFile () function ..
_devicename[4] = toupper(DRIVE_LETTER);
hDevice = CreateFileA((LPCSTR ) _devicename, FILE_ACCESS,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

[....]

to read a sector: ReadFile(hDevice, buf, 512, &bytesRead, NULL)

to write a sector: WriteFile(hDevice, buf, 512, &bytesWritten, NULL) )


You can also find a lot of FAT code on the net... I would try EFSL library; you could hack that to follow your "double name" FAT arrangement.

Using the above snippets, I was able to test my FAT code very very easily under XP with VisualC++ Express without messing up my drives. It was very handy to have different image files for the different "corner" cases to test.







.



Relevant Pages

  • Re: XP Pro Recovery Errors
    ... it turns out that the boot sector, sector 0, of my HDD failed to "read, write, or remove write-protection." ... Hard drives, when they have a problem with a sector, mark it as "pending". ... So if you do something to write to the disk, and write sector zero, ...
    (microsoft.public.windowsxp.general)
  • Re: Bad Clusters
    ... >drives I use for backup. ... head positioning wobble that reduces accuracy of pickup, ... Why would a previously good HD develop a bad sector? ... i.e. where the head touches the disk and thus damages it. ...
    (microsoft.public.windowsxp.general)
  • ATA Defect management
    ... > data to a reallocated sector. ... actually make backups and want to restore them on to the disk without ... > identical to the conditions for reallocate on read. ... NO. Fix the drives. ...
    (Linux-Kernel)
  • Re: raid 1 - automatic repair possible?
    ... Having looked at a lot of disks, I think that it is definitely worth ... With large drives, you ... clean the questionable sector and leave you with a perfectly fine disk. ...
    (Linux-Kernel)
  • Re: Advise on data recovery from failed drive
    ... I have an ancient program that I once wrote to make copies of disk drives ... It will retry a single sector read several times before ... FreeBSD 4.8-RELEASE dd command and discovered a new option that avoids ...
    (freebsd-questions)