You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: layer.md
+39-1Lines changed: 39 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,46 @@ Where supported, MUST include file attributes for Additions and Modifications in
44
44
* Group Name (`gname`) *secondary to `gid`*
45
45
* Mode (`mode`)
46
46
* Extended Attributes (`xattrs`)
47
-
* Symlink reference (`linkname`)
47
+
* Symlink reference (`linkname` + symbolic link type)
48
+
*[Hardlink](#hardlinks) reference (`linkname`)
48
49
49
50
[Sparse files](https://en.wikipedia.org/wiki/Sparse_file) SHOULD NOT be used because they lack consistent support across tar implementations.
50
51
52
+
#### Hardlinks
53
+
54
+
Hardlinks are a [POSIX concept](http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html) for having one or more directory entries for the same file on the same device.
55
+
Not all filesystems support hardlinks (e.g. [FAT](https://en.wikipedia.org/wiki/File_Allocation_Table)).
56
+
57
+
Hardlinks are possible with all [file types](#file-types) except `directories`.
58
+
Non-directory files are considered "hardlinked" when their link count is greater than 1.
59
+
Hardlinked files are on a same device (i.e. comparing Major:Minor pair) and have the same inode.
60
+
The corresponding files that share the link with the > 1 linkcount may be outside the directory that the changeset is being produced from, in which case the `linkname` is not recorded in the changeset.
61
+
62
+
Hardlinks are stored in a tar archive with type of a `1` char, per the [GNU Basic Tar Format][gnu-tar-standard] and [libarchive tar(5)][libarchive-tar].
63
+
64
+
While approaches to deriving new or changed hardlinks may vary, a possible approach is:
65
+
66
+
```
67
+
SET LinkMap to map[< Major:Minor String >]map[< inode integer >]< path string >
68
+
SET LinkNames to map[< src path string >]< dest path string >
69
+
FOR each path in root path
70
+
IF path type is directory
71
+
CONTINUE
72
+
ENDIF
73
+
SET filestat to stat(path)
74
+
IF filestat num of links == 1
75
+
CONTINUE
76
+
ENDIF
77
+
IF LinkMap[filestat device][filestat inode] is not empty
78
+
SET LinkNames[path] to LinkMap[filestat device][filestat inode]
79
+
ELSE
80
+
SET LinkMap[filestat device][filestat inode] to path
81
+
ENDIF
82
+
END FOR
83
+
```
84
+
85
+
With this approach, the link map and links names of a directory could be compared against that of another directory to derive additions and changes to hardlinks.
86
+
51
87
## Creating
52
88
53
89
### Initial Root Filesystem
@@ -279,4 +315,6 @@ Layers that have these restrictions SHOULD be tagged with an alternative mediaty
279
315
[Descriptors](descriptor.md) referencing these layers MAY include `urls` for downloading these layers.
280
316
It is implementation-defined whether or not implementations upload layers tagged with this media type.
0 commit comments