-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: remove "file name too long" limitation (ref)
* limit mountpath length * refactor * part six, prev. commit: 4d75c7d Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
7fe1d0b
commit 455bb66
Showing
5 changed files
with
62 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package fs | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/NVIDIA/aistore/cmn/cos" | ||
) | ||
|
||
// file name too long (0x24) | ||
const ( | ||
prefixFntl = ".x" | ||
|
||
// a typical local FS limitation | ||
maxLenBasename = 255 | ||
|
||
// a.k.a. maximum FQN length before we decide to shorten it | ||
// given that Linux PATH_MAX = 4096 (see /usr/include/limits.h) | ||
// this number also takes into account: | ||
// - maxLenMountpath = 255 (see cmn/config) | ||
// - max bucket name = 64 (see cos.CheckAlphaPlus) | ||
maxLenPath = 3072 | ||
) | ||
|
||
func HasPrefixFntl(s string) bool { | ||
return strings.HasPrefix(s, prefixFntl) | ||
} | ||
|
||
func ShortenFntl(s string) string { | ||
return prefixFntl + cos.ChecksumB2S(cos.UnsafeB(s), cos.ChecksumSHA256) | ||
} | ||
|
||
func IsFntl(objName string) bool { | ||
if l := len(objName); l > maxLenBasename { | ||
if l > maxLenPath || len(filepath.Base(objName)) > maxLenBasename { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters