This augments rpcd to be able to inspect symbolic links, instead of simply 
returning the linked file info.

See also: https://github.com/openwrt/rpcd/pull/9

root@OpenWrt:/# ubus call file stat '{"path":"/etc/os-release"}'
{
        "path": "/etc/os-release",
        "type": "file",
        "size": 528,
        "mode": 33188,
        "atime": 1727094886,
        "mtime": 1727094886,
        "ctime": 1727094886,
        "inode": 1124,
        "uid": 0,
        "gid": 0
}
root@OpenWrt:/# ubus call file lstat '{"path":"/etc/os-release"}'
{
        "path": "/etc/os-release",
        "type": "symlink",
        "size": 21,
        "mode": 41471,
        "atime": 1727094886,
        "mtime": 1727094886,
        "ctime": 1727094886,
        "inode": 219,
        "uid": 0,
        "gid": 0
}
root@OpenWrt:/# ubus call file stat '{"path":"/var"}'
{
        "path": "/var",
        "type": "directory",
        "size": 520,
        "mode": 17407,
        "atime": 1730221560,
        "mtime": 1730221753,
        "ctime": 1730221753,
        "inode": 1,
        "uid": 0,
        "gid": 0
}
root@OpenWrt:/# ubus call file lstat '{"path":"/var"}'
{
        "path": "/var",
        "type": "symlink",
        "size": 3,
        "mode": 41471,
        "atime": 1727094886,
        "mtime": 1727094886,
        "ctime": 1727094886,
        "inode": 1264,
        "uid": 0,
        "gid": 0
}
root@OpenWrt:/# ubus call file stat '{"path":"/bin/ash"}'
{
        "path": "/bin/ash",
        "type": "file",
        "size": 405522,
        "mode": 33261,
        "atime": 1727094886,
        "mtime": 1727094886,
        "ctime": 1727094886,
        "inode": 15,
        "uid": 0,
        "gid": 0
}
root@OpenWrt:/# ubus call file lstat '{"path":"/bin/ash"}'
{
        "path": "/bin/ash",
        "type": "symlink",
        "size": 7,
        "mode": 41471,
        "atime": 1727094886,
        "mtime": 1727094886,
        "ctime": 1727094886,
        "inode": 13,
        "uid": 0,
        "gid": 0
}

Paul Donald (1):
  file: linkstat to get link stat info

 file.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

-- 
2.44.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to