Skip to content

Commit bc42d89

Browse files
committed
Return information about file systems
1 parent 6c53b3b commit bc42d89

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ $ reolinkfw info RLC-410-5MP_20_20052300.zip -i 2
7474
"detail_machine_type": "IPC_51516M5M",
7575
"type": "IPC",
7676
"version_file": "20_20052300",
77+
"filesystems": [
78+
{
79+
"name": "fs",
80+
"type": "squashfs"
81+
}
82+
],
7783
"sha256": "6ef371a51b61d7b21d8f7016d90b5fc1ed3eaa8a3f30f1e202a3474bfb4807e5",
7884
"file": "RLC-410-5MP_20_20052300.zip",
7985
"pak": "IPC_51516M5M.20_20052300.RLC-410-5MP.OV05A10.5MP.REOLINK.pak"

reolinkfw/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import aiohttp
1212
from lxml.etree import fromstring
1313
from lxml.html import document_fromstring
14-
from pakler import PAK, is_pak_file
14+
from pakler import PAK, Section, is_pak_file
1515
from pycramfs import Cramfs
1616
from pycramfs.const import MAGIC_BYTES as CRAMFS_MAGIC
1717
from PySquashfsImage import SquashFsImage
@@ -146,6 +146,18 @@ def is_local_file(string):
146146
return Path(string).is_file()
147147

148148

149+
def get_fs_info(pak: PAK, fs_sections: list[Section]) -> list[dict[str, str]]:
150+
result = []
151+
for section in fs_sections:
152+
pak._fd.seek(section.start)
153+
fs = FileSystem.from_magic(pak._fd.read(4))
154+
result.append({
155+
"name": section.name,
156+
"type": fs.name.lower() if fs is not None else "unknown"
157+
})
158+
return result
159+
160+
149161
async def get_info_from_pak(pak: PAK):
150162
ha = await asyncio.to_thread(sha256_pak, pak)
151163
fs_sections = [s for s in pak.sections if s.name in FS_SECTIONS]
@@ -161,7 +173,7 @@ async def get_info_from_pak(pak: PAK):
161173
else:
162174
return {"error": "Unrecognized image type", "sha256": ha}
163175
info = get_info_from_files(files)
164-
return {**info, "sha256": ha}
176+
return {**info, "filesystems": get_fs_info(pak, fs_sections), "sha256": ha}
165177

166178

167179
async def direct_download_url(url):

0 commit comments

Comments
 (0)