Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

add a hard link marker to 16byte + maker, for future extensions

Chris Lu474e2b6ac389
diff --git a/weed/filesys/dir_link.go b/weed/filesys/dir_link.go
index 368ded442c..f6bc41b56d 100644
--- a/weed/filesys/dir_link.go
+++ b/weed/filesys/dir_link.go
@@ -18,6 +18,10 @@ var _ = fs.NodeLinker(&Dir{})
var _ = fs.NodeSymlinker(&Dir{})
var _ = fs.NodeReadlinker(&File{})
+const (
+ HARD_LINK_MARKER = '\x01'
+)
+
func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (fs.Node, error) {
oldFile, ok := old.(*File)
@@ -33,7 +37,7 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f
// update old file to hardlink mode
if len(oldFile.entry.HardLinkId) == 0 {
- oldFile.entry.HardLinkId = util.RandomBytes(16)
+ oldFile.entry.HardLinkId = append(util.RandomBytes(16), HARD_LINK_MARKER)
oldFile.entry.HardLinkCounter = 1
}
oldFile.entry.HardLinkCounter++