tags:

views:

36

answers:

1

In Linux v0.11 task_struct had an executable member of type m_inode *. I am looking for something similar.

Does the exec/execve system call store this information anywhere or is it lost upon loading into memory?

+1  A: 

There's no direct link like that anymore. The proc_exe_link() function gets this information by looking for the first executable vma in the task that is mapping a file. You would do that for current with something like:

struct dentry *dentry = NULL;
struct vfsmount *mnt = NULL;
struct vm_area_struct * vma;

down_read(&current->mm->mmap_sem);

vma = current->mm->mmap;
while (vma) {
    if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file)
        break;
    vma = vma->vm_next;
}

if (vma) {
    mnt = mntget(vma->vm_file->f_path.mnt);
    dentry = dget(vma->vm_file->f_path.dentry);
}

up_read(&current->mm->mmap_sem);

if (dentry) {
    /* inode is dentry->d_inode */
}
caf