목록과 미리보기 임시 파일을 여유 있는 위치에 저장함
- 작성자
- 시로사키 하나
- 작성 시각
- 커밋
c942f313e43826b3cb1732393f1c3066cbfb36e7- 부모
- ccb80fd
변경된 파일 7개
+754-21| @@ -595,6 +595,9 @@ impl<W: Write> Job<W> { | ||
| 595 | 595 | .and_then(|path| Dir::root(&path).ok()) |
| 596 | 596 | .map(|root| crate::spool::place_in(&root)) |
| 597 | 597 | .transpose()?, |
| 598 | 추가: Action::List { archive } | Action::Preview { archive, .. } => { | |
| 599 | 추가: Some(crate::spool::fallback_for(&archive.to_path()?)) | |
| 600 | 추가: } | |
| 598 | 601 | _ => None, |
| 599 | 602 | }; |
| 600 | 603 | if let Some(budget) = &self.budget { |
| @@ -8,27 +8,107 @@ use std::{ | ||
| 8 | 8 | |
| 9 | 9 | type Result<T> = std::result::Result<T, ErrorCode>; |
| 10 | 10 | |
| 11 | 추가: enum Placement { | |
| 12 | 추가: Fixed(filesystem::Dir), | |
| 13 | 추가: Fallback { | |
| 14 | 추가: source_parent: std::path::PathBuf, | |
| 15 | 추가: next: usize, | |
| 16 | 추가: other_error: Option<ErrorCode>, | |
| 17 | 추가: }, | |
| 18 | 추가: } | |
| 19 | 추가: | |
| 11 | 20 | thread_local! { |
| 12 | 삭제: // 작업 스레드가 지정한 임시 파일 위치. 없으면 시스템 임시 폴더를 사용함. | |
| 13 | 삭제: static LOCATION: std::cell::RefCell<Option<filesystem::Dir>> = | |
| 21 | 추가: // 작업 스레드의 임시 파일 정책만 보관함. | |
| 22 | 추가: static LOCATION: std::cell::RefCell<Option<Placement>> = | |
| 14 | 23 | const { std::cell::RefCell::new(None) }; |
| 15 | 24 | // 출력 폴더에 이름 있는 임시 파일을 만든 뒤 이름을 지우지 못했는지 기록함. |
| 16 | 25 | static LEFTOVER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; |
| 17 | 26 | } |
| 18 | 27 | |
| 19 | 삭제: /// 해제 작업의 임시 파일을 출력 폴더에 두도록 지정함. 반환값이 사라지면 해제됨. | |
| 20 | 삭제: /// 작업은 한 스레드에서 실행되므로 다른 작업이나 시험에 섞이지 않음. | |
| 21 | 삭제: pub(crate) struct Location(()); | |
| 28 | 추가: pub(crate) struct Location(Option<Placement>); | |
| 22 | 29 | impl Drop for Location { |
| 23 | 30 | fn drop(&mut self) { |
| 24 | 삭제: LOCATION.with(|location| *location.borrow_mut() = None); | |
| 31 | 추가: LOCATION.with(|location| *location.borrow_mut() = self.0.take()); | |
| 25 | 32 | } |
| 26 | 33 | } |
| 27 | 34 | pub(crate) fn place_in(dir: &filesystem::Dir) -> Result<Location> { |
| 28 | 삭제: let dir = dir.duplicate()?; | |
| 29 | 삭제: LOCATION.with(|location| *location.borrow_mut() = Some(dir)); | |
| 35 | 추가: let placement = Placement::Fixed(dir.duplicate()?); | |
| 36 | 추가: LEFTOVER.with(|leftover| leftover.set(false)); | |
| 37 | 추가: Ok(LOCATION.with(|location| Location(location.replace(Some(placement))))) | |
| 38 | 추가: } | |
| 39 | 추가: pub(crate) fn fallback_for(path: &Path) -> Location { | |
| 30 | 40 | LEFTOVER.with(|leftover| leftover.set(false)); |
| 31 | 삭제: Ok(Location(())) | |
| 41 | 추가: let placement = Placement::Fallback { | |
| 42 | 추가: source_parent: path.parent().unwrap_or(Path::new("")).to_path_buf(), | |
| 43 | 추가: next: 0, | |
| 44 | 추가: other_error: None, | |
| 45 | 추가: }; | |
| 46 | 추가: LOCATION.with(|location| Location(location.replace(Some(placement)))) | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: #[cfg(target_os = "linux")] | |
| 50 | 추가: fn private_directory(path: &Path) -> Result<filesystem::Dir> { | |
| 51 | 추가: if !path.is_absolute() { | |
| 52 | 추가: return Err(ErrorCode::Io); | |
| 53 | 추가: } | |
| 54 | 추가: match filesystem::Dir::root(path) { | |
| 55 | 추가: Ok(dir) => Ok(dir), | |
| 56 | 추가: Err(error) => { | |
| 57 | 추가: if !matches!(std::fs::symlink_metadata(path), Err(ref e) if e.kind() == std::io::ErrorKind::NotFound) | |
| 58 | 추가: { | |
| 59 | 추가: return Err(error); | |
| 60 | 추가: } | |
| 61 | 추가: let parent = private_directory(path.parent().ok_or(ErrorCode::Io)?)?; | |
| 62 | 추가: let name = path | |
| 63 | 추가: .file_name() | |
| 64 | 추가: .and_then(|n| n.to_str()) | |
| 65 | 추가: .ok_or(ErrorCode::Io)?; | |
| 66 | 추가: parent.child(name, true)?.ok_or(ErrorCode::Io) | |
| 67 | 추가: } | |
| 68 | 추가: } | |
| 69 | 추가: } | |
| 70 | 추가: fn cache_directory() -> Result<filesystem::Dir> { | |
| 71 | 추가: #[cfg(target_os = "linux")] | |
| 72 | 추가: { | |
| 73 | 추가: let base = match std::env::var_os("XDG_CACHE_HOME").filter(|p| !p.is_empty()) { | |
| 74 | 추가: Some(path) => std::path::PathBuf::from(path), | |
| 75 | 추가: None => std::path::PathBuf::from(std::env::var_os("HOME").ok_or(ErrorCode::Io)?) | |
| 76 | 추가: .join(".cache"), | |
| 77 | 추가: }; | |
| 78 | 추가: private_directory(&base)? | |
| 79 | 추가: .child("zipelo", true)? | |
| 80 | 추가: .ok_or(ErrorCode::Io) | |
| 81 | 추가: } | |
| 82 | 추가: #[cfg(windows)] | |
| 83 | 추가: { | |
| 84 | 추가: let base = std::path::PathBuf::from(std::env::var_os("LOCALAPPDATA").ok_or(ErrorCode::Io)?); | |
| 85 | 추가: if !base.is_absolute() { | |
| 86 | 추가: return Err(ErrorCode::Io); | |
| 87 | 추가: } | |
| 88 | 추가: filesystem::Dir::root(&base)? | |
| 89 | 추가: .child("Zipelo", true)? | |
| 90 | 추가: .ok_or(ErrorCode::Io)? | |
| 91 | 추가: .child("Temp", true)? | |
| 92 | 추가: .ok_or(ErrorCode::Io) | |
| 93 | 추가: } | |
| 94 | 추가: } | |
| 95 | 추가: fn next_after_full() -> Result<bool> { | |
| 96 | 추가: LOCATION.with(|location| { | |
| 97 | 추가: let mut location = location.borrow_mut(); | |
| 98 | 추가: match location.as_mut() { | |
| 99 | 추가: Some(Placement::Fallback { | |
| 100 | 추가: next, other_error, .. | |
| 101 | 추가: }) => { | |
| 102 | 추가: *next += 1; | |
| 103 | 추가: if *next >= 3 { | |
| 104 | 추가: Err(other_error.unwrap_or(ErrorCode::DiskFull)) | |
| 105 | 추가: } else { | |
| 106 | 추가: Ok(true) | |
| 107 | 추가: } | |
| 108 | 추가: } | |
| 109 | 추가: _ => Ok(false), | |
| 110 | 추가: } | |
| 111 | 추가: }) | |
| 32 | 112 | } |
| 33 | 113 | |
| 34 | 114 | /// 출력 폴더에 지우지 못한 임시 파일이 남았음을 기록함. Windows 임시 파일은 닫으면 지워지므로 |
| @@ -43,25 +123,64 @@ pub(crate) fn take_leftover() -> bool { | ||
| 43 | 123 | LEFTOVER.with(|leftover| leftover.replace(false)) |
| 44 | 124 | } |
| 45 | 125 | |
| 126 | 추가: /// 실패한 단계의 임시 파일이 닫힌 뒤 다음 위치에서 다시 시도함. | |
| 127 | 추가: pub(crate) fn retry_full<T>(mut operation: impl FnMut() -> Result<T>) -> Result<T> { | |
| 128 | 추가: loop { | |
| 129 | 추가: match operation() { | |
| 130 | 추가: Err(ErrorCode::DiskFull) if next_after_full()? => continue, | |
| 131 | 추가: result => return result, | |
| 132 | 추가: } | |
| 133 | 추가: } | |
| 134 | 추가: } | |
| 135 | 추가: | |
| 46 | 136 | pub(crate) fn random_name() -> Result<String> { |
| 47 | 137 | let mut random = [0; 16]; |
| 48 | 138 | crate::crypto::random(&mut random)?; |
| 49 | 139 | Ok(random.iter().map(|b| format!("{b:02x}")).collect()) |
| 50 | 140 | } |
| 51 | 141 | |
| 52 | 삭제: /// 이름 없는 임시 파일을 만듦. 해제 작업에서는 출력 폴더에, 그 외에는 시스템 임시 폴더에 둠. | |
| 53 | 삭제: /// 출력 폴더에 두면 공간 판단이 실제 출력 디스크와 같아지고 /tmp 크기나 할당량에 묶이지 않음. | |
| 54 | 삭제: /// 출력 폴더에 만들지 못하면(읽기 전용, 공간 부족 등) 이 작업의 남은 임시 파일은 모두 | |
| 55 | 삭제: /// 기존 시스템 임시 폴더에 둠. 그러면 동작과 오류 우선순위가 이전과 같아지며, 출력 폴더 | |
| 56 | 삭제: /// 문제는 원래의 출력 확인 지점에서 보고됨. | |
| 142 | 추가: /// 지정한 정책에 따라 이름 없는 임시 파일을 만듦. | |
| 57 | 143 | pub(crate) fn temporary() -> Result<File> { |
| 58 | 삭제: let placed = | |
| 59 | 삭제: LOCATION.with(|location| location.borrow().as_ref().map(filesystem::Dir::temporary)); | |
| 60 | 삭제: match placed { | |
| 61 | 삭제: Some(Ok(file)) => return Ok(file), | |
| 62 | 삭제: Some(Err(_)) => LOCATION.with(|location| *location.borrow_mut() = None), | |
| 63 | 삭제: None => {} | |
| 64 | 삭제: } | |
| 144 | 추가: let placed = LOCATION.with(|location| { | |
| 145 | 추가: let mut location = location.borrow_mut(); | |
| 146 | 추가: match location.as_mut() { | |
| 147 | 추가: Some(Placement::Fixed(dir)) => match dir.temporary() { | |
| 148 | 추가: Ok(file) => Some(Ok(file)), | |
| 149 | 추가: Err(_) => { | |
| 150 | 추가: *location = None; | |
| 151 | 추가: None | |
| 152 | 추가: } | |
| 153 | 추가: }, | |
| 154 | 추가: Some(Placement::Fallback { | |
| 155 | 추가: source_parent, | |
| 156 | 추가: next, | |
| 157 | 추가: other_error, | |
| 158 | 추가: }) => { | |
| 159 | 추가: while *next < 3 { | |
| 160 | 추가: let file = match *next { | |
| 161 | 추가: 0 => cache_directory().and_then(|dir| dir.temporary()), | |
| 162 | 추가: 1 => filesystem::Dir::root(source_parent).and_then(|dir| dir.temporary()), | |
| 163 | 추가: _ => system_temporary(), | |
| 164 | 추가: }; | |
| 165 | 추가: match file { | |
| 166 | 추가: Ok(file) => return Some(Ok(file)), | |
| 167 | 추가: Err(error) => { | |
| 168 | 추가: if error != ErrorCode::DiskFull { | |
| 169 | 추가: *other_error = Some(ErrorCode::Io); | |
| 170 | 추가: } | |
| 171 | 추가: *next += 1; | |
| 172 | 추가: } | |
| 173 | 추가: } | |
| 174 | 추가: } | |
| 175 | 추가: Some(Err(other_error.unwrap_or(ErrorCode::DiskFull))) | |
| 176 | 추가: } | |
| 177 | 추가: None => None, | |
| 178 | 추가: } | |
| 179 | 추가: }); | |
| 180 | 추가: placed.unwrap_or_else(system_temporary) | |
| 181 | 추가: } | |
| 182 | 추가: | |
| 183 | 추가: fn system_temporary() -> Result<File> { | |
| 65 | 184 | #[cfg(target_os = "linux")] |
| 66 | 185 | { |
| 67 | 186 | use std::os::unix::fs::OpenOptionsExt; |
| @@ -193,6 +312,26 @@ impl Snapshot { | ||
| 193 | 312 | source: &mut File, |
| 194 | 313 | limit: u64, |
| 195 | 314 | step: &mut impl FnMut(Step) -> Result<()>, |
| 315 | 추가: ) -> Result<Self> { | |
| 316 | 추가: let original = source.metadata().map_err(|_| ErrorCode::Io)?; | |
| 317 | 추가: loop { | |
| 318 | 추가: step(Step::Check)?; | |
| 319 | 추가: let current = source.metadata().map_err(|_| ErrorCode::Io)?; | |
| 320 | 추가: if current.len() != original.len() | |
| 321 | 추가: || current.modified().ok() != original.modified().ok() | |
| 322 | 추가: { | |
| 323 | 추가: return Err(ErrorCode::SourceChanged); | |
| 324 | 추가: } | |
| 325 | 추가: match Self::capture_once(source, limit, step) { | |
| 326 | 추가: Err(ErrorCode::DiskFull) if next_after_full()? => continue, | |
| 327 | 추가: result => return result, | |
| 328 | 추가: } | |
| 329 | 추가: } | |
| 330 | 추가: } | |
| 331 | 추가: fn capture_once( | |
| 332 | 추가: source: &mut File, | |
| 333 | 추가: limit: u64, | |
| 334 | 추가: step: &mut impl FnMut(Step) -> Result<()>, | |
| 196 | 335 | ) -> Result<Self> { |
| 197 | 336 | let before = completed(source.metadata().map_err(|_| ErrorCode::Io), step)?; |
| 198 | 337 | if !before.is_file() { |
| @@ -74,6 +74,19 @@ impl Catalog { | ||
| 74 | 74 | password: Option<&[u8]>, |
| 75 | 75 | selected: Option<u32>, |
| 76 | 76 | check: &mut impl crate::resources::Monitor, |
| 77 | 추가: ) -> Result<Self> { | |
| 78 | 추가: spool::retry_full(|| { | |
| 79 | 추가: Self::open_selected_once(source, len, limits, decode, password, selected, check) | |
| 80 | 추가: }) | |
| 81 | 추가: } | |
| 82 | 추가: fn open_selected_once( | |
| 83 | 추가: source: &mut File, | |
| 84 | 추가: len: u64, | |
| 85 | 추가: limits: Limits, | |
| 86 | 추가: decode: bool, | |
| 87 | 추가: password: Option<&[u8]>, | |
| 88 | 추가: selected: Option<u32>, | |
| 89 | 추가: check: &mut impl crate::resources::Monitor, | |
| 77 | 90 | ) -> Result<Self> { |
| 78 | 91 | let mut magic = [0; 6]; |
| 79 | 92 | let n = len.min(6) as usize; |
| @@ -1637,3 +1637,6 @@ mod partial_output; | ||
| 1637 | 1637 | |
| 1638 | 1638 | #[cfg(target_os = "linux")] |
| 1639 | 1639 | mod spool_location; |
| 1640 | 추가: | |
| 1641 | 추가: #[cfg(target_os = "linux")] | |
| 1642 | 추가: mod spool_fallback; |
| @@ -0,0 +1,421 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: use std::{ | |
| 3 | 추가: io::Read, | |
| 4 | 추가: os::unix::fs::{DirBuilderExt, PermissionsExt}, | |
| 5 | 추가: process::Child, | |
| 6 | 추가: sync::mpsc, | |
| 7 | 추가: time::Duration, | |
| 8 | 추가: }; | |
| 9 | 추가: | |
| 10 | 추가: struct Running(Child); | |
| 11 | 추가: impl Drop for Running { | |
| 12 | 추가: fn drop(&mut self) { | |
| 13 | 추가: let _ = self.0.kill(); | |
| 14 | 추가: let _ = self.0.wait(); | |
| 15 | 추가: } | |
| 16 | 추가: } | |
| 17 | 추가: | |
| 18 | 추가: const PAYLOAD: &[u8] = b"spool fallback preview\n"; | |
| 19 | 추가: struct Case { | |
| 20 | 추가: scratch: Scratch, | |
| 21 | 추가: } | |
| 22 | 추가: impl Case { | |
| 23 | 추가: fn new() -> Self { | |
| 24 | 추가: let scratch = Scratch::new(); | |
| 25 | 추가: for name in ["cache", "archive", "system"] { | |
| 26 | 추가: fs::DirBuilder::new() | |
| 27 | 추가: .mode(0o700) | |
| 28 | 추가: .create(scratch.0.join(name)) | |
| 29 | 추가: .unwrap(); | |
| 30 | 추가: } | |
| 31 | 추가: assert!( | |
| 32 | 추가: Command::new("python3") | |
| 33 | 추가: .arg("-B") | |
| 34 | 추가: .arg( | |
| 35 | 추가: PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 36 | 추가: .join("../../tests/rust-archive-worker/spool_fallback_cases.py") | |
| 37 | 추가: ) | |
| 38 | 추가: .arg(&scratch.0) | |
| 39 | 추가: .status() | |
| 40 | 추가: .unwrap() | |
| 41 | 추가: .success() | |
| 42 | 추가: ); | |
| 43 | 추가: Self { scratch } | |
| 44 | 추가: } | |
| 45 | 추가: fn run(&self, action: Action, phase: &str, mask: u8, named: bool) -> Vec<Message> { | |
| 46 | 추가: let s = &self.scratch; | |
| 47 | 추가: let mut command = s.worker(); | |
| 48 | 추가: command | |
| 49 | 추가: .env("XDG_CACHE_HOME", s.0.join("cache")) | |
| 50 | 추가: .env( | |
| 51 | 추가: "TMPDIR", | |
| 52 | 추가: if phase == "real" { | |
| 53 | 추가: PathBuf::from(std::env::var_os("ZIPELO_SPOOL_REAL_TMP").unwrap()) | |
| 54 | 추가: } else { | |
| 55 | 추가: s.0.join("system") | |
| 56 | 추가: }, | |
| 57 | 추가: ) | |
| 58 | 추가: .env("HOME", &s.0); | |
| 59 | 추가: if phase == "home" { | |
| 60 | 추가: command.env_remove("XDG_CACHE_HOME"); | |
| 61 | 추가: } | |
| 62 | 추가: if phase == "changed" { | |
| 63 | 추가: command.env( | |
| 64 | 추가: "ZIPELO_SPOOL_SOURCE", | |
| 65 | 추가: self.archive("zip").to_path().unwrap(), | |
| 66 | 추가: ); | |
| 67 | 추가: } | |
| 68 | 추가: if phase != "real" { | |
| 69 | 추가: let library = s.0.join("location.so"); | |
| 70 | 추가: if !library.exists() { | |
| 71 | 추가: assert!( | |
| 72 | 추가: Command::new("cc") | |
| 73 | 추가: .args(["-shared", "-fPIC", "-O2", "-Wall", "-Wextra", "-Werror"]) | |
| 74 | 추가: .arg( | |
| 75 | 추가: PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 76 | 추가: .join("../../tests/rust-archive-worker/spool_location_fault.c") | |
| 77 | 추가: ) | |
| 78 | 추가: .args(["-ldl", "-o"]) | |
| 79 | 추가: .arg(&library) | |
| 80 | 추가: .status() | |
| 81 | 추가: .unwrap() | |
| 82 | 추가: .success() | |
| 83 | 추가: ); | |
| 84 | 추가: } | |
| 85 | 추가: command | |
| 86 | 추가: .env("LD_PRELOAD", library) | |
| 87 | 추가: .env("ZIPELO_SPOOL_PHASE", phase) | |
| 88 | 추가: .env("ZIPELO_SPOOL_MASK", mask.to_string()) | |
| 89 | 추가: .env("ZIPELO_SPOOL_TRACE", s.0.join("trace")); | |
| 90 | 추가: if named { | |
| 91 | 추가: command.env("ZIPELO_SPOOL_NAMED", "1"); | |
| 92 | 추가: } | |
| 93 | 추가: } | |
| 94 | 추가: let mut child = Running( | |
| 95 | 추가: command | |
| 96 | 추가: .stdin(Stdio::piped()) | |
| 97 | 추가: .stdout(Stdio::piped()) | |
| 98 | 추가: .stderr(Stdio::piped()) | |
| 99 | 추가: .spawn() | |
| 100 | 추가: .unwrap(), | |
| 101 | 추가: ); | |
| 102 | 추가: let preview = matches!(action, Action::Preview { .. }); | |
| 103 | 추가: let start = Start { | |
| 104 | 추가: action, | |
| 105 | 추가: limits: Limits::default(), | |
| 106 | 추가: }; | |
| 107 | 추가: let message = if preview { | |
| 108 | 추가: Message::StartGuarded(GuardedStart { | |
| 109 | 추가: start, | |
| 110 | 추가: ceiling: Limits::default(), | |
| 111 | 추가: interactive: true, | |
| 112 | 추가: }) | |
| 113 | 추가: } else { | |
| 114 | 추가: Message::Start(start) | |
| 115 | 추가: }; | |
| 116 | 추가: let mut writer = Some(Writer::new(child.0.stdin.take().unwrap(), 17)); | |
| 117 | 추가: writer.as_mut().unwrap().send(&message).unwrap(); | |
| 118 | 추가: let stdout = child.0.stdout.take().unwrap(); | |
| 119 | 추가: let mut stderr = child.0.stderr.take().unwrap(); | |
| 120 | 추가: let (send, receive) = mpsc::sync_channel(128); | |
| 121 | 추가: let reader = std::thread::spawn(move || { | |
| 122 | 추가: let mut reader = Reader::new(stdout); | |
| 123 | 추가: loop { | |
| 124 | 추가: let frame = reader.read(); | |
| 125 | 추가: let done = !matches!(frame, Ok(Some(_))); | |
| 126 | 추가: if send.send(frame).is_err() || done { | |
| 127 | 추가: break; | |
| 128 | 추가: } | |
| 129 | 추가: } | |
| 130 | 추가: }); | |
| 131 | 추가: let mut events = Vec::new(); | |
| 132 | 추가: loop { | |
| 133 | 추가: let Some((job, _, event)) = receive | |
| 134 | 추가: .recv_timeout(Duration::from_secs(30)) | |
| 135 | 추가: .expect("worker timeout") | |
| 136 | 추가: .unwrap() | |
| 137 | 추가: else { | |
| 138 | 추가: break; | |
| 139 | 추가: }; | |
| 140 | 추가: assert_eq!(job, 17); | |
| 141 | 추가: assert!( | |
| 142 | 추가: !matches!( | |
| 143 | 추가: event, | |
| 144 | 추가: Message::ResourceRequired { .. } | Message::PasswordRequired { .. } | |
| 145 | 추가: ), | |
| 146 | 추가: "{event:?}" | |
| 147 | 추가: ); | |
| 148 | 추가: if matches!(event, Message::Terminal(_)) { | |
| 149 | 추가: drop(writer.take()); | |
| 150 | 추가: } | |
| 151 | 추가: events.push(event); | |
| 152 | 추가: } | |
| 153 | 추가: assert!(child.0.wait().unwrap().success(), "{events:?}"); | |
| 154 | 추가: let mut errors = Vec::new(); | |
| 155 | 추가: stderr.read_to_end(&mut errors).unwrap(); | |
| 156 | 추가: assert!(errors.is_empty(), "{errors:?}"); | |
| 157 | 추가: reader.join().unwrap(); | |
| 158 | 추가: assert_eq!( | |
| 159 | 추가: events | |
| 160 | 추가: .iter() | |
| 161 | 추가: .filter(|e| matches!(e, Message::Terminal(_))) | |
| 162 | 추가: .count(), | |
| 163 | 추가: 1 | |
| 164 | 추가: ); | |
| 165 | 추가: self.clean(); | |
| 166 | 추가: events | |
| 167 | 추가: } | |
| 168 | 추가: fn archive(&self, format: &str) -> NativePath { | |
| 169 | 추가: self.scratch.path(&format!("archive/input.{format}")) | |
| 170 | 추가: } | |
| 171 | 추가: fn list(&self, format: &str, phase: &str, mask: u8, named: bool) -> Vec<Message> { | |
| 172 | 추가: self.run( | |
| 173 | 추가: Action::List { | |
| 174 | 추가: archive: self.archive(format), | |
| 175 | 추가: }, | |
| 176 | 추가: phase, | |
| 177 | 추가: mask, | |
| 178 | 추가: named, | |
| 179 | 추가: ) | |
| 180 | 추가: } | |
| 181 | 추가: fn clean(&self) { | |
| 182 | 추가: let root = &self.scratch.0; | |
| 183 | 추가: for directory in ["cache/zipelo", ".cache/zipelo", "system"] { | |
| 184 | 추가: let path = root.join(directory); | |
| 185 | 추가: if path.is_dir() { | |
| 186 | 추가: assert_eq!(fs::read_dir(&path).unwrap().count(), 0, "{path:?}"); | |
| 187 | 추가: } | |
| 188 | 추가: } | |
| 189 | 추가: assert_eq!(fs::read_dir(root.join("archive")).unwrap().count(), 2); | |
| 190 | 추가: } | |
| 191 | 추가: fn preview(&self, format: &str, phase: &str, mask: u8, named: bool) -> Vec<Message> { | |
| 192 | 추가: let events = self.list(format, phase, mask, named); | |
| 193 | 추가: assert_eq!( | |
| 194 | 추가: terminal(&events).outcome, | |
| 195 | 추가: Outcome::Completed, | |
| 196 | 추가: "{format}/{phase}/{mask}: {events:?}" | |
| 197 | 추가: ); | |
| 198 | 추가: let list_id = events | |
| 199 | 추가: .iter() | |
| 200 | 추가: .find_map(|e| match e { | |
| 201 | 추가: Message::ListEnd { list_id, .. } => Some(list_id.clone()), | |
| 202 | 추가: _ => None, | |
| 203 | 추가: }) | |
| 204 | 추가: .unwrap(); | |
| 205 | 추가: let entry_id = events | |
| 206 | 추가: .iter() | |
| 207 | 추가: .find_map(|e| match e { | |
| 208 | 추가: Message::Entry(entry) if entry.name == "preview.txt" => Some(entry.entry_id), | |
| 209 | 추가: _ => None, | |
| 210 | 추가: }) | |
| 211 | 추가: .unwrap(); | |
| 212 | 추가: self.run( | |
| 213 | 추가: Action::Preview { | |
| 214 | 추가: archive: self.archive(format), | |
| 215 | 추가: list_id, | |
| 216 | 추가: entry_id, | |
| 217 | 추가: }, | |
| 218 | 추가: phase, | |
| 219 | 추가: mask, | |
| 220 | 추가: named, | |
| 221 | 추가: ) | |
| 222 | 추가: } | |
| 223 | 추가: fn assert_preview(&self, format: &str, phase: &str, mask: u8, named: bool) { | |
| 224 | 추가: let path = self.scratch.0.join(format!("archive/input.{format}")); | |
| 225 | 추가: let original = fs::read(&path).unwrap(); | |
| 226 | 추가: assert!(original.len() > 16 * 1024 * 1024); | |
| 227 | 추가: let events = self.preview(format, phase, mask, named); | |
| 228 | 추가: assert_eq!( | |
| 229 | 추가: terminal(&events).outcome, | |
| 230 | 추가: Outcome::Completed, | |
| 231 | 추가: "{format}/{phase}/{mask}: {events:?}" | |
| 232 | 추가: ); | |
| 233 | 추가: let mut preview = Vec::new(); | |
| 234 | 추가: for event in &events { | |
| 235 | 추가: if let Message::PreviewChunk { data, .. } = event { | |
| 236 | 추가: preview.extend_from_slice(data); | |
| 237 | 추가: } | |
| 238 | 추가: } | |
| 239 | 추가: assert_eq!(preview, PAYLOAD); | |
| 240 | 추가: assert!( | |
| 241 | 추가: events | |
| 242 | 추가: .iter() | |
| 243 | 추가: .any(|e| matches!(e, Message::PreviewEnd { .. })) | |
| 244 | 추가: ); | |
| 245 | 추가: assert_eq!(fs::read(path).unwrap(), original); | |
| 246 | 추가: } | |
| 247 | 추가: } | |
| 248 | 추가: #[test] | |
| 249 | 추가: fn cache_source_and_system_locations_retry_creation_space_and_partial_quota_writes() { | |
| 250 | 추가: for named in [false, true] { | |
| 251 | 추가: for phase in ["create", "space", "write"] { | |
| 252 | 추가: for mask in [0, 1, 3] { | |
| 253 | 추가: let c = Case::new(); | |
| 254 | 추가: for format in ["zip", "7z"] { | |
| 255 | 추가: c.assert_preview(format, phase, mask, named); | |
| 256 | 추가: } | |
| 257 | 추가: let trace = fs::read_to_string(c.scratch.0.join("trace")).unwrap(); | |
| 258 | 추가: let expected = match mask { | |
| 259 | 추가: 0 => '0', | |
| 260 | 추가: 1 => '1', | |
| 261 | 추가: _ => '2', | |
| 262 | 추가: }; | |
| 263 | 추가: assert!(trace.contains(expected), "{phase}/{mask}: {trace}"); | |
| 264 | 추가: if mask == 0 { | |
| 265 | 추가: assert!(!trace.contains('1') && !trace.contains('2'), "{trace}"); | |
| 266 | 추가: } | |
| 267 | 추가: if mask == 1 { | |
| 268 | 추가: assert!(!trace.contains('2'), "{trace}"); | |
| 269 | 추가: } | |
| 270 | 추가: } | |
| 271 | 추가: } | |
| 272 | 추가: } | |
| 273 | 추가: } | |
| 274 | 추가: #[test] | |
| 275 | 추가: fn disk_full_requires_exhausting_all_three_locations_and_io_errors_stay_io() { | |
| 276 | 추가: for phase in ["create", "space", "write"] { | |
| 277 | 추가: let c = Case::new(); | |
| 278 | 추가: for format in ["zip", "7z"] { | |
| 279 | 추가: let events = c.list(format, phase, 7, false); | |
| 280 | 추가: assert_eq!( | |
| 281 | 추가: terminal(&events).error, | |
| 282 | 추가: ErrorCode::DiskFull, | |
| 283 | 추가: "{phase}: {events:?}" | |
| 284 | 추가: ); | |
| 285 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Failed); | |
| 286 | 추가: assert!(!events.iter().any(|e| matches!(e, Message::ListEnd { .. }))); | |
| 287 | 추가: } | |
| 288 | 추가: let trace = fs::read_to_string(c.scratch.0.join("trace")).unwrap(); | |
| 289 | 추가: for at in ['0', '1', '2'] { | |
| 290 | 추가: assert!(trace.contains(at), "{phase}: {trace}"); | |
| 291 | 추가: } | |
| 292 | 추가: } | |
| 293 | 추가: let c = Case::new(); | |
| 294 | 추가: for phase in ["io", "denied"] { | |
| 295 | 추가: let events = c.list("zip", phase, 7, false); | |
| 296 | 추가: assert_eq!(terminal(&events).error, ErrorCode::Io, "{events:?}"); | |
| 297 | 추가: } | |
| 298 | 추가: } | |
| 299 | 추가: #[test] | |
| 300 | 추가: fn unsafe_cache_is_skipped_without_following_its_link() { | |
| 301 | 추가: use std::os::unix::fs::symlink; | |
| 302 | 추가: let c = Case::new(); | |
| 303 | 추가: fs::DirBuilder::new() | |
| 304 | 추가: .mode(0o700) | |
| 305 | 추가: .create(c.scratch.0.join("outside")) | |
| 306 | 추가: .unwrap(); | |
| 307 | 추가: symlink( | |
| 308 | 추가: c.scratch.0.join("outside"), | |
| 309 | 추가: c.scratch.0.join("cache/zipelo"), | |
| 310 | 추가: ) | |
| 311 | 추가: .unwrap(); | |
| 312 | 추가: let events = c.list("zip", "create", 0, false); | |
| 313 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 314 | 추가: assert_eq!( | |
| 315 | 추가: fs::read_dir(c.scratch.0.join("outside")).unwrap().count(), | |
| 316 | 추가: 0 | |
| 317 | 추가: ); | |
| 318 | 추가: fs::remove_file(c.scratch.0.join("cache/zipelo")).unwrap(); | |
| 319 | 추가: c.clean(); | |
| 320 | 추가: } | |
| 321 | 추가: #[test] | |
| 322 | 추가: fn preview_decode_retries_when_snapshot_fits_but_decoded_staging_does_not() { | |
| 323 | 추가: for named in [false, true] { | |
| 324 | 추가: for phase in ["stage-space", "stage-write"] { | |
| 325 | 추가: for mask in [1, 3] { | |
| 326 | 추가: let c = Case::new(); | |
| 327 | 추가: for format in ["zip", "7z"] { | |
| 328 | 추가: c.assert_preview(format, phase, mask, named); | |
| 329 | 추가: } | |
| 330 | 추가: } | |
| 331 | 추가: let c = Case::new(); | |
| 332 | 추가: for format in ["zip", "7z"] { | |
| 333 | 추가: let events = c.preview(format, phase, 7, named); | |
| 334 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Failed, "{events:?}"); | |
| 335 | 추가: assert_eq!(terminal(&events).error, ErrorCode::DiskFull, "{events:?}"); | |
| 336 | 추가: assert!( | |
| 337 | 추가: !events | |
| 338 | 추가: .iter() | |
| 339 | 추가: .any(|event| matches!(event, Message::PreviewEnd { .. })) | |
| 340 | 추가: ); | |
| 341 | 추가: } | |
| 342 | 추가: } | |
| 343 | 추가: } | |
| 344 | 추가: } | |
| 345 | 추가: | |
| 346 | 추가: #[test] | |
| 347 | 추가: fn default_home_cache_is_created_privately() { | |
| 348 | 추가: let c = Case::new(); | |
| 349 | 추가: c.assert_preview("zip", "home", 0, false); | |
| 350 | 추가: for name in [".cache", ".cache/zipelo"] { | |
| 351 | 추가: assert_eq!( | |
| 352 | 추가: fs::metadata(c.scratch.0.join(name)) | |
| 353 | 추가: .unwrap() | |
| 354 | 추가: .permissions() | |
| 355 | 추가: .mode() | |
| 356 | 추가: & 0o777, | |
| 357 | 추가: 0o700 | |
| 358 | 추가: ); | |
| 359 | 추가: } | |
| 360 | 추가: } | |
| 361 | 추가: | |
| 362 | 추가: #[test] | |
| 363 | 추가: fn source_change_during_failed_copy_prevents_retry_success() { | |
| 364 | 추가: let c = Case::new(); | |
| 365 | 추가: let events = c.list("zip", "changed", 1, false); | |
| 366 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Failed, "{events:?}"); | |
| 367 | 추가: assert_eq!( | |
| 368 | 추가: terminal(&events).error, | |
| 369 | 추가: ErrorCode::SourceChanged, | |
| 370 | 추가: "{events:?}" | |
| 371 | 추가: ); | |
| 372 | 추가: let trace = fs::read_to_string(c.scratch.0.join("trace")).unwrap(); | |
| 373 | 추가: assert!( | |
| 374 | 추가: trace.contains('0') && !trace.contains('1') && !trace.contains('2'), | |
| 375 | 추가: "{trace}" | |
| 376 | 추가: ); | |
| 377 | 추가: } | |
| 378 | 추가: | |
| 379 | 추가: #[test] | |
| 380 | 추가: #[ignore = "별도 VM의 작은 tmpfs 경로를 ZIPELO_SPOOL_REAL_TMP로 지정해야 함"] | |
| 381 | 추가: fn actual_tmpfs_quota_lists_and_previews_large_zip_and_seven_zip() { | |
| 382 | 추가: let path = PathBuf::from(std::env::var_os("ZIPELO_SPOOL_REAL_TMP").unwrap()); | |
| 383 | 추가: let filesystem = Command::new("stat") | |
| 384 | 추가: .args(["-f", "-c", "%T"]) | |
| 385 | 추가: .arg(&path) | |
| 386 | 추가: .output() | |
| 387 | 추가: .unwrap(); | |
| 388 | 추가: assert_eq!( | |
| 389 | 추가: String::from_utf8(filesystem.stdout).unwrap().trim(), | |
| 390 | 추가: "tmpfs" | |
| 391 | 추가: ); | |
| 392 | 추가: let capacity = Command::new("stat") | |
| 393 | 추가: .args(["-f", "-c", "%S %b"]) | |
| 394 | 추가: .arg(&path) | |
| 395 | 추가: .output() | |
| 396 | 추가: .unwrap(); | |
| 397 | 추가: let fields: Vec<u64> = String::from_utf8(capacity.stdout) | |
| 398 | 추가: .unwrap() | |
| 399 | 추가: .split_whitespace() | |
| 400 | 추가: .map(|value| value.parse().unwrap()) | |
| 401 | 추가: .collect(); | |
| 402 | 추가: let bytes = fields[0] * fields[1]; | |
| 403 | 추가: assert!(bytes > 0 && bytes < 16 * 1024 * 1024, "{bytes}"); | |
| 404 | 추가: let probe = path.join("capacity-probe"); | |
| 405 | 추가: let error = fs::write(&probe, vec![0; bytes as usize + 4096]).unwrap_err(); | |
| 406 | 추가: assert_eq!(error.kind(), std::io::ErrorKind::StorageFull); | |
| 407 | 추가: fs::remove_file(probe).unwrap(); | |
| 408 | 추가: let c = Case::new(); | |
| 409 | 추가: for format in ["zip", "7z"] { | |
| 410 | 추가: c.assert_preview(format, "real", 0, false); | |
| 411 | 추가: } | |
| 412 | 추가: assert_eq!(fs::read_dir(path).unwrap().count(), 0); | |
| 413 | 추가: assert_eq!( | |
| 414 | 추가: fs::metadata(c.scratch.0.join("cache/zipelo")) | |
| 415 | 추가: .unwrap() | |
| 416 | 추가: .permissions() | |
| 417 | 추가: .mode() | |
| 418 | 추가: & 0o777, | |
| 419 | 추가: 0o700 | |
| 420 | 추가: ); | |
| 421 | 추가: } |
| @@ -0,0 +1,18 @@ | ||
| 1 | 추가: """시스템 임시 폴더보다 큰 독립 ZIP과 7z 입력을 만듦.""" | |
| 2 | 추가: from pathlib import Path | |
| 3 | 추가: import sys | |
| 4 | 추가: import zipfile | |
| 5 | 추가: | |
| 6 | 추가: from seven_zip_fixtures import archive | |
| 7 | 추가: | |
| 8 | 추가: root = Path(sys.argv[1]) | |
| 9 | 추가: payload = b"spool fallback preview\n" | |
| 10 | 추가: filler = bytes(range(256)) * (16 * 1024 * 1024 // 256) | |
| 11 | 추가: with zipfile.ZipFile( | |
| 12 | 추가: root / "archive" / "input.zip", "w", compression=zipfile.ZIP_STORED | |
| 13 | 추가: ) as target: | |
| 14 | 추가: target.writestr("preview.txt", payload) | |
| 15 | 추가: target.writestr("filler.bin", filler) | |
| 16 | 추가: (root / "archive" / "input.7z").write_bytes( | |
| 17 | 추가: archive([("preview.txt", payload, 0x20), ("filler.bin", filler, 0x20)], method="copy") | |
| 18 | 추가: ) |
| @@ -0,0 +1,136 @@ | ||
| 1 | 추가: #define _GNU_SOURCE | |
| 2 | 추가: #include <dlfcn.h> | |
| 3 | 추가: #include <errno.h> | |
| 4 | 추가: #include <fcntl.h> | |
| 5 | 추가: #include <stdarg.h> | |
| 6 | 추가: #include <stdio.h> | |
| 7 | 추가: #include <stdlib.h> | |
| 8 | 추가: #include <string.h> | |
| 9 | 추가: #include <sys/statvfs.h> | |
| 10 | 추가: #include <unistd.h> | |
| 11 | 추가: | |
| 12 | 추가: static int (*original_openat)(int, const char *, int, ...); | |
| 13 | 추가: static int (*original_open64)(const char *, int, ...); | |
| 14 | 추가: static ssize_t (*original_write)(int, const void *, size_t); | |
| 15 | 추가: static int written[3]; | |
| 16 | 추가: static int snapshot_fd = -1; | |
| 17 | 추가: | |
| 18 | 추가: __attribute__((constructor)) static void initialize(void) { | |
| 19 | 추가: original_openat = dlsym(RTLD_NEXT, "openat"); | |
| 20 | 추가: original_open64 = dlsym(RTLD_NEXT, "open64"); | |
| 21 | 추가: original_write = dlsym(RTLD_NEXT, "write"); | |
| 22 | 추가: } | |
| 23 | 추가: static int location(const char *path) { | |
| 24 | 추가: if (strstr(path, "/cache/")) return 0; | |
| 25 | 추가: if (strstr(path, "/archive/")) return 1; | |
| 26 | 추가: if (strstr(path, "/system/")) return 2; | |
| 27 | 추가: return -1; | |
| 28 | 추가: } | |
| 29 | 추가: static int descriptor(int fd, char *path, size_t size) { | |
| 30 | 추가: char link[64]; | |
| 31 | 추가: path[0] = 0; | |
| 32 | 추가: snprintf(link, sizeof(link), "/proc/self/fd/%d", fd); | |
| 33 | 추가: ssize_t length = readlink(link, path, size - 1); | |
| 34 | 추가: if (length < 0) return -1; | |
| 35 | 추가: path[length] = 0; | |
| 36 | 추가: return location(path); | |
| 37 | 추가: } | |
| 38 | 추가: static int affected(int at) { | |
| 39 | 추가: const char *mask = getenv("ZIPELO_SPOOL_MASK"); | |
| 40 | 추가: return at >= 0 && mask && (atoi(mask) & (1 << at)); | |
| 41 | 추가: } | |
| 42 | 추가: static void trace(int at) { | |
| 43 | 추가: const char *path = getenv("ZIPELO_SPOOL_TRACE"); | |
| 44 | 추가: if (!path || at < 0) return; | |
| 45 | 추가: int fd = original_openat(AT_FDCWD, path, O_CREAT | O_WRONLY | O_APPEND, 0600); | |
| 46 | 추가: if (fd >= 0) { | |
| 47 | 추가: char value = '0' + at; | |
| 48 | 추가: original_write(fd, &value, 1); | |
| 49 | 추가: close(fd); | |
| 50 | 추가: } | |
| 51 | 추가: } | |
| 52 | 추가: static int reject(int at, int flags) { | |
| 53 | 추가: if ((flags & O_TMPFILE) != O_TMPFILE && !(flags & O_CREAT)) return 0; | |
| 54 | 추가: trace(at); | |
| 55 | 추가: const char *phase = getenv("ZIPELO_SPOOL_PHASE"); | |
| 56 | 추가: if (affected(at) && phase && (!strcmp(phase, "create") || !strcmp(phase, "denied"))) { | |
| 57 | 추가: errno = !strcmp(phase, "denied") ? EACCES : EDQUOT; | |
| 58 | 추가: return 1; | |
| 59 | 추가: } | |
| 60 | 추가: if (getenv("ZIPELO_SPOOL_NAMED") && (flags & O_TMPFILE) == O_TMPFILE) { | |
| 61 | 추가: errno = EOPNOTSUPP; | |
| 62 | 추가: return 1; | |
| 63 | 추가: } | |
| 64 | 추가: return 0; | |
| 65 | 추가: } | |
| 66 | 추가: int openat(int fd, const char *path, int flags, ...) { | |
| 67 | 추가: mode_t mode = 0; | |
| 68 | 추가: if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) { | |
| 69 | 추가: va_list args; | |
| 70 | 추가: va_start(args, flags); | |
| 71 | 추가: mode = va_arg(args, unsigned int); | |
| 72 | 추가: va_end(args); | |
| 73 | 추가: } | |
| 74 | 추가: char parent[4096], full[8192]; | |
| 75 | 추가: descriptor(fd, parent, sizeof(parent)); | |
| 76 | 추가: snprintf(full, sizeof(full), "%s/%s", parent, path); | |
| 77 | 추가: if (reject(location(full), flags)) return -1; | |
| 78 | 추가: int result = original_openat(fd, path, flags, mode); | |
| 79 | 추가: if (result >= 0 && snapshot_fd < 0 && location(full) >= 0 | |
| 80 | 추가: && ((flags & O_TMPFILE) == O_TMPFILE || (flags & O_CREAT))) { | |
| 81 | 추가: snapshot_fd = result; | |
| 82 | 추가: } | |
| 83 | 추가: return result; | |
| 84 | 추가: } | |
| 85 | 추가: int open64(const char *path, int flags, ...) { | |
| 86 | 추가: mode_t mode = 0; | |
| 87 | 추가: if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) { | |
| 88 | 추가: va_list args; | |
| 89 | 추가: va_start(args, flags); | |
| 90 | 추가: mode = va_arg(args, unsigned int); | |
| 91 | 추가: va_end(args); | |
| 92 | 추가: } | |
| 93 | 추가: char full[8192]; | |
| 94 | 추가: snprintf(full, sizeof(full), "%s/", path); | |
| 95 | 추가: if (reject(location(full), flags)) return -1; | |
| 96 | 추가: int result = original_open64(path, flags, mode); | |
| 97 | 추가: if (result >= 0 && snapshot_fd < 0 && location(full) >= 0 | |
| 98 | 추가: && ((flags & O_TMPFILE) == O_TMPFILE || (flags & O_CREAT))) { | |
| 99 | 추가: snapshot_fd = result; | |
| 100 | 추가: } | |
| 101 | 추가: return result; | |
| 102 | 추가: } | |
| 103 | 추가: ssize_t write(int fd, const void *bytes, size_t count) { | |
| 104 | 추가: char path[4096]; | |
| 105 | 추가: int at = descriptor(fd, path, sizeof(path)); | |
| 106 | 추가: const char *phase = getenv("ZIPELO_SPOOL_PHASE"); | |
| 107 | 추가: int stage = phase && !strcmp(phase, "stage-write") && fd != snapshot_fd; | |
| 108 | 추가: if (affected(at) && phase && (stage || !strcmp(phase, "write") | |
| 109 | 추가: || !strcmp(phase, "changed") || !strcmp(phase, "io"))) { | |
| 110 | 추가: if (!strcmp(phase, "io")) { errno = EIO; return -1; } | |
| 111 | 추가: if (!written[at]++) return original_write(fd, bytes, count < 7 ? count : 7); | |
| 112 | 추가: if (!strcmp(phase, "changed")) { | |
| 113 | 추가: int source = original_openat(AT_FDCWD, getenv("ZIPELO_SPOOL_SOURCE"), O_WRONLY | O_APPEND); | |
| 114 | 추가: if (source >= 0) { | |
| 115 | 추가: original_write(source, "x", 1); | |
| 116 | 추가: close(source); | |
| 117 | 추가: } | |
| 118 | 추가: } | |
| 119 | 추가: errno = EDQUOT; | |
| 120 | 추가: return -1; | |
| 121 | 추가: } | |
| 122 | 추가: return original_write(fd, bytes, count); | |
| 123 | 추가: } | |
| 124 | 추가: int fstatvfs(int fd, struct statvfs *value) { | |
| 125 | 추가: int (*original)(int, struct statvfs *) = dlsym(RTLD_NEXT, "fstatvfs"); | |
| 126 | 추가: int result = original(fd, value); | |
| 127 | 추가: char path[4096]; | |
| 128 | 추가: int at = descriptor(fd, path, sizeof(path)); | |
| 129 | 추가: const char *phase = getenv("ZIPELO_SPOOL_PHASE"); | |
| 130 | 추가: int stage = phase && !strcmp(phase, "stage-space") && fd != snapshot_fd; | |
| 131 | 추가: if (!result && affected(at) && phase && (stage || !strcmp(phase, "space"))) { | |
| 132 | 추가: value->f_frsize = 1; | |
| 133 | 추가: value->f_bavail = stage ? 0 : 1024; | |
| 134 | 추가: } | |
| 135 | 추가: return result; | |
| 136 | 추가: } |