You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose that we're looking up /foo/bar/baz, and bar is a symlink to a different directory. Currently, path_lookup() fails because it does not have any logic to follow symlinks. Let's add a follow_symlinks=False kwarg and add that logic in without breaking backward compatibility.
(this is just a reminder to myself to do this, I hope to send a pull request shortly)
The text was updated successfully, but these errors were encountered:
@ryantimwilson is interested in reviving this, so I'm going to summarize and expand on my comments on the last attempt:
Before we modify path_lookup() itself, we're going to need a new helper in drgn/helpers/linux/fs.py along these lines:
classSymlinkNotCachedError(Exception):
"""Error raised when attempting to read an uncached symbolic link."""definode_readlink(inode: Object) ->bytes:
""" Return the target of a symbolic link. >>> inode = path_lookup("/bin").dentry.d_inode >>> inode_readlink(inode) b'usr/bin' :param inode: ``struct inode *`` :return: Link target :raises ValueError: if *inode* is not a symbolic link :raises SymlinkNotCachedError: if the link target is not cached :raises NotImplementedError: if reading symbolic links is not yet implemented for the filesystem containing *inode* """
...
Basically, when the target of a symlink inode is requested in the kernel, the filesystem reads it from the disk/network/etc. and usually caches it somewhere. drgn can obviously only read it if it is cached. The tricky thing is that filesystems cache it differently. See vfs_readlink() in the kernel, which calls the filesystem's ->get_link() callback.
So, we're going to need to pick an initial set of filesystems to implement this for. inode_readlink() can check the ->get_link() callback to figure out how to proceed . E.g., if inode.i_op.get_link == prog["page_get_link"]: ... emulate page_get_link .... For the initial PR, I'd suggest starting with one or both of these:
ext4: three possibilities depending on the filesystem configuration. I'd pretend that the encrypted option doesn't exist for now and only handle the other two.
Once inode_readlink() is implemented for a couple of filesystems, the next step is to use it in path_lookup(). My comment on the previous attempt has some thoughts on how to go about that.
Suppose that we're looking up
/foo/bar/baz
, andbar
is a symlink to a different directory. Currently,path_lookup()
fails because it does not have any logic to follow symlinks. Let's add afollow_symlinks=False
kwarg and add that logic in without breaking backward compatibility.(this is just a reminder to myself to do this, I hope to send a pull request shortly)
The text was updated successfully, but these errors were encountered: