vfs: names up to 255 bytes and paths up to 4096, like Linux
Every path component was copied into a DIRSIZ buffer and every path into a MAXPATH one, so names were cut at 29 bytes and paths at 127 without an error. Two names sharing their first 29 bytes opened the same file, on SchFS and FAT alike, though both hold 255. VFS_NAME_MAX (255) and VFS_PATH_MAX (4096) are the limits now, and anything longer is ENAMETOOLONG. namex_from() takes its path buffers from kalloc(), a page each, rather than putting two of them on an 8 KB kernel stack. The v1 format still stores DIRSIZ bytes, and refuses a longer name instead of matching on its first 30. Checked: 255-byte names on SchFS and FAT (fsck.fat clean, and the FAT name answers to its uppercase form), 256 refused, a 200-byte path and a link to it, and no pages lost over 700 lookups through links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
parent
b213ab5778
commit
67db42b460
7 changed files with 121 additions and 38 deletions
|
|
@ -171,6 +171,16 @@ struct inode {
|
|||
|
||||
// Mounted FAT volumes, FAT_DEV onward. See include/fat.h.
|
||||
|
||||
// Linux's limits, for every filesystem behind the VFS. A path component can be
|
||||
// NAME_MAX bytes and a whole path PATH_MAX including its NUL. Each filesystem
|
||||
// may refuse less: SchFS and FAT take 255, the v1 format DIRSIZ.
|
||||
//
|
||||
// The VFS used to copy every component into a DIRSIZ buffer and every path
|
||||
// into a MAXPATH one, which cut names at 29 bytes and paths at 127 without a
|
||||
// word -- so a longer name opened whichever file shared its first 29 bytes.
|
||||
#define VFS_NAME_MAX 255
|
||||
#define VFS_PATH_MAX 4096 // one page: namex_from() kalloc()s it
|
||||
|
||||
// 1 if some inode on dev with this number is referenced. In fs.c.
|
||||
int iheld(uint dev, uint64 inum);
|
||||
// 1 if any inode on dev but `except` is referenced (0: no exception). In fs.c.
|
||||
|
|
|
|||
Loading…
Reference in a new issue