file: append "target" for symbolic links
When list encounters a symbolic link, we add its nested "target" entry, to where
the symbolic link points. Just how `ls -l` reports.
So when calling e.g.: ubus call file list '{"path":"/etc"}'
instead of:
...
"name": "os-release",
"type": "symlink",
"size": 21,
"mode": 41471,
"atime":
1760891865,
"mtime":
1760891865,
"ctime":
1760891865,
"inode": 266,
"uid": 0,
"gid": 0,
"target_type": "file"
...
We get:
...
"name": "os-release",
"type": "symlink",
"size": 21,
"mode": 41471,
"atime":
1760891865,
"mtime":
1760891865,
"ctime":
1760891865,
"inode": 266,
"uid": 0,
"gid": 0,
"target": {
"name": "../usr/lib/os-release",
"type": "file",
"size": 582,
"mode": 33188,
"atime":
1760891865,
"mtime":
1760891865,
"ctime":
1760891865,
"inode": 1744,
"uid": 0,
"gid": 0
}
...
And should a link be broken:
"name": "foo",
"type": "symlink",
"size": 8,
"mode": 41471,
"atime":
1762640365,
"mtime":
1762640365,
"ctime":
1762640365,
"inode": 348,
"uid": 0,
"gid": 0,
"target": {
"name": "/tmp/foo",
"type": "broken"
}
Tested on: OpenWrt 24.10.4 r28959-
29397011cc
Signed-off-by: Paul Donald <[email protected]>
Tested-by: Eric Fahlgren <[email protected]>
Link: https://github.com/openwrt/rpcd/pull/21
Signed-off-by: Robert Marko <[email protected]>