team-ljyzipelo

공개

리눅스 단일 파일 게시 후보를 추가합니다

작성자
시로사키 하나
작성 시각
커밋
10dc446c90d3527437298cff270b26d2e196a748
부모
23b8d1c
이 시점의 파일 보기

변경된 파일 10개

+1,145-0
추가experiments/rust-file-publication/Cargo.lock+16-0
@@ -0,0 +1,16 @@
1추가: # This file is automatically @generated by Cargo.
2추가: # It is not intended for manual editing.
3추가: version = 4
4추가:
5추가: [[package]]
6추가: name = "libc"
7추가: version = "0.2.191"
8추가: source = "registry+https://github.com/rust-lang/crates.io-index"
9추가: checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
10추가:
11추가: [[package]]
12추가: name = "zipelo-file-publication"
13추가: version = "0.1.0"
14추가: dependencies = [
15추가: "libc",
16추가: ]
추가experiments/rust-file-publication/Cargo.toml+18-0
@@ -0,0 +1,18 @@
1추가: [package]
2추가: name = "zipelo-file-publication"
3추가: version = "0.1.0"
4추가: edition = "2024"
5추가: rust-version = "1.99"
6추가: license = "MIT"
7추가: publish = false
8추가: autotests = false
9추가: autoexamples = false
10추가: autobenches = false
11추가:
12추가: [lib]
13추가: doctest = false
14추가:
15추가: [target.'cfg(target_os = "linux")'.dependencies]
16추가: libc = { version = "=0.2.191", default-features = false, features = ["std"] }
17추가:
18추가: [workspace]
추가experiments/rust-file-publication/LICENSE+21-0
@@ -0,0 +1,21 @@
1추가: MIT License
2추가:
3추가: Copyright (c) 2026 Team-LJY contributors
4추가:
5추가: Permission is hereby granted, free of charge, to any person obtaining a copy
6추가: of this software and associated documentation files (the "Software"), to deal
7추가: in the Software without restriction, including without limitation the rights
8추가: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9추가: copies of the Software, and to permit persons to whom the Software is
10추가: furnished to do so, subject to the following conditions:
11추가:
12추가: The above copyright notice and this permission notice shall be included in all
13추가: copies or substantial portions of the Software.
14추가:
15추가: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16추가: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17추가: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18추가: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19추가: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20추가: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21추가: SOFTWARE.
추가experiments/rust-file-publication/SHA256SUMS+9-0
@@ -0,0 +1,9 @@
1추가: b38bcde0e0c7286f53254ecbc357a55a0b18e803fd7294dec1025fcb34eb6092 Cargo.lock
2추가: e6d911fb2c215dcab367116b0eac2544a3e37abe0d69ba6f0323c0d0308b329d Cargo.toml
3추가: 0714945e52a4d5b560c02c9a18478519f8c4e2572cbf87bd6d52adcfb2b63c62 LICENSE
4추가: 83bd16a9177040f87f726c5ff9c0e14e7e3fc0096c743abe0d7b1b97ab1fc425 THIRD-PARTY-NOTICES.txt
5추가: fc091b378311e5a5898f770b4a91317ada5d2daebbb3cfb795e1026736334161 contract.json
6추가: 75757b6b770ea09d7b345ca3beaf3d75fdbbe7c792d00d3aec7465b9968ce4f5 dependencies.json
7추가: 8304a9c37e8d0a2e21f6657483c58d28c23ba4a4c2ed9ae7e43d389d0f3c2bc3 src/lib.rs
8추가: 75225159189cb2418b24c5e35c4db804dfe2f0171bf957f59578ae284f046d0c src/linux.rs
9추가: 75ed00e7059990abe5c3ba7bc0aae87801e3ffa915824c900d09ed31a61f8159 static-validation.json
추가experiments/rust-file-publication/THIRD-PARTY-NOTICES.txt+208-0
@@ -0,0 +1,208 @@
1추가: libc 0.2.191 - MIT OR Apache-2.0
2추가:
3추가: LICENSE-APACHE
4추가: Apache License
5추가: Version 2.0, January 2004
6추가: http://www.apache.org/licenses/
7추가:
8추가: TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
9추가:
10추가: 1. Definitions.
11추가:
12추가: "License" shall mean the terms and conditions for use, reproduction,
13추가: and distribution as defined by Sections 1 through 9 of this document.
14추가:
15추가: "Licensor" shall mean the copyright owner or entity authorized by
16추가: the copyright owner that is granting the License.
17추가:
18추가: "Legal Entity" shall mean the union of the acting entity and all
19추가: other entities that control, are controlled by, or are under common
20추가: control with that entity. For the purposes of this definition,
21추가: "control" means (i) the power, direct or indirect, to cause the
22추가: direction or management of such entity, whether by contract or
23추가: otherwise, or (ii) ownership of fifty percent (50%) or more of the
24추가: outstanding shares, or (iii) beneficial ownership of such entity.
25추가:
26추가: "You" (or "Your") shall mean an individual or Legal Entity
27추가: exercising permissions granted by this License.
28추가:
29추가: "Source" form shall mean the preferred form for making modifications,
30추가: including but not limited to software source code, documentation
31추가: source, and configuration files.
32추가:
33추가: "Object" form shall mean any form resulting from mechanical
34추가: transformation or translation of a Source form, including but
35추가: not limited to compiled object code, generated documentation,
36추가: and conversions to other media types.
37추가:
38추가: "Work" shall mean the work of authorship, whether in Source or
39추가: Object form, made available under the License, as indicated by a
40추가: copyright notice that is included in or attached to the work
41추가: (an example is provided in the Appendix below).
42추가:
43추가: "Derivative Works" shall mean any work, whether in Source or Object
44추가: form, that is based on (or derived from) the Work and for which the
45추가: editorial revisions, annotations, elaborations, or other modifications
46추가: represent, as a whole, an original work of authorship. For the purposes
47추가: of this License, Derivative Works shall not include works that remain
48추가: separable from, or merely link (or bind by name) to the interfaces of,
49추가: the Work and Derivative Works thereof.
50추가:
51추가: "Contribution" shall mean any work of authorship, including
52추가: the original version of the Work and any modifications or additions
53추가: to that Work or Derivative Works thereof, that is intentionally
54추가: submitted to Licensor for inclusion in the Work by the copyright owner
55추가: or by an individual or Legal Entity authorized to submit on behalf of
56추가: the copyright owner. For the purposes of this definition, "submitted"
57추가: means any form of electronic, verbal, or written communication sent
58추가: to the Licensor or its representatives, including but not limited to
59추가: communication on electronic mailing lists, source code control systems,
60추가: and issue tracking systems that are managed by, or on behalf of, the
61추가: Licensor for the purpose of discussing and improving the Work, but
62추가: excluding communication that is conspicuously marked or otherwise
63추가: designated in writing by the copyright owner as "Not a Contribution."
64추가:
65추가: "Contributor" shall mean Licensor and any individual or Legal Entity
66추가: on behalf of whom a Contribution has been received by Licensor and
67추가: subsequently incorporated within the Work.
68추가:
69추가: 2. Grant of Copyright License. Subject to the terms and conditions of
70추가: this License, each Contributor hereby grants to You a perpetual,
71추가: worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72추가: copyright license to reproduce, prepare Derivative Works of,
73추가: publicly display, publicly perform, sublicense, and distribute the
74추가: Work and such Derivative Works in Source or Object form.
75추가:
76추가: 3. Grant of Patent License. Subject to the terms and conditions of
77추가: this License, each Contributor hereby grants to You a perpetual,
78추가: worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79추가: (except as stated in this section) patent license to make, have made,
80추가: use, offer to sell, sell, import, and otherwise transfer the Work,
81추가: where such license applies only to those patent claims licensable
82추가: by such Contributor that are necessarily infringed by their
83추가: Contribution(s) alone or by combination of their Contribution(s)
84추가: with the Work to which such Contribution(s) was submitted. If You
85추가: institute patent litigation against any entity (including a
86추가: cross-claim or counterclaim in a lawsuit) alleging that the Work
87추가: or a Contribution incorporated within the Work constitutes direct
88추가: or contributory patent infringement, then any patent licenses
89추가: granted to You under this License for that Work shall terminate
90추가: as of the date such litigation is filed.
91추가:
92추가: 4. Redistribution. You may reproduce and distribute copies of the
93추가: Work or Derivative Works thereof in any medium, with or without
94추가: modifications, and in Source or Object form, provided that You
95추가: meet the following conditions:
96추가:
97추가: (a) You must give any other recipients of the Work or
98추가: Derivative Works a copy of this License; and
99추가:
100추가: (b) You must cause any modified files to carry prominent notices
101추가: stating that You changed the files; and
102추가:
103추가: (c) You must retain, in the Source form of any Derivative Works
104추가: that You distribute, all copyright, patent, trademark, and
105추가: attribution notices from the Source form of the Work,
106추가: excluding those notices that do not pertain to any part of
107추가: the Derivative Works; and
108추가:
109추가: (d) If the Work includes a "NOTICE" text file as part of its
110추가: distribution, then any Derivative Works that You distribute must
111추가: include a readable copy of the attribution notices contained
112추가: within such NOTICE file, excluding those notices that do not
113추가: pertain to any part of the Derivative Works, in at least one
114추가: of the following places: within a NOTICE text file distributed
115추가: as part of the Derivative Works; within the Source form or
116추가: documentation, if provided along with the Derivative Works; or,
117추가: within a display generated by the Derivative Works, if and
118추가: wherever such third-party notices normally appear. The contents
119추가: of the NOTICE file are for informational purposes only and
120추가: do not modify the License. You may add Your own attribution
121추가: notices within Derivative Works that You distribute, alongside
122추가: or as an addendum to the NOTICE text from the Work, provided
123추가: that such additional attribution notices cannot be construed
124추가: as modifying the License.
125추가:
126추가: You may add Your own copyright statement to Your modifications and
127추가: may provide additional or different license terms and conditions
128추가: for use, reproduction, or distribution of Your modifications, or
129추가: for any such Derivative Works as a whole, provided Your use,
130추가: reproduction, and distribution of the Work otherwise complies with
131추가: the conditions stated in this License.
132추가:
133추가: 5. Submission of Contributions. Unless You explicitly state otherwise,
134추가: any Contribution intentionally submitted for inclusion in the Work
135추가: by You to the Licensor shall be under the terms and conditions of
136추가: this License, without any additional terms or conditions.
137추가: Notwithstanding the above, nothing herein shall supersede or modify
138추가: the terms of any separate license agreement you may have executed
139추가: with Licensor regarding such Contributions.
140추가:
141추가: 6. Trademarks. This License does not grant permission to use the trade
142추가: names, trademarks, service marks, or product names of the Licensor,
143추가: except as required for reasonable and customary use in describing the
144추가: origin of the Work and reproducing the content of the NOTICE file.
145추가:
146추가: 7. Disclaimer of Warranty. Unless required by applicable law or
147추가: agreed to in writing, Licensor provides the Work (and each
148추가: Contributor provides its Contributions) on an "AS IS" BASIS,
149추가: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150추가: implied, including, without limitation, any warranties or conditions
151추가: of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152추가: PARTICULAR PURPOSE. You are solely responsible for determining the
153추가: appropriateness of using or redistributing the Work and assume any
154추가: risks associated with Your exercise of permissions under this License.
155추가:
156추가: 8. Limitation of Liability. In no event and under no legal theory,
157추가: whether in tort (including negligence), contract, or otherwise,
158추가: unless required by applicable law (such as deliberate and grossly
159추가: negligent acts) or agreed to in writing, shall any Contributor be
160추가: liable to You for damages, including any direct, indirect, special,
161추가: incidental, or consequential damages of any character arising as a
162추가: result of this License or out of the use or inability to use the
163추가: Work (including but not limited to damages for loss of goodwill,
164추가: work stoppage, computer failure or malfunction, or any and all
165추가: other commercial damages or losses), even if such Contributor
166추가: has been advised of the possibility of such damages.
167추가:
168추가: 9. Accepting Warranty or Additional Liability. While redistributing
169추가: the Work or Derivative Works thereof, You may choose to offer,
170추가: and charge a fee for, acceptance of support, warranty, indemnity,
171추가: or other liability obligations and/or rights consistent with this
172추가: License. However, in accepting such obligations, You may act only
173추가: on Your own behalf and on Your sole responsibility, not on behalf
174추가: of any other Contributor, and only if You agree to indemnify,
175추가: defend, and hold each Contributor harmless for any liability
176추가: incurred by, or claims asserted against, such Contributor by reason
177추가: of your accepting any such warranty or additional liability.
178추가:
179추가: END OF TERMS AND CONDITIONS
180추가:
181추가:
182추가: LICENSE-MIT
183추가: Copyright (c) The Rust Project Developers
184추가:
185추가: Permission is hereby granted, free of charge, to any
186추가: person obtaining a copy of this software and associated
187추가: documentation files (the "Software"), to deal in the
188추가: Software without restriction, including without
189추가: limitation the rights to use, copy, modify, merge,
190추가: publish, distribute, sublicense, and/or sell copies of
191추가: the Software, and to permit persons to whom the Software
192추가: is furnished to do so, subject to the following
193추가: conditions:
194추가:
195추가: The above copyright notice and this permission notice
196추가: shall be included in all copies or substantial portions
197추가: of the Software.
198추가:
199추가: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
200추가: ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
201추가: TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
202추가: PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
203추가: SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
204추가: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
205추가: OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
206추가: IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
207추가: DEALINGS IN THE SOFTWARE.
208추가:
추가experiments/rust-file-publication/contract.json+90-0
@@ -0,0 +1,90 @@
1추가: {
2추가: "schema": 1,
3추가: "package": "zipelo-file-publication",
4추가: "status": "source-static-only",
5추가: "base_head": "23b8d1c615f24f42469138fcc63e7fce7cda4f24",
6추가: "scope": [
7추가: "experiments/rust-file-publication/"
8추가: ],
9추가: "tests_owner": "bugfix role; separate root tests path after API review",
10추가: "api": {
11추가: "entry": "Publication::new() -> (Publication, Cancellation); Publication::publish(self, Request, checkpoint) -> Report<E>",
12추가: "input": "Immutable borrowed byte slice, absolute parent Path, single OsStr leaf, bounded Limits. No source-file access and no input validation/worker evidence.",
13추가: "callbacks": [
14추가: "Opening (twice)",
15추가: "Writing before each write",
16추가: "Verifying before sync and every read, including EOF probe",
17추가: "BeforeCommit after byte/metadata checks and procfs setup"
18추가: ],
19추가: "output": "Report { outcome, usage, cleanup }. Outcome::Committed requires private FileCommitReceipt obtained only after linkat returns zero. No caller bool, public receipt constructor, Default, or Deserialize.",
20추가: "receipt": "Parent and file device/inode plus length. Caller retains requested leaf separately. Identities are observations, not permanent identities after inode reuse. No bytes/hash or archive validity claim."
21추가: },
22추가: "limits": {
23추가: "payload_bytes": 16777216,
24추가: "scratch_bytes": 65536,
25추가: "default_duration_seconds": 30,
26추가: "max_duration_seconds": 300,
27추가: "max_reserved_read_write_bytes": 134217728,
28추가: "max_read_write_calls": 131072,
29추가: "memory": "Borrow input without copying; fixed 64KiB scratch, bounded path allocations (parent<=4095 bytes, leaf<=255), at most 4 File handles. Does not bound caller's existing allocations, callbacks, allocator internals or filesystem/kernel memory.",
30추가: "accounting": "Reserve full requested read/write length and one attempt before each syscall; never refund on short/zero/error/EOF. Actual transferred bytes separately counted. EOF probe reserves 1 byte. open/metadata/sync/link counters are adapter attempts; metadata is std File::metadata. lseek and close excluded from IO byte/call budgets; close attempts/failures in Cleanup.",
31추가: "termination": "Cooperative elapsed-time check at checkpoints before commit. No hard deadline for callback, blocking syscall, sync or close. Postcommit sync/close are not interrupted by cancellation or elapsed limit. Per invocation usage; upper job layer must aggregate retries."
32추가: },
33추가: "linux": {
34추가: "parent": "Reject nonabsolute, empty/repeated/trailing components, dot/dotdot, NUL, oversized paths. Root '/' is lexical-valid but must pass owner/mode and filesystem checks. openat2 O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY and RESOLVE_NO_SYMLINKS; no fallback.",
35추가: "trust": "fstat directory, effective UID owner, no group/other write bits. Only an exclusively managed destination directory with trusted same-UID actors is in scope. This is not an ACL, LSM, namespace, root or same-user adversary sandbox. No permission/security setting changes. Ancestors may move; no persistent pathname guarantee.",
36추가: "filesystem": "fstatfs magic 0xef53 (ext family, not proof specifically ext4) or 0x58465342 (XFS) only. Unknown/network/overlay/tmpfs rejected before temp creation. Actual O_TMPFILE support still required. Source-only: no mounted filesystem support verified.",
37추가: "temporary": "openat(held_parent, '.', O_TMPFILE|O_RDWR|O_CLOEXEC, 0600), without O_EXCL. fstat regular, nlink=0, euid owner, same st_dev. No named staging file.",
38추가: "verification": "Bounded raw write with positive short-write accumulation; zero write is WriteZero. fsync_file before lseek and exact chunk readback/EOF check. Native errors including EINTR preserved without raw IO retries. Final fstat checks same identity, regular type, nlink=0 and length. Readback is not archive validation, security isolation or protection from privileged/same-UID fd manipulation.",
39추가: "procfs": "openat2('/proc', O_PATH|O_DIRECTORY|O_CLOEXEC, RESOLVE_NO_SYMLINKS); fstatfs PROC_SUPER_MAGIC. Open numeric getpid()/fd relative to held proc root using BENEATH|NO_SYMLINKS|NO_XDEV. Keep all fds owned. Actual link source is numeric temp fd relative to proc fd directory with AT_SYMLINK_FOLLOW. Require trusted procfs for this PID namespace. No alternate /proc mount or launcher.",
40추가: "commit": "linkat(held_proc_fd_directory, numeric_temp_fd, held_parent, leaf, AT_SYMLINK_FOLLOW) exactly once after CAS. Existing leaf of any kind, including symlink/directory, is EEXIST; never truncate, overwrite, merge, rename or delete. No fallback on EXDEV, ENOSYS, unsupported FS/procfs or other error.",
41추가: "namespace": "Success belongs to held parent object and leaf at link return, not to the original parent pathname. Parent rename/replacement may cause commit into moved original directory; unlinked parent may fail. No postcheck can prove the original pathname persists; no later namespace stability claim."
42추가: },
43추가: "cancellation": {
44추가: "state": "Per-publication private Arc<AtomicU8>: Pending -> Cancelled by request CAS, or Pending -> Committing by commit CAS, then Finished at Publication drop. SeqCst defines a total decision order.",
45추가: "before": "A cancellation CAS winning before begin_commit prevents linkat. Stop::Cancelled also stops before link. Callback(E) is returned unchanged, including when callback also requests cancellation. Native IO failures are returned before a later checkpoint and are not overwritten by cancellation.",
46추가: "after": "Committing wins: requests return TooLate until publication drops; link syscall result preserved, no callbacks after CAS. Success cannot become cancelled and no unlink rollback exists. A late request after returned report is Finished.",
47추가: "abandon": "Dropping unused Publication marks Finished without completion proof. Panic before commit unwinds RAII but returns no report; panic/abort and forced process death are not verified cleanup. Callback is trusted application code and may block or panic."
48추가: },
49추가: "outcomes": {
50추가: "NotCommitted": "All pre-link failures, including unsupported platform/filesystem, cancellation, original callback or IO error, and linkat EEXIST. Preserves errno without flattening to archive failure. This is an operation observation, not assertion that no other actor changed destination.",
51추가: "CommitUncertain": "Any non-EEXIST linkat error is conservatively uncertain, including EXDEV/EINTR/ENOENT. Original io::Error retained, no receipt minted, no automatic retry/unlink. This deliberately overclassifies some definite failures pending later syscall-specific review.",
52추가: "Committed": "linkat returned zero. Private file-layer receipt exists even if parent fsync or close fails. Not OS worker, archive validation or product Published success.",
53추가: "durability": "File fsync failure is precommit failure. After link success, parent fsync success is FileAndParentSynced, otherwise ParentSyncFailed(original error). Two successful fsync returns are reported, not a guarantee against faulty storage or arbitrary crash recovery.",
54추가: "cleanup": "All acquired fds are explicitly close'd once on every normal return. Order temporary, proc fd directory, proc root, parent. Fixed four-slot failures retain resource and original errno separately. Never retry close (including EINTR), never unlink any name. Unlinked O_TMPFILE normally ceases to exist after last reference, but successful close is not physical deletion proof; close failure is not reported as confirmed cleanup. Panic path uses File RAII with unobserved close errors."
55추가: },
56추가: "diagnostics": "No stored full path, file content or raw byte Debug on Request/receipt/Report. Callback E and io::Error may carry caller-controlled data; consumers must redact rather than log raw Debug. No external transmission.",
57추가: "validation": {
58추가: "completed": [
59추가: "rustfmt syntax/format only",
60추가: "locked/offline metadata and offline lock generation",
61추가: "inline structural/static assertions and manifest hashes",
62추가: "cached libc archive checksum, cached regular file equality and license texts"
63추가: ],
64추가: "not_performed": [
65추가: "Rust compile or typecheck",
66추가: "tests/discovery",
67추가: "publication/filesystem syscalls from candidate",
68추가: "worker execution",
69추가: "Windows",
70추가: "GUI",
71추가: "CVE/advisory audit"
72추가: ],
73추가: "future": "Synthetic files only in fresh task-owned directory on supported filesystem. Regression owner uses root tests/. Distinguish injected errors from real syscalls, parent replacement from persistence, EEXIST preservation, short/zero writes, verification mismatch, sync errors, cancellation/commit CAS order, late cancellation and close failures. Missing supported filesystem is unsupported, not authorization to mount/install/change environment."
74추가: },
75추가: "references": [
76추가: "https://man7.org/linux/man-pages/man2/openat2.2.html",
77추가: "https://man7.org/linux/man-pages/man2/open.2.html",
78추가: "https://man7.org/linux/man-pages/man2/linkat.2.html",
79추가: "https://man7.org/linux/man-pages/man2/fsync.2.html",
80추가: "https://man7.org/linux/man-pages/man2/close.2.html"
81추가: ],
82추가: "preservation": [
83추가: "PR42/43/44/46 frozen",
84추가: "C# unchanged",
85추가: "No worker/execveat EACCES retry or bypass",
86추가: "No folder publication or product UI",
87추가: "No main merge",
88추가: "No old evidence rewritten"
89추가: ]
90추가: }
추가experiments/rust-file-publication/dependencies.json+25-0
@@ -0,0 +1,25 @@
1추가: {
2추가: "direct": [
3추가: {
4추가: "name": "libc",
5추가: "version": "0.2.191",
6추가: "license": "MIT OR Apache-2.0",
7추가: "target": "cfg(target_os = linux)",
8추가: "features": [
9추가: "std"
10추가: ],
11추가: "default_features": false,
12추가: "checksum": "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a",
13추가: "cached_regular_files_verified": 452,
14추가: "license_files": [
15추가: "LICENSE-APACHE",
16추가: "LICENSE-MIT"
17추가: ]
18추가: }
19추가: ],
20추가: "transitive": [],
21추가: "new_external_crate_versions": false,
22추가: "reuse": "Existing rust-file-snapshot and rust-live-supervisor libc version; no snapshot dependency",
23추가: "network_restore": false,
24추가: "advisory_audit": "not performed; no vulnerability-free claim"
25추가: }
추가experiments/rust-file-publication/src/lib.rs+361-0
@@ -0,0 +1,361 @@
1추가: #![deny(unsafe_op_in_unsafe_fn)]
2추가:
3추가: //! 파일 계층의 단일 이름 게시만 담당함.
4추가: //! 원래 경로 유지, 압축 검증, OS worker 실행과 원자적 입력 snapshot을 증명하지 않음.
5추가:
6추가: use std::{
7추가: ffi::OsStr,
8추가: io,
9추가: path::Path,
10추가: sync::{
11추가: Arc,
12추가: atomic::{AtomicU8, Ordering},
13추가: },
14추가: time::{Duration, Instant},
15추가: };
16추가:
17추가: #[cfg(target_os = "linux")]
18추가: mod linux;
19추가:
20추가: pub const MAX_BYTES: u64 = 16 * 1024 * 1024;
21추가: pub const MAX_IO_BYTES: u64 = 128 * 1024 * 1024;
22추가: pub const MAX_IO_CALLS: u64 = 131_072;
23추가: pub const CHUNK_BYTES: usize = 65_536;
24추가: const PENDING: u8 = 0;
25추가: const CANCELLED: u8 = 1;
26추가: const COMMITTING: u8 = 2;
27추가: const FINISHED: u8 = 3;
28추가:
29추가: #[derive(Clone, Copy, Debug)]
30추가: pub struct Limits {
31추가: pub max_bytes: u64,
32추가: pub max_io_bytes: u64,
33추가: pub max_io_calls: u64,
34추가: pub max_duration: Duration,
35추가: }
36추가:
37추가: impl Default for Limits {
38추가: fn default() -> Self {
39추가: Self {
40추가: max_bytes: MAX_BYTES,
41추가: max_io_bytes: MAX_IO_BYTES,
42추가: max_io_calls: MAX_IO_CALLS,
43추가: max_duration: Duration::from_secs(30),
44추가: }
45추가: }
46추가: }
47추가:
48추가: pub struct Request<'a> {
49추가: pub parent: &'a Path,
50추가: pub leaf: &'a OsStr,
51추가: pub bytes: &'a [u8],
52추가: pub limits: Limits,
53추가: }
54추가:
55추가: #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
56추가: pub struct Usage {
57추가: pub open_calls: u64,
58추가: pub metadata_calls: u64,
59추가: pub sync_calls: u64,
60추가: pub link_calls: u64,
61추가: pub read_calls: u64,
62추가: pub write_calls: u64,
63추가: pub reserved_io_bytes: u64,
64추가: pub actual_read_bytes: u64,
65추가: pub actual_written_bytes: u64,
66추가: }
67추가:
68추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
69추가: pub enum Stage {
70추가: Opening,
71추가: Writing,
72추가: Verifying,
73추가: BeforeCommit,
74추가: }
75추가:
76추가: #[derive(Clone, Copy, Debug)]
77추가: pub struct Checkpoint {
78추가: pub stage: Stage,
79추가: pub offset: u64,
80추가: pub length: u64,
81추가: pub usage: Usage,
82추가: }
83추가:
84추가: #[derive(Debug)]
85추가: pub enum Stop<E> {
86추가: Cancelled,
87추가: Callback(E),
88추가: }
89추가:
90추가: #[derive(Debug)]
91추가: pub enum Error<E> {
92추가: InvalidLimits,
93추가: InvalidPath,
94추가: LimitExceeded,
95추가: DeadlineExceeded,
96추가: Cancelled,
97추가: Callback(E),
98추가: UnsupportedPlatform,
99추가: UnsupportedFilesystem,
100추가: UntrustedParent,
101추가: InvalidTemporaryFile,
102추가: VerificationMismatch,
103추가: Io {
104추가: operation: &'static str,
105추가: source: io::Error,
106추가: },
107추가: }
108추가:
109추가: // 재사용이나 초기화 API를 제공하지 않는 작업별 취소 핸들임.
110추가: #[derive(Clone)]
111추가: pub struct Cancellation {
112추가: state: Arc<AtomicU8>,
113추가: }
114추가:
115추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
116추가: pub enum CancelDecision {
117추가: Requested,
118추가: AlreadyRequested,
119추가: TooLate,
120추가: Finished,
121추가: }
122추가:
123추가: impl Cancellation {
124추가: pub fn request(&self) -> CancelDecision {
125추가: match self
126추가: .state
127추가: .compare_exchange(PENDING, CANCELLED, Ordering::SeqCst, Ordering::SeqCst)
128추가: {
129추가: Ok(_) => CancelDecision::Requested,
130추가: Err(CANCELLED) => CancelDecision::AlreadyRequested,
131추가: Err(COMMITTING) => CancelDecision::TooLate,
132추가: Err(_) => CancelDecision::Finished,
133추가: }
134추가: }
135추가: }
136추가:
137추가: pub struct Publication {
138추가: state: Arc<AtomicU8>,
139추가: }
140추가:
141추가: impl Publication {
142추가: pub fn new() -> (Self, Cancellation) {
143추가: let state = Arc::new(AtomicU8::new(PENDING));
144추가: (
145추가: Self {
146추가: state: state.clone(),
147추가: },
148추가: Cancellation { state },
149추가: )
150추가: }
151추가:
152추가: // 반환 receipt는 파일 이름 생성만 증명하며 내용의 업무상 유효성을 증명하지 않음.
153추가: pub fn publish<E>(
154추가: self,
155추가: request: Request<'_>,
156추가: mut checkpoint: impl FnMut(Checkpoint) -> Result<(), Stop<E>>,
157추가: ) -> Report<E> {
158추가: let mut run = Run {
159추가: limits: request.limits,
160추가: usage: Usage::default(),
161추가: started: Instant::now(),
162추가: state: &self.state,
163추가: length: request.bytes.len() as u64,
164추가: };
165추가: if let Err(error) = run.validate() {
166추가: return Report {
167추가: outcome: Outcome::NotCommitted(error),
168추가: usage: run.usage,
169추가: cleanup: Cleanup::empty(),
170추가: };
171추가: }
172추가: #[cfg(target_os = "linux")]
173추가: {
174추가: linux::publish(request, &mut run, &mut checkpoint)
175추가: }
176추가: #[cfg(not(target_os = "linux"))]
177추가: {
178추가: let _ = &mut checkpoint;
179추가: Report {
180추가: outcome: Outcome::NotCommitted(Error::UnsupportedPlatform),
181추가: usage: run.usage,
182추가: cleanup: Cleanup::empty(),
183추가: }
184추가: }
185추가: }
186추가: }
187추가:
188추가: impl Drop for Publication {
189추가: fn drop(&mut self) {
190추가: self.state.store(FINISHED, Ordering::SeqCst);
191추가: }
192추가: }
193추가:
194추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
195추가: pub struct Identity {
196추가: device: u64,
197추가: inode: u64,
198추가: }
199추가:
200추가: impl Identity {
201추가: pub fn device(&self) -> u64 {
202추가: self.device
203추가: }
204추가: pub fn inode(&self) -> u64 {
205추가: self.inode
206추가: }
207추가: }
208추가:
209추가: // 외부 생성자와 역직렬화를 제공하지 않음.
210추가: pub struct FileCommitReceipt {
211추가: parent: Identity,
212추가: file: Identity,
213추가: length: u64,
214추가: }
215추가:
216추가: impl FileCommitReceipt {
217추가: pub fn parent_identity(&self) -> Identity {
218추가: self.parent
219추가: }
220추가: pub fn file_identity(&self) -> Identity {
221추가: self.file
222추가: }
223추가: pub fn length(&self) -> u64 {
224추가: self.length
225추가: }
226추가: }
227추가:
228추가: #[derive(Debug)]
229추가: pub enum Durability {
230추가: FileAndParentSynced,
231추가: ParentSyncFailed(io::Error),
232추가: }
233추가:
234추가: pub enum Outcome<E> {
235추가: NotCommitted(Error<E>),
236추가: // 링크 호출 실패의 원격 또는 파일시스템 부작용을 추측하지 않음.
237추가: CommitUncertain {
238추가: source: io::Error,
239추가: },
240추가: Committed {
241추가: receipt: FileCommitReceipt,
242추가: durability: Durability,
243추가: },
244추가: }
245추가:
246추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)]
247추가: pub enum Resource {
248추가: TemporaryFile,
249추가: ProcFdDirectory,
250추가: ProcRoot,
251추가: ParentDirectory,
252추가: }
253추가:
254추가: #[derive(Debug)]
255추가: pub struct CloseFailure {
256추가: pub resource: Resource,
257추가: pub source: io::Error,
258추가: }
259추가:
260추가: #[derive(Debug)]
261추가: pub struct Cleanup {
262추가: pub attempted: u8,
263추가: pub failures: [Option<CloseFailure>; 4],
264추가: }
265추가:
266추가: impl Cleanup {
267추가: fn empty() -> Self {
268추가: Self {
269추가: attempted: 0,
270추가: failures: [None, None, None, None],
271추가: }
272추가: }
273추가:
274추가: // 성공한 close 호출만 뜻하며 물리 삭제나 저장 내구성 증거가 아님.
275추가: pub fn all_close_calls_succeeded(&self) -> bool {
276추가: self.failures.iter().all(Option::is_none)
277추가: }
278추가: }
279추가:
280추가: pub struct Report<E> {
281추가: pub outcome: Outcome<E>,
282추가: pub usage: Usage,
283추가: pub cleanup: Cleanup,
284추가: }
285추가:
286추가: struct Run<'a> {
287추가: limits: Limits,
288추가: usage: Usage,
289추가: started: Instant,
290추가: state: &'a AtomicU8,
291추가: length: u64,
292추가: }
293추가:
294추가: impl Run<'_> {
295추가: fn validate<E>(&self) -> Result<(), Error<E>> {
296추가: if self.limits.max_bytes > MAX_BYTES
297추가: || self.limits.max_io_bytes > MAX_IO_BYTES
298추가: || self.limits.max_io_calls > MAX_IO_CALLS
299추가: || self.limits.max_duration.is_zero()
300추가: || self.limits.max_duration > Duration::from_secs(300)
301추가: {
302추가: return Err(Error::InvalidLimits);
303추가: }
304추가: if self.length > self.limits.max_bytes {
305추가: return Err(Error::LimitExceeded);
306추가: }
307추가: Ok(())
308추가: }
309추가:
310추가: fn check<E>(
311추가: &self,
312추가: stage: Stage,
313추가: offset: usize,
314추가: callback: &mut impl FnMut(Checkpoint) -> Result<(), Stop<E>>,
315추가: ) -> Result<(), Error<E>> {
316추가: match callback(Checkpoint {
317추가: stage,
318추가: offset: offset as u64,
319추가: length: self.length,
320추가: usage: self.usage,
321추가: }) {
322추가: Err(Stop::Callback(error)) => return Err(Error::Callback(error)),
323추가: Err(Stop::Cancelled) => return Err(Error::Cancelled),
324추가: Ok(()) => {}
325추가: }
326추가: if self.state.load(Ordering::SeqCst) == CANCELLED {
327추가: return Err(Error::Cancelled);
328추가: }
329추가: if self.started.elapsed() >= self.limits.max_duration {
330추가: return Err(Error::DeadlineExceeded);
331추가: }
332추가: Ok(())
333추가: }
334추가:
335추가: fn reserve<E>(&mut self, count: usize, write: bool) -> Result<(), Error<E>> {
336추가: let total = self
337추가: .usage
338추가: .reserved_io_bytes
339추가: .checked_add(count as u64)
340추가: .ok_or(Error::LimitExceeded)?;
341추가: if total > self.limits.max_io_bytes
342추가: || self.usage.read_calls + self.usage.write_calls >= self.limits.max_io_calls
343추가: {
344추가: return Err(Error::LimitExceeded);
345추가: }
346추가: self.usage.reserved_io_bytes = total;
347추가: if write {
348추가: self.usage.write_calls += 1;
349추가: } else {
350추가: self.usage.read_calls += 1;
351추가: }
352추가: Ok(())
353추가: }
354추가:
355추가: fn begin_commit<E>(&self) -> Result<(), Error<E>> {
356추가: self.state
357추가: .compare_exchange(PENDING, COMMITTING, Ordering::SeqCst, Ordering::SeqCst)
358추가: .map(|_| ())
359추가: .map_err(|_| Error::Cancelled)
360추가: }
361추가: }
추가experiments/rust-file-publication/src/linux.rs+343-0
@@ -0,0 +1,343 @@
1추가: use super::*;
2추가: use std::{
3추가: ffi::{CStr, CString},
4추가: fs::{File, Metadata},
5추가: mem::MaybeUninit,
6추가: os::{
7추가: fd::{AsRawFd, FromRawFd, IntoRawFd, RawFd},
8추가: unix::{ffi::OsStrExt, fs::MetadataExt},
9추가: },
10추가: };
11추가:
12추가: const NO_SYMLINKS: u64 = 0x04;
13추가: const BENEATH: u64 = 0x08;
14추가: const NO_XDEV: u64 = 0x01;
15추가:
16추가: #[repr(C)]
17추가: struct OpenHow {
18추가: flags: u64,
19추가: mode: u64,
20추가: resolve: u64,
21추가: }
22추가:
23추가: #[derive(Default)]
24추가: struct Handles {
25추가: parent: Option<File>,
26추가: temp: Option<File>,
27추가: proc_root: Option<File>,
28추가: proc_fds: Option<File>,
29추가: }
30추가:
31추가: impl Handles {
32추가: fn close_all(&mut self) -> Cleanup {
33추가: let mut cleanup = Cleanup::empty();
34추가: for (resource, file) in [
35추가: (Resource::TemporaryFile, self.temp.take()),
36추가: (Resource::ProcFdDirectory, self.proc_fds.take()),
37추가: (Resource::ProcRoot, self.proc_root.take()),
38추가: (Resource::ParentDirectory, self.parent.take()),
39추가: ] {
40추가: if let Some(file) = file {
41추가: let fd = file.into_raw_fd();
42추가: let index = cleanup.attempted as usize;
43추가: cleanup.attempted += 1;
44추가: // 소유 fd를 한 번만 닫으며 Linux close 오류를 재시도하지 않음.
45추가: if unsafe { libc::close(fd) } != 0 {
46추가: cleanup.failures[index] = Some(CloseFailure {
47추가: resource,
48추가: source: io::Error::last_os_error(),
49추가: });
50추가: }
51추가: }
52추가: }
53추가: cleanup
54추가: }
55추가: }
56추가:
57추가: pub(super) fn publish<E>(
58추가: request: Request<'_>,
59추가: run: &mut Run<'_>,
60추가: callback: &mut impl FnMut(Checkpoint) -> Result<(), Stop<E>>,
61추가: ) -> Report<E> {
62추가: let mut handles = Handles::default();
63추가: let outcome = match perform(request, run, callback, &mut handles) {
64추가: Ok(outcome) => outcome,
65추가: Err(error) => Outcome::NotCommitted(error),
66추가: };
67추가: let cleanup = handles.close_all();
68추가: Report {
69추가: outcome,
70추가: usage: run.usage,
71추가: cleanup,
72추가: }
73추가: }
74추가:
75추가: fn io_error<E>(operation: &'static str, source: io::Error) -> Error<E> {
76추가: Error::Io { operation, source }
77추가: }
78추가:
79추가: fn opened<E>(fd: libc::c_long, operation: &'static str) -> Result<File, Error<E>> {
80추가: if fd < 0 {
81추가: return Err(io_error(operation, io::Error::last_os_error()));
82추가: }
83추가: // 성공한 open 계열 호출의 새 fd 소유권을 정확히 한 번 인수함.
84추가: Ok(unsafe { File::from_raw_fd(fd as RawFd) })
85추가: }
86추가:
87추가: fn open2<E>(
88추가: dir: RawFd,
89추가: path: &CStr,
90추가: flags: i32,
91추가: resolve: u64,
92추가: run: &mut Run<'_>,
93추가: ) -> Result<File, Error<E>> {
94추가: let how = OpenHow {
95추가: flags: flags as u64,
96추가: mode: 0,
97추가: resolve,
98추가: };
99추가: run.usage.open_calls += 1;
100추가: // NUL 종료 경로와 초기화한 구조체를 호출 동안 유지함.
101추가: let fd = unsafe {
102추가: libc::syscall(
103추가: libc::SYS_openat2,
104추가: dir,
105추가: path.as_ptr(),
106추가: &how as *const OpenHow,
107추가: std::mem::size_of::<OpenHow>(),
108추가: )
109추가: };
110추가: opened(fd, "openat2")
111추가: }
112추가:
113추가: fn metadata<E>(file: &File, run: &mut Run<'_>) -> Result<Metadata, Error<E>> {
114추가: run.usage.metadata_calls += 1;
115추가: file.metadata().map_err(|error| io_error("fstat", error))
116추가: }
117추가:
118추가: fn filesystem<E>(file: &File, run: &mut Run<'_>) -> Result<u64, Error<E>> {
119추가: let mut value = MaybeUninit::<libc::statfs>::uninit();
120추가: run.usage.metadata_calls += 1;
121추가: // 성공한 fstatfs만 초기화된 구조체로 읽음.
122추가: if unsafe { libc::fstatfs(file.as_raw_fd(), value.as_mut_ptr()) } != 0 {
123추가: return Err(io_error("fstatfs", io::Error::last_os_error()));
124추가: }
125추가: Ok(unsafe { value.assume_init() }.f_type as u64)
126추가: }
127추가:
128추가: fn identity(value: &Metadata) -> Identity {
129추가: Identity {
130추가: device: value.dev(),
131추가: inode: value.ino(),
132추가: }
133추가: }
134추가:
135추가: fn paths<E>(request: &Request<'_>) -> Result<(CString, CString), Error<E>> {
136추가: let parent = request.parent.as_os_str().as_bytes();
137추가: let leaf = request.leaf.as_bytes();
138추가: if parent.first() != Some(&b'/')
139추가: || parent.len() > 4095
140추가: || (parent != b"/"
141추가: && parent[1..]
142추가: .split(|v| *v == b'/')
143추가: .any(|v| v.is_empty() || v == b"." || v == b".."))
144추가: || leaf.is_empty()
145추가: || leaf.len() > 255
146추가: || leaf == b"."
147추가: || leaf == b".."
148추가: || leaf.contains(&b'/')
149추가: {
150추가: return Err(Error::InvalidPath);
151추가: }
152추가: Ok((
153추가: CString::new(parent).map_err(|_| Error::InvalidPath)?,
154추가: CString::new(leaf).map_err(|_| Error::InvalidPath)?,
155추가: ))
156추가: }
157추가:
158추가: fn perform<E>(
159추가: request: Request<'_>,
160추가: run: &mut Run<'_>,
161추가: callback: &mut impl FnMut(Checkpoint) -> Result<(), Stop<E>>,
162추가: handles: &mut Handles,
163추가: ) -> Result<Outcome<E>, Error<E>> {
164추가: let (parent_path, leaf) = paths(&request)?;
165추가: run.check(Stage::Opening, 0, callback)?;
166추가: handles.parent = Some(open2(
167추가: libc::AT_FDCWD,
168추가: &parent_path,
169추가: libc::O_RDONLY | libc::O_DIRECTORY | libc::O_CLOEXEC | libc::O_NONBLOCK | libc::O_NOCTTY,
170추가: NO_SYMLINKS,
171추가: run,
172추가: )?);
173추가: let parent = handles.parent.as_ref().expect("owned parent");
174추가: let parent_meta = metadata(parent, run)?;
175추가: // 유효 UID를 읽을 뿐 권한이나 신원을 변경하지 않음.
176추가: let uid = unsafe { libc::geteuid() };
177추가: if !parent_meta.is_dir() || parent_meta.uid() != uid || parent_meta.mode() & 0o022 != 0 {
178추가: return Err(Error::UntrustedParent);
179추가: }
180추가: match filesystem(parent, run)? {
181추가: 0xef53 | 0x58465342 => {}
182추가: _ => return Err(Error::UnsupportedFilesystem),
183추가: }
184추가: run.check(Stage::Opening, 0, callback)?;
185추가: run.usage.open_calls += 1;
186추가: // 고정 부모 아래 이름 없는 파일을 만들며 O_EXCL을 사용하지 않음.
187추가: handles.temp = Some(opened(
188추가: unsafe {
189추가: libc::openat(
190추가: parent.as_raw_fd(),
191추가: c".".as_ptr(),
192추가: libc::O_TMPFILE | libc::O_RDWR | libc::O_CLOEXEC,
193추가: 0o600 as libc::mode_t,
194추가: )
195추가: } as libc::c_long,
196추가: "openat_tmpfile",
197추가: )?);
198추가: let temp = handles.temp.as_mut().expect("owned temporary file");
199추가: let initial = metadata(temp, run)?;
200추가: if !initial.is_file()
201추가: || initial.nlink() != 0
202추가: || initial.uid() != uid
203추가: || initial.dev() != parent_meta.dev()
204추가: {
205추가: return Err(Error::InvalidTemporaryFile);
206추가: }
207추가: let mut offset = 0;
208추가: while offset < request.bytes.len() {
209추가: run.check(Stage::Writing, offset, callback)?;
210추가: let end = (offset + CHUNK_BYTES).min(request.bytes.len());
211추가: run.reserve(end - offset, true)?;
212추가: // 읽기 전용 입력 슬라이스의 유효 범위만 커널에 전달함.
213추가: let result = unsafe {
214추가: libc::write(
215추가: temp.as_raw_fd(),
216추가: request.bytes[offset..end].as_ptr().cast(),
217추가: end - offset,
218추가: )
219추가: };
220추가: if result < 0 {
221추가: return Err(io_error("write", io::Error::last_os_error()));
222추가: }
223추가: let count = result as usize;
224추가: run.usage.actual_written_bytes += count as u64;
225추가: if count == 0 {
226추가: return Err(io_error("write", io::Error::from(io::ErrorKind::WriteZero)));
227추가: }
228추가: offset += count;
229추가: }
230추가: run.check(Stage::Verifying, 0, callback)?;
231추가: run.usage.sync_calls += 1;
232추가: sync(temp).map_err(|error| io_error("fsync_file", error))?;
233추가: // 소유한 임시 파일의 읽기 위치만 이동함.
234추가: if unsafe { libc::lseek(temp.as_raw_fd(), 0, libc::SEEK_SET) } < 0 {
235추가: return Err(io_error("lseek", io::Error::last_os_error()));
236추가: }
237추가: let mut scratch = [0_u8; CHUNK_BYTES];
238추가: offset = 0;
239추가: while offset < request.bytes.len() {
240추가: run.check(Stage::Verifying, offset, callback)?;
241추가: let count = CHUNK_BYTES.min(request.bytes.len() - offset);
242추가: run.reserve(count, false)?;
243추가: let read =
244추가: read_once(temp, &mut scratch[..count]).map_err(|error| io_error("read", error))?;
245추가: run.usage.actual_read_bytes += read as u64;
246추가: if read == 0 || scratch[..read] != request.bytes[offset..offset + read] {
247추가: return Err(Error::VerificationMismatch);
248추가: }
249추가: offset += read;
250추가: }
251추가: run.check(Stage::Verifying, offset, callback)?;
252추가: run.reserve(1, false)?;
253추가: let extra = read_once(temp, &mut scratch[..1]).map_err(|error| io_error("read_eof", error))?;
254추가: run.usage.actual_read_bytes += extra as u64;
255추가: if extra != 0 {
256추가: return Err(Error::VerificationMismatch);
257추가: }
258추가: let final_meta = metadata(temp, run)?;
259추가: if identity(&final_meta) != identity(&initial)
260추가: || !final_meta.is_file()
261추가: || final_meta.nlink() != 0
262추가: || final_meta.len() != request.bytes.len() as u64
263추가: {
264추가: return Err(Error::VerificationMismatch);
265추가: }
266추가: // procfs 연결 방식은 파일 계층용이며 worker 실행 우회가 아님.
267추가: handles.proc_root = Some(open2(
268추가: libc::AT_FDCWD,
269추가: c"/proc",
270추가: libc::O_PATH | libc::O_DIRECTORY | libc::O_CLOEXEC,
271추가: NO_SYMLINKS,
272추가: run,
273추가: )?);
274추가: let proc_root = handles.proc_root.as_ref().expect("owned proc root");
275추가: if filesystem(proc_root, run)? != 0x9fa0 {
276추가: return Err(Error::UnsupportedFilesystem);
277추가: }
278추가: // 현재 프로세스의 숫자 경로를 사용해 self 심볼릭 링크를 피함.
279추가: let pid = unsafe { libc::getpid() };
280추가: let proc_path = CString::new(format!("{pid}/fd")).map_err(|_| Error::InvalidPath)?;
281추가: handles.proc_fds = Some(open2(
282추가: proc_root.as_raw_fd(),
283추가: &proc_path,
284추가: libc::O_PATH | libc::O_DIRECTORY | libc::O_CLOEXEC,
285추가: BENEATH | NO_SYMLINKS | NO_XDEV,
286추가: run,
287추가: )?);
288추가: let proc_fds = handles.proc_fds.as_ref().expect("owned proc fd directory");
289추가: let fd_name = CString::new(temp.as_raw_fd().to_string()).map_err(|_| Error::InvalidPath)?;
290추가: run.check(Stage::BeforeCommit, offset, callback)?;
291추가: run.begin_commit()?;
292추가: run.usage.link_calls += 1;
293추가: // CAS 이후 callback 없이 소유 fd와 고정 부모 사이의 원자적 링크를 한 번 시도함.
294추가: let linked = unsafe {
295추가: libc::linkat(
296추가: proc_fds.as_raw_fd(),
297추가: fd_name.as_ptr(),
298추가: parent.as_raw_fd(),
299추가: leaf.as_ptr(),
300추가: libc::AT_SYMLINK_FOLLOW,
301추가: )
302추가: };
303추가: if linked != 0 {
304추가: let source = io::Error::last_os_error();
305추가: if source.raw_os_error() == Some(libc::EEXIST) {
306추가: return Err(io_error("linkat_conflict", source));
307추가: }
308추가: return Ok(Outcome::CommitUncertain { source });
309추가: }
310추가: let receipt = FileCommitReceipt {
311추가: parent: identity(&parent_meta),
312추가: file: identity(&initial),
313추가: length: run.length,
314추가: };
315추가: run.usage.sync_calls += 1;
316추가: let durability = match sync(parent) {
317추가: Ok(()) => Durability::FileAndParentSynced,
318추가: Err(error) => Durability::ParentSyncFailed(error),
319추가: };
320추가: Ok(Outcome::Committed {
321추가: receipt,
322추가: durability,
323추가: })
324추가: }
325추가:
326추가: fn read_once(file: &File, buffer: &mut [u8]) -> io::Result<usize> {
327추가: // 독점 대여한 버퍼의 길이 안에서만 읽으며 EINTR도 원형으로 반환함.
328추가: let result = unsafe { libc::read(file.as_raw_fd(), buffer.as_mut_ptr().cast(), buffer.len()) };
329추가: if result < 0 {
330추가: Err(io::Error::last_os_error())
331추가: } else {
332추가: Ok(result as usize)
333추가: }
334추가: }
335추가:
336추가: fn sync(file: &File) -> io::Result<()> {
337추가: // 소유 fd에 한 번만 fsync를 호출함.
338추가: if unsafe { libc::fsync(file.as_raw_fd()) } == 0 {
339추가: Ok(())
340추가: } else {
341추가: Err(io::Error::last_os_error())
342추가: }
343추가: }
추가experiments/rust-file-publication/static-validation.json+54-0
@@ -0,0 +1,54 @@
1추가: {
2추가: "kind": "author source/static only",
3추가: "commands": [
4추가: {
5추가: "command": [
6추가: "rustfmt",
7추가: "+1.99.1",
8추가: "--edition",
9추가: "2024",
10추가: "experiments/rust-file-publication/src/lib.rs",
11추가: "experiments/rust-file-publication/src/linux.rs"
12추가: ],
13추가: "exit_code": 0,
14추가: "stdout_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
15추가: "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
16추가: },
17추가: {
18추가: "command": [
19추가: "rustfmt",
20추가: "+1.99.1",
21추가: "--edition",
22추가: "2024",
23추가: "--check",
24추가: "experiments/rust-file-publication/src/lib.rs",
25추가: "experiments/rust-file-publication/src/linux.rs"
26추가: ],
27추가: "exit_code": 0,
28추가: "stdout_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
29추가: "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
30추가: },
31추가: {
32추가: "command": [
33추가: "cargo",
34추가: "+1.99.1",
35추가: "metadata",
36추가: "--locked",
37추가: "--offline",
38추가: "--format-version",
39추가: "1",
40추가: "--manifest-path",
41추가: "experiments/rust-file-publication/Cargo.toml"
42추가: ],
43추가: "exit_code": 0,
44추가: "stdout_sha256": "22874e27b6910977181b21cc2fba7547531ae3ca782c86bab5dacd7f5017081b",
45추가: "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
46추가: }
47추가: ],
48추가: "structural_checks": "passed; syntax/shape assertions, not typecheck or runtime evidence",
49추가: "rust_compile": false,
50추가: "publication_executed": false,
51추가: "regression_execution": false,
52추가: "dependency_archive_and_source_check": "libc 0.2.191 checksum and 452 cached regular files matched",
53추가: "limits": "No current advisory audit or filesystem support verification"
54추가: }