Created
October 18, 2010 23:12
-
-
Save erickt/633265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function task_file_handle_d_path:string (task:long, fd:long) %{ /* pure */ | |
struct task_struct *p = (struct task_struct *)((long)THIS->task); | |
struct files_struct *files; | |
char *page = NULL; | |
rcu_read_lock(); | |
files = kread(&p->files); | |
page = (char *)__get_free_page(GFP_KERNEL); | |
/* TODO: handle !page */ | |
if (page) { | |
struct file *filp = fcheck_files(files, THIS->fd); | |
char *path = NULL; | |
if (filp) { | |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) | |
/* git commit 9d1bc601 */ | |
path = d_path(&filp->f_path, page, PAGE_SIZE); | |
#else | |
{ | |
struct dentry *dentry = kread(&filp->f_dentry); | |
struct vfsmount *vfsmnt = kread(&filp->f_vfsmnt); | |
if (dentry && vfsmnt) { | |
path = d_path(dentry, vfsmnt, page, PAGE_SIZE); | |
} | |
} | |
#endif | |
if (path && !IS_ERR(path)) { | |
snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", path); | |
} | |
} | |
} | |
CATCH_DEREF_FAULT(); | |
if (page) free_page((unsigned long)page); | |
rcu_read_unlock(); | |
%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment