When using Python functions os.path.realpath() or pathlib.Path.resolve(strict=True) on a drive created by OSFMount, the operation fails with OSError: [WinError 1] Incorrect function. This error does not occur on standard physical NTFS drives.
This issue is critical for modern Python applications and web servers (e.g., ComfyUI, aiohttp) that rely on these functions to resolve canonical file paths.
Steps to Reproduce:
Expected Result:
Both functions should return the canonical path without errors on all drives.
Actual Result:
On the OSFMount RAM disk (R:), both functions fail with:
OSError: [WinError 1] Incorrect function: 'R:\\test_folder'
On a local physical NTFS drive (D:), both functions succeed.
Environment Information:
The underlying Windows API function GetFinalPathNameByHandleW appears to return the error ERROR_INVALID_FUNCTION (1) when called on files located on the OSFMount virtual drive. This breaks standard library functionality in Python and likely affects other applications that rely on this system call.
This issue blocks the operation of several modern software packages. A fix or workaround guidance would be greatly appreciated.
This issue is critical for modern Python applications and web servers (e.g., ComfyUI, aiohttp) that rely on these functions to resolve canonical file paths.
Steps to Reproduce:
- Create a RAM disk (NTFS) using OSFMount (e.g., drive R:)
- Save and run the following Python test script
- Observe the output
Code:
import os
import pathlib
def test_realpath_on_drive(drive_letter: str):
test_dir = f"{drive_letter}:\\test_osfmount_{os.getpid()}"
os.makedirs(test_dir, exist_ok=True)
dir_exists = os.path.exists(test_dir) and os.path.isdir(test_dir)
print(f"Testing on {drive_letter}:\\")
print(f" Directory exists: {dir_exists} ({test_dir})")
try:
result = pathlib.Path(test_dir).resolve(strict=True)
print(f" pathlib.Path.resolve(strict=True): SUCCESS -> {result}")
except OSError as e:
print(f" pathlib.Path.resolve(strict=True): FAILED -> {e}")
try:
result = os.path.realpath(test_dir, strict=True)
print(f" os.path.realpath(strict=True): SUCCESS -> {result}")
except OSError as e:
print(f" os.path.realpath(strict=True): FAILED -> {e}")
os.rmdir(test_dir)
print()
print("Python version:", os.sys.version)
print("\nTesting realpath behavior:\n")
test_realpath_on_drive("R")
test_realpath_on_drive("D")
Expected Result:
Both functions should return the canonical path without errors on all drives.
Actual Result:
On the OSFMount RAM disk (R:), both functions fail with:
OSError: [WinError 1] Incorrect function: 'R:\\test_folder'
On a local physical NTFS drive (D:), both functions succeed.
Environment Information:
- OSFMount Version: 3.1.1003.0
- OS: Windows 10/11
- Python Version: 3.12.10, 3.9.11
- RAM Disk Configuration: Type: RAM Disk, File System: NTFS
The underlying Windows API function GetFinalPathNameByHandleW appears to return the error ERROR_INVALID_FUNCTION (1) when called on files located on the OSFMount virtual drive. This breaks standard library functionality in Python and likely affects other applications that rely on this system call.
This issue blocks the operation of several modern software packages. A fix or workaround guidance would be greatly appreciated.

Comment