-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle symlinks in path_lookup() #216
Comments
@ryantimwilson is interested in reviving this, so I'm going to summarize and expand on my comments on the last attempt: Before we modify class SymlinkNotCachedError(Exception):
"""Error raised when attempting to read an uncached symbolic link."""
def inode_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 So, we're going to need to pick an initial set of filesystems to implement this for.
Then, we could add these in followup PRs:
Once |
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: