路径查找

2017-01-25  本文已影响22人  eesly_yuan

int kern_path(const char *name, unsigned int flags, struct path *path)
int fastcall path_lookup(const char *path, unsigned flags, struct nameidata *nd)
int user_path_at(int dfd, const char __user *name, unsigned flags, struct path *path)

/**
 * path_put - put a reference to a path
 * @path: path to put the reference to
 *
 * Given a path decrement the reference count to the dentry and the vfsmount.
 */
void path_put(const struct path *path)
{
        dput(path->dentry);
        mntput(path->mnt);
}

or

void path_release(struct nameidata *nd)
{
        dput(nd->dentry);
        mntput(nd->mnt);
}

get_user_pages()
作用:获取用户区进程使用内存的某个页(struct page),然后在内核区通过 kmap()等函数映射到内核区线性地址,从而可以在内核区向其写入数据。对于获取的page记得put_page()。

int get_user_pages(struct task_struct \*tsk, 
  struct mm_struct \*mm, 
  unsigned long start, 
  int len, 
  int write, 
  int force, 
  struct page \*\*pages, 
  struct vm_area_struct \*\*vmas);
其中
tsk :指定进程
mm : 进程的内存占用结构,如current->mm,
start :要获取其页面的起始线性地址
len :要获取的页数
write :是否要对该页进行写入
force :待查
pages :存放获取的struct page的指针数组
vms : 返回各个页对应的struct vm_area_struct,可以传入NULL表示不获取
返回值:数返回实际获取的页数
上一篇 下一篇

猜你喜欢

热点阅读