erofs-utils: lib: add API to get pathname of EROFS inode

Igor Eisberg igoreisberg at gmail.com
Sat Dec 18 03:47:44 AEDT 2021


For reference, description of how this method works:
The target inode's nid is saved in a custom context that's used for the
rest of the path search. Buffer offset (pos) is set to 0.
The function starts a recursive traversal from the root node, always
altering the offset in the buffer for the next inode in path (without
writing yet).
Recursion continues until the target nid is reached, then:
1. The inode's name is written to the buffer at the last remembered offset,
in the form of: '/' + <inode name> + NUL
2. A custom return code EROFS_PATHNAME_FOUND is returned which causes the
whole recursion to stop
3. Parent inode writes the node's name in the form: '/' + <dir inode name>,
then also returns EROFS_PATHNAME_FOUND.
This is repeated per recursion level, until the first callback has returned.
Demo of the buffer changes (? = undefined data in the buffer, $ = null byte
that marks end-of-string):

?????????????????????????????????????????????????? (initial buffer)
?????????????????????????????/firmware$??????????? (target inode found,
write and break recursion)
??????????????????????/vendor/firmware$??????????? (1st parent dir inode)
?????????????/readonly/vendor/firmware$??????????? (2nd parent dir inode)
????????/adsp/readonly/vendor/firmware$??????????? (3rd parent dir inode)
????/mdm/adsp/readonly/vendor/firmware$??????????? (4th parent dir inode)
/rfs/mdm/adsp/readonly/vendor/firmware$??????????? (last parent dir inode,
function returns)

On Fri, 17 Dec 2021 at 16:20, Igor Eisberg <igoreisberg at gmail.com> wrote:

>
>
> On Fri, 17 Dec 2021 at 14:30, Igor Eisberg <igoreisberg at gmail.com> wrote:
>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20211217/70622050/attachment.htm>


More information about the Linux-erofs mailing list