Skip to content

Commit 4e29ee5

Browse files
authored
Merge pull request #19 from desultory/dev
properly handle reading rdevmaj/minor from files
2 parents 9f0146b + d1c1f2a commit 4e29ee5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/pycpio/cpio/data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23

34
from pycpio.masks import mode_bytes_from_path
@@ -110,6 +111,9 @@ def from_path(path: Path, relative=False, resolve_symlink=False, *args, **kwargs
110111
except FileNotFoundError:
111112
kwargs[stat] = 0 # If the symlink target doesn't exist, set the stat to 0
112113

114+
kwargs["rdevmajor"] = kwargs.pop("rdevmajor", os.major(path.stat(follow_symlinks=resolve_symlink).st_rdev))
115+
kwargs["rdevminor"] = kwargs.pop("rdevminor", os.minor(path.stat(follow_symlinks=resolve_symlink).st_rdev))
116+
113117
header = CPIOHeader(*args, **kwargs)
114118
data = CPIOData.get_subtype(b"", header, *args, **kwargs)
115119

0 commit comments

Comments
 (0)