]> arthur.barton.de Git - netatalk.git/blob - doc/README.ids
Removed mentions of the mtab and hash schemes.
[netatalk.git] / doc / README.ids
1 File and Directory IDs explained.
2
3 What are File and Directory ID's?
4
5 On a mac the file system stores all files and directory information on each 
6 volume in a big file called the catalogue file.  Inside the catalogue, all 
7 files and directories are accessed using a key, central to which is a number, 
8 called the ID.  In the case of a file its a file ID (FID) or for a directory, 
9 a directory ID (DID).
10
11 How many IDs can there be?
12
13 The ID in a catalogue key is stored using 4 bytes, which means it can only 
14 be between 0 and 4,294,967,295 (FF FF FF FF in hex).  However the first 16 
15 IDs are reserved so you don't have quite that many.  Each ID is unique for 
16 ever, on any given volume.  Once all 4 billion have been used, you cannot 
17 create new files, so will need to reformat the volume to continue using it.
18
19 Why are IDs so important?
20
21 Most system calls relating to files inside a mac (either vi a network or a 
22 hard disk) can refer to files or directories by ID.  This makes the ID a 
23 powerful piece of information.  
24
25 So whats the problem?
26
27 The problem lies in file servers that don't use IDs.  The protocol used by
28 macs to share files over a network is called the Apple Filing Protocol (AFP)
29 and it requires the use of IDs.  So if you want to support AFP fully, any
30 AFP server, must adopt its own system for storing and maintaining a link
31 between each file or directory and its respective ID.  This is most critical
32 when acessing directories.  
33
34 So why does this matter on a non mac server like netatalk?
35
36 The three big stumbling blocks that crop up with AFP servers that don't 
37 fully support IDs are 1) aliases, 2) the trash can and 3) linked documents.
38
39 Alias problems.
40
41 An alias on a mac is quite special.  Rather than just storing the path to 
42 the original file (like a unix symlink), it stores the ID to that file and 
43 a special identifier for the volume (and the server it's on).  Ideally this 
44 is great.  If the file moves or is renamed, the alias still works.  However 
45 if either the file (or directory) ID changes, or the volume identifier 
46 (or server identifer), then the alias will break.  The file it claims to 
47 point to will claim to have been removed.  
48
49 Trash can (accidentally deleted file) problems.
50
51 The trash can has similar problems.  Files that have been moved to the trash
52 are represented by their ID.  When you empty the trash all ID's listed are 
53 deleted.  However if the ID of a file that was in the trash, is reallocated
54 to an ordinary file, then when the trash is emptied that file will be deleted.
55
56 Linked document problems.
57
58 Finally linked documents: Linked documents are documents that contain hidden
59 links to other documents.  Print setting and layout application (such as 
60 Quark) use this technique.  Sometimes these documents contain IDs linking to
61 their embeded documents.  These can break in the same way as aliases.  
62
63 So how does netatalk approach the problem?
64
65 Netatalk has two different methods of allocating IDs: last and cnid.
66
67 DID = last.
68
69 This uses a running number to allocate IDs.  When an ID is allocated the 
70 server remembers this by adding it to a table.  If an ID is referenced, then
71 the server looks up on the table.  When the server is restarted, the table is
72 lost.  This is the most simple method, but it is unreliable.  If you stick to
73 the mac features which don't rely heavily on IDs it works fine.  If you try
74 to use IDs much, things break.  
75
76 DID = cnid. 
77
78 This uses a Berkeley 3 database to store and maintain a directory of IDs
79 similar to that of a catalogue file on a mac.  Consequently it is the most
80 reliable method.  Unfortunately there seem to be heavy multi user problems 
81 that lead to database corruption.  These are being worked on, but cnid remains
82 the safest and most reliable DID scheme.  See README.cnid for more details.
83
84