Skip to content

Commit 5b223d8

Browse files
authored
feature: add nlink support for jffs stat (#1064)
1 parent 12306a3 commit 5b223d8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

dissect/target/filesystems/jffs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def lstat(self) -> fsutil.stat_result:
109109
self.entry.mode,
110110
self.entry.inum,
111111
id(self.fs),
112-
1, # TODO: properly calculate nlink in dissect.jffs
112+
self.entry.nlink,
113113
node.uid,
114114
node.gid,
115115
node.isize,

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ full = [
5757
"dissect.fat>=3,<4",
5858
"dissect.ffs>=3,<4",
5959
"dissect.fve>=4,<5; platform_system != 'Windows' or platform_python_implementation != 'PyPy'",
60-
"dissect.jffs>=1,<2",
60+
"dissect.jffs>=1.5.dev,<2", # TODO: update on release
6161
"dissect.ole>=3,<4",
6262
"dissect.shellitem>=3,<4",
6363
"dissect.squashfs>=1,<2",
@@ -95,7 +95,7 @@ dev = [
9595
"dissect.ffs[dev]>=3.0.dev,<4.0.dev",
9696
"dissect.fve[dev]>=4.0.dev,<5.0.dev; platform_system != 'Windows' or platform_python_implementation != 'PyPy'",
9797
"dissect.hypervisor[dev]>=3.0.dev,<4.0.dev",
98-
"dissect.jffs[dev]>=1.0.dev,<2.0.dev",
98+
"dissect.jffs[dev]>=1.5.dev,<2.0.dev",
9999
"dissect.ntfs[dev]>=3.4.dev,<4.0.dev",
100100
"dissect.regf[dev]>=3.3.dev,<4.0.dev",
101101
"dissect.shellitem[dev]>=3.0.dev,<4.0.dev",

tests/filesystems/test_jffs2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def jffs_fs_file_entry(jffs_fs: JFFSFilesystem) -> Iterator[JFFSFilesystemEntry]
2020
inode = Mock(
2121
mode=0o100664,
2222
inum=4,
23+
nlink=1,
2324
inode=raw_inode,
2425
atime=datetime(2024, 10, 1, 12, 0, 0),
2526
mtime=datetime(2024, 10, 2, 12, 0, 0),
@@ -39,6 +40,7 @@ def jffs_fs_directory_entry(jffs_fs: JFFSFilesystem) -> Iterator[JFFSFilesystemE
3940
inode = Mock(
4041
mode=0o40775,
4142
inum=2,
43+
nlink=2,
4244
inode=raw_inode,
4345
atime=datetime(2024, 10, 1, 12, 0, 0),
4446
mtime=datetime(2024, 10, 2, 12, 0, 0),
@@ -63,7 +65,7 @@ def test_jffs2_stat(entry_fixture: str, expected_blocks: int, request: pytest.Fi
6365
assert stat.st_mode == entry.mode
6466
assert stat.st_ino == entry.inum
6567
assert stat.st_dev == id(jffs_entry.fs)
66-
assert stat.st_nlink == 1
68+
assert stat.st_nlink == entry.nlink
6769
assert stat.st_uid == entry.inode.uid
6870
assert stat.st_gid == entry.inode.gid
6971
assert stat.st_size == entry.inode.isize

0 commit comments

Comments
 (0)