30

I know FAT32, as well as FAT16/12 neither support symbolic links nor hard-links. However I came up with this idea:

The FAT specification describes that every file is associated with a directory-entry. In my understanding, one could say that a file-entry in a directory somehow or other points to the file's content.

So, how can I define two directory-entries which point to the same file-content? Or, what could prevent me from doing so?

Use case: I have a USB mass storage device for my car radio, and I want to use directories as playlists since the radio software doesn't support playlists. So it isn't important to me how Windows behaves when doing this.

palswim
  • 11,856
  • 6
  • 53
  • 77
fishbone
  • 3,140
  • 2
  • 37
  • 50
  • What's the use case? Why are you stuck using a FAT32 file system? What system will only support FAT32, but understands symbolic links? – Cody Gray - on strike Dec 28 '10 at 11:20
  • I'm explaining this in my comment on answer 1 – fishbone Dec 28 '10 at 12:27
  • 4
    Did you make any more progress on your testing? I'm trying to do the exact same thing for my car's USB interface, only I want to write a simple GUI to do the work rather than using a hex editor. Shoot me an email if you are still interested in this project (remove all underscores): crush_meguy at yah_oo dot com. – Doug Hill Mar 09 '11 at 05:17
  • @DougHill: Oh well. It looks some people around had _exactly_ the same idea as me! – alecov Aug 20 '14 at 17:02
  • I have lots of clean working and unit tested C++-code, but unfortunately no time to continue the project. The challenge is to provide a UI with good usability... – fishbone Aug 21 '14 at 10:49
  • 3
    @fishbone I would love to see your code for this. Any chance you might put it on github or email it to me? I have the same problem with the radio in my car. – shwoseph Jan 17 '15 at 07:25
  • I had exactly the same idea for my car, too. Googling it brought me here. @DougHill did you get anywhere with your GUI? – daiscog Jan 11 '18 at 18:19
  • [The difference between symbolic links and hard links](https://serverfault.com/q/10543/50236); this question refers to hard links. – palswim Feb 23 '18 at 04:31

3 Answers3

7

This should work for simple issues. I.e. it works as a hack / workaround and I don't know what happens if you rename / move / remove files. So, you should not do this on your main hdd.

I edited the directory-entries manually using a hex editor. I modified clusters as well as file-sizes and successfully faked hardlinks. My car-radio and even Windows (7, 64Bit) have no problems with playing back the original and "hard-linked" mp3-Files I used.

When I'm opening the device again in the hex-editor none of my modifications are changed back (See chkdsk issue in answer #1 - but as far as I know chkdsk has to be started manually, anyways.

fishbone
  • 3,140
  • 2
  • 37
  • 50
6

What you are talking about ("two directory-entries which are pointing to the same file-content") are hard links. chkdsk will report them as cross-links and break them, "repairing" the files (in fact making the copies).

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • 1
    I actually want to do this on a usb-device for usage with my car radio. My idea is to fake playlists since they aren't supported by the device. I could imagine that vendors are using provided drivers - do you think that those drivers implement behavior similar to chkdsk? Do you know how linux is handling this? Do you know a good tool for playing around with this idea? At the moment I'm using a hex editor. – fishbone Dec 28 '10 at 12:15
  • @fishbone One can only guess, how the specific driver will behave on specific device. Some drivers might have chkdsk built-in but I doubt that they will include "fix" functionality there. However, they can refuse to play the "corrupted" media. Note, that to in order to clarify questions it's better to edit the original question rather than add comments -- this adds readability to the question and immediately attracts attention of those, who read the questions. – Eugene Mayevski 'Callback Dec 28 '10 at 12:34
  • 1
    The reason why I don't like editing questions is that correct answers will become wrong. I wrote the comment, since i thought chkdsk is a windows-only program, but I never said that I'm going to use windows. – fishbone Dec 28 '10 at 12:47
  • 2
    If only @fishbone could construct some sort of symbolic link between their comment and their edit to the original question. – Ben J Apr 16 '17 at 08:29
4

MichaelPh posted instructions on SuperUser:

https://superuser.com/a/486829/51237

It's possible to use Disk Probe (on XP only, I've yet to get it to write the changes on Win7) to modify the cluster a FAT Directory references. This method can be used to redirect the DCIM folder (or a subfolder) to point to the folder used by a different scan device.

Whether this is a good idea or not is a different matter and you use this at your own risk.

  1. Insert the Eye-Fi card either in it's USB Card Reader or directly into an SSD slot and note the drive letter it's installed as (assumed to be F:\ for simplicity)
  2. Ensure all Windows Explorer windows for the card and sub-directories are closed.
  3. Run Disk Probe
  4. Select Drives->Logical Volume
  5. In the Open Logical Volume dialog double-click F:\ in the Logical Volumes list
  6. Click the Set Active button for the Handle F: has been selected as. You can leave the handle as read-only for now.
  7. Select Tools->Search Sectors...
  8. Check Exhaustive Search, enter DCIM in Enter characters to search for and Search
  9. You should find a match (mine is at 8192). Select No on the "Found match..." dialog to cancel the rest of the search.
  10. Select Sectors->Read and increase Number of Sectors to at least two so that the whole directory table is included.
  11. Find DCIM in the ASCII on the right of the Disk Probe screen, this is the start of the FAT entry for the directory. Make a note of the hex value of the 27th byte of the record (each entry is 32bytes), this is the directory cluster reference. This value is require to revert the DCIM directory back to normal use if required.
  12. Find the entry for the directory you want to redirect DCIM to and again make a note of the 27th byte in the record.
  13. Go back to the 27th byte of the DCIM record and change it to the value noted in step 11.
  14. Select Sectors->Write and then click Write it on the Write Sector dialog. A warning will come up if you opened the sectors as read-only. Yes to overwrite if you're happy to make the change.

Opening the DCIM directory in Windows Explorer will now show the contents of the target directory.

Community
  • 1
  • 1
AlcubierreDrive
  • 3,654
  • 2
  • 29
  • 45