{"record":{"id":"a6c6c36127a077d0","repo":"rustfs/rustfs","slug":"cannot-safely-reopen-the-publication-root-for-path","errorCode":null,"errorMessage":"cannot safely reopen the publication root for pathname access","messagePattern":"cannot safely reopen the publication root for pathname access","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/ecstore/src/disk/os.rs","lineNumber":2843,"sourceCode":"            use windows_sys::Win32::Storage::FileSystem::{FILE_SHARE_READ, FILE_SHARE_WRITE};\n\n            let relative = directory.strip_prefix(&self.destination_parent).map_err(|_| {\n                io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"guarded path must remain below the rename destination parent\",\n                )\n            })?;\n            for component in relative.components() {\n                if !matches!(component, Component::Normal(_) | Component::CurDir) {\n                    return Err(io::Error::new(\n                        io::ErrorKind::InvalidInput,\n                        \"guarded destination path contains an invalid component\",\n                    ));\n                }\n            }\n\n            let component = self.destination_parent.file_name().ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::PermissionDenied,\n                    \"cannot safely reopen the publication root for pathname access\",\n                )\n            })?;\n            let parent_index = self.destination_parent_guard.handles.len().checked_sub(2).ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::PermissionDenied,\n                    \"cannot safely reopen the publication root for pathname access\",\n                )\n            })?;\n            let mut handles = self.destination_parent_guard.handles[..=parent_index].to_vec();\n            let parent = handles\n                .last()\n                .ok_or_else(|| io::Error::other(\"Windows destination guard lost its parent handle\"))?;\n            let mut relative_components = relative\n                .components()\n                .filter_map(|component| match component {\n                    Component::Normal(component) => Some(component),","sourceCodeStart":2825,"sourceCodeEnd":2861,"githubUrl":"https://github.com/rustfs/rustfs/blob/201c653dcd34c2a01b9aec5991ed76176b342118/crates/ecstore/src/disk/os.rs#L2825-L2861","documentation":"Reopening the publication root for pathname access needs the last segment of destination_parent to open it relative to its own parent. If destination_parent is a filesystem root (C:\\ or a UNC share root), file_name() returns None, the reopen is impossible, and the guard fails closed with PermissionDenied rather than falling back to unguarded pathname access.","triggerScenarios":"The storage/data directory is configured at the root of a volume, e.g. E:\\ or \\\\server\\share, leaving no named segment for the handle-relative reopen.","commonSituations":"Quick test setups pointing at a bare drive; misformatted config such as path: \"C:\\\"; automation mounting a volume and using its root directly as the pool path.","solutions":["Configure the storage path as a named subdirectory of the volume, e.g. E:\\rustfs-data instead of E:\\","Validate at startup that the configured data path has a file name and fail configuration early with a clear message"],"exampleFix":"# before\npath: \"E:\\\"\n\n# after\npath: \"E:\\rustfs-data\"","handlingStrategy":"validation","validationCode":"let data_dir = load_config().data_dir;\nif data_dir.file_name().is_none() {\n    return Err(config_error(\"storage path must be a named directory, not a volume root\"));\n}","typeGuard":"fn has_file_name(p: &Path) -> bool { p.file_name().is_some() }","tryCatchPattern":"Err(e) if e.kind() == io::ErrorKind::PermissionDenied && e.to_string().contains(\"publication root for pathname access\") => reconfigure the data path to a named subdirectory; restart required","preventionTips":["Never configure storage at a bare drive root","Validate the configured path shape at startup","Use dedicated subdirectories per storage pool"],"tags":["windows","path-validation","config","filesystem-root"],"backgroundTag":"filesystem-root-path","analyzedSha":"201c653dcd34c2a01b9aec5991ed76176b342118","analyzedAt":"2026-08-20T21:57:04.799Z","contentChangedAt":"2026-08-20T21:57:04.799Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}