compiler/stage2_l0/src/compiler_filesystem.l0
Module compiler_filesystem
Overview Symbols grouped by source file: compiler/stage2_l0/src/compiler_filesystem.l0
Module: compiler_filesystem
Source: compiler/stage2_l0/src/compiler_filesystem.l0 Language: Dea/L0
Imports / Includes
util.diagstd.timestd.vectorstd.textstd.systemstd.stringstd.arraysys.rt
Symbols
- CFS_PATH_ABSENT
- CFS_PATH_REGULAR
- CFS_PATH_DIRECTORY
- CFS_PATH_OTHER
- l0c_fs_mkdir
- l0c_fs_join_child
- l0c_fs_path_kind_nofollow
- l0c_fs_path_kind_follow
- l0c_fs_remove_regular_file
- l0c_fs_remove_empty_dir
- l0c_fs_resolve_trusted_temp_parent
- cfs_error
- cfs_path_kind
- cfs_path_kind_follow
- cfs_join_child
- cfs_mkdir
- cfs_remove_regular_file
- cfs_remove_empty_dir
- cfs_resolve_trusted_temp_parent
- cfs_select_temp_parent_from_values
- cfs_select_temp_parent
- cfs_workspace_free
- cfs_workspace_child
- cfs_workspace_create_for_identity
- cfs_workspace_create
- cfs_workspace_cleanup
- cfs_apply_cleanup_status
- CompilerWorkspace
Variable CFS_PATH_ABSENT
let CFS_PATH_ABSENT: int = 0
No filesystem object exists at the path.
Variable CFS_PATH_REGULAR
let CFS_PATH_REGULAR: int = 1
A regular file exists at the path.
Variable CFS_PATH_DIRECTORY
let CFS_PATH_DIRECTORY: int = 2
A directory exists at the path.
Variable CFS_PATH_OTHER
let CFS_PATH_OTHER: int = 3
A symlink, reparse point, or other unsupported object exists at the path.
Function l0c_fs_mkdir
extern func l0c_fs_mkdir(path: byte*, path_len: int, mode: int) -> int
Create one directory from a native path byte span.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.mode: POSIX permission and special bits through07777; validated but otherwise ignored on Windows.
Returns: 1 after creation, 0 when an object already exists at the path, or -1 on invalid input or an operating-system error.
Function l0c_fs_join_child
extern func l0c_fs_join_child(parent: byte*, parent_len: int, child: byte*, child_len: int, output: byte*?, output_capacity: int) -> int
Join a trusted parent path and one internal child name.
A query with a null output and zero capacity returns the required byte length. A sufficiently large output span receives the path without a trailing NUL.
Parameters:
parent: Non-empty native parent path bytes without an embedded NUL.parent_len: Number of bytes inparent.child: Non-empty native child-name bytes without an embedded NUL.child_len: Number of bytes inchild.output: Optional destination for the joined path bytes.output_capacity: Available bytes inoutput, or zero for a query.
Returns: Required byte length, or -1 on invalid input or overflow.
Function l0c_fs_path_kind_nofollow
extern func l0c_fs_path_kind_nofollow(path: byte*, path_len: int) -> int
Classify one native path without following a final symlink or reparse point.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.
Returns: A CFS_PATH_* kind, or -1 on invalid input or an operating-system error.
Function l0c_fs_path_kind_follow
extern func l0c_fs_path_kind_follow(path: byte*, path_len: int) -> int
Classify one native path after following symlinks or reparse points.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.
Returns: A CFS_PATH_* kind, with dangling links reported as absent, or -1 on invalid input or an operating-system error.
Function l0c_fs_remove_regular_file
extern func l0c_fs_remove_regular_file(path: byte*, path_len: int) -> int
Remove one regular file without following a substituted path object.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.
Returns: 1 after removal, 0 when absent, or -1 for invalid input, an unsupported object kind, or an operating-system error.
Function l0c_fs_remove_empty_dir
extern func l0c_fs_remove_empty_dir(path: byte*, path_len: int) -> int
Remove one empty real directory without accepting a symlink or reparse point.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.
Returns: 1 after removal, 0 when absent, or -1 on invalid input, a non-directory object, a non-empty directory, or an operating-system error.
Function l0c_fs_resolve_trusted_temp_parent
extern func l0c_fs_resolve_trusted_temp_parent(path: byte*, path_len: int, output: byte*?, output_capacity: int) -> int
Resolve and validate one selected compiler temporary parent.
A query with a null output and zero capacity returns the canonical byte length. A sufficiently large output span receives the canonical path without a trailing NUL. POSIX validates the complete resolved directory trust chain; Windows relies on the documented trusted-parent ACL assumption.
Parameters:
path: Non-empty native path bytes without an embedded NUL.path_len: Number of bytes inpath.output: Optional destination for the canonical path bytes.output_capacity: Available bytes inoutput, or zero for a query.
Returns: Canonical byte length, or -1 on invalid input, trust failure, or an operating-system error.
Function cfs_error
func cfs_error(diags: DiagCollector*, code: string, message: string, path: string)
Emit one compiler-filesystem diagnostic without source coordinates.
Function cfs_path_kind
func cfs_path_kind(path: string) -> int
Call the compiler-internal no-follow path classifier.
Function cfs_path_kind_follow
func cfs_path_kind_follow(path: string) -> int
Call the compiler-internal follow path classifier.
Function cfs_join_child
func cfs_join_child(parent: string, child: string) -> string
Join a trusted parent and internal child using actual-host separators.
Function cfs_mkdir
func cfs_mkdir(path: string, mode: int) -> int
Create one directory using the compiler-internal raw-byte ABI.
Function cfs_remove_regular_file
func cfs_remove_regular_file(path: string) -> int
Remove one regular file without following a substituted path.
Function cfs_remove_empty_dir
func cfs_remove_empty_dir(path: string) -> int
Remove one empty real directory through the compiler-internal ABI.
Function cfs_resolve_trusted_temp_parent
func cfs_resolve_trusted_temp_parent(path: string) -> string?
Resolve and validate one selected temporary parent.
The support ABI determines the actual host. POSIX validates the complete resolved owner/sticky-bit chain; Windows retains the trusted-parent ACL assumption. Platform-alias environment variables are deliberately ignored.
Parameters:
path: Selected existing directory.
Returns: Canonical trusted path, or null on failure.
Function cfs_select_temp_parent_from_values
func cfs_select_temp_parent_from_values(tmpdir: string?, temp: string?, tmp: string?, system_tmp: string, fallback: string, diags: DiagCollector*) -> string?
Select a temporary parent from explicit candidate values.
Empty values, absent paths, and non-directories fall through. Inspection errors are fatal; once a directory is selected, canonical resolution and trust validation are also authoritative.
The explicit system_tmp and fallback parameters are an internal test seam. Production supplies /tmp and . respectively.
Function cfs_select_temp_parent
func cfs_select_temp_parent(diags: DiagCollector*) -> string?
Return the first existing temporary-parent directory by stable precedence.
Function cfs_workspace_free
func cfs_workspace_free(self: CompilerWorkspace*)
Release a workspace path bundle after explicit cleanup.
Function cfs_workspace_child
func cfs_workspace_child(workspace: CompilerWorkspace*, leaf: string) -> string
Register and return one fixed driver-selected workspace child.
Parameters:
workspace: Workspace that owns the child.leaf: Fixed child filename.
Returns: Joined child path.
Function cfs_workspace_create_for_identity
func cfs_workspace_create_for_identity(parent_path: string, tag: string, pid: int, sec: int, nsec: int, diags: DiagCollector*) -> CompilerWorkspace*?
Exclusively reserve one workspace from a deterministic identity tuple.
Pre-existing candidates are skipped and no unchecked fallback is returned.
Function cfs_workspace_create
func cfs_workspace_create(tag: string, diags: DiagCollector*) -> CompilerWorkspace*?
Select, resolve, validate, and exclusively reserve one compiler workspace.
Function cfs_workspace_cleanup
func cfs_workspace_cleanup(workspace: CompilerWorkspace*, diags: DiagCollector*) -> bool
Remove only known regular children, then the empty owned directory.
Cleanup first verifies the workspace root without following aliases. An unexpected child or substituted path retains the workspace for inspection.
Function cfs_apply_cleanup_status
func cfs_apply_cleanup_status(primary_status: int, cleanup_ok: bool) -> int
Apply cleanup failure to a command's already-determined status.
Cleanup turns success into status 1, while an existing failure or program status remains authoritative.
Struct CompilerWorkspace
Invocation-owned native build/run workspace.
CompilerWorkspace Field root
root: string
CompilerWorkspace Field children
children: StringVector*