sebaubuntu-python/aospdtgen

Handling symbolic links as a file?

Opened this issue · 3 comments

Android device tree generator
Version 0.1.0

[INFO] Figuring out partitions scheme
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/someone5678/android/dump/aospdtgen/aospdtgen/__main__.py", line 11, in <module>
    main()
  File "/home/someone5678/android/dump/aospdtgen/aospdtgen/main.py", line 31, in main
    dump = DeviceTree(args.dump_path)
  File "/home/someone5678/android/dump/aospdtgen/aospdtgen/device_tree.py", line 36, in __init__
    self.partitions = Partitions(self.path)
  File "/home/someone5678/.local/lib/python3.10/site-packages/sebaubuntu_libs/libandroid/partitions/partitions.py", line 25, in __init__
    self.partitions[PartitionModel.SYSTEM] = AndroidPartition(PartitionModel.SYSTEM, system)
  File "/home/someone5678/.local/lib/python3.10/site-packages/sebaubuntu_libs/libandroid/partitions/partition.py", line 38, in __init__
    self.files = get_files_list(self.path)
  File "/home/someone5678/.local/lib/python3.10/site-packages/sebaubuntu_libs/libandroid/partitions/partition.py", line 29, in get_files_list
    files.extend(get_files_list(i))
  File "/home/someone5678/.local/lib/python3.10/site-packages/sebaubuntu_libs/libandroid/partitions/partition.py", line 29, in get_files_list
    files.extend(get_files_list(i))
  File "/home/someone5678/.local/lib/python3.10/site-packages/sebaubuntu_libs/libandroid/partitions/partition.py", line 25, in get_files_list
    for i in path.iterdir():
  File "/usr/lib/python3.10/pathlib.py", line 1017, in iterdir
    for name in self._accessor.listdir(self):
FileNotFoundError: [Errno 2] No such file or directory: '../dumpyara/working/miui_MONDRIAN_V14.0.23.2.13.DEV_16aad31db7_13.0/system/system/lib/libc.so'

As I found, currently, aospdtgen following all symbolic links instead of just handling it as a file.
To workaround for above issue I should delete all symlink files by running command
find . -type l -delete .
After that I can finally generate dt.

If they're broken symlinks erroring out is fine imho, let me know if they're valid symlinks

If they're broken symlinks erroring out is fine imho, let me know if they're valid symlinks

Oh yes. As I checked, they are all valid symlinks.

I'm sure libc.so is a broken symlink since it usually points to /apex on a real device, not sure how I can just let pathlib ignore broken symlinks