Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5819
  • 博文数量: 0
  • 博客积分: 97
  • 博客等级: 民兵
  • 技术积分: 12
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-15 11:15
我的朋友
博文列表
标题:
标题 阅读 评论 转发 发布日期
     暂时没有公开的博文,给他留言提醒一下吧。
    
给主人留下些什么吧!~~

yv92002015-01-22 17:30

大神 有时间再帮我看看那个问题  。。

回复  |  举报

ouyangyufu2010-10-13 16:52

/*
* Author:Tinnal <Tinnal.Feng@miartech.com>
*
*
* The source code in this file can be freely used, adapted,
* and redistributed in source or binary form, so long as an
* acknowledgment appears in derived source files.No warranty
* is attached;we cannot take responsibility for errors or
* fitness for use.
*
* Modification:
*      Tinnal  V1.00   2010-10-10      Create the file.
*/

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>

#include <linux/kernel.h>                       /* printk() */
#include <linux/fs.h>                           /* everything... */
#include <linux/namei.h>                                /* path_lookup*/

static char *path = NULL;

module_param(path, charp, 0);

static int __init PathLookup_init(void)
{

        struct nameidata nd;
        void *cookie;

        if(path == NULL)
        {
                printk("PathLookup: Used: insmod PathLookup path=\"<Link file name>\"\n");
                return -1;
        }
        printk("PathLookup: The link file you enter is: %s\n", path);

        if (path_lookup(path, 0, &nd)) {
                printk("PathLookup:  path %s not found!\n", path);
                return -1;
        }

        printk("PathLookup: The real file is %s\n", nd.dentry->d_name.name);

        cookie = nd.dentry->d_inode->i_op->follow_link(nd.dentry, &nd);
        if (!IS_ERR(cookie)) {
                printk("PathLookup: [followlink]:%s\n", nd_get_link(&nd));
                if (nd.dentry->d_inode->i_op->put_link)
                        nd.dentry->d_inode->i_op->put_link(nd.dentry, &nd, cookie);
        }
        path_release(&nd);

        return 0;
}

static void __exit PathLookup_exit(void)
{
}

module_init(PathLookup_init);
module_exit(PathLookup_exit);
MODULE_AUTHOR("Tinnal <tinnal.feng@miartech.com>");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("V1.00");

麻烦一下Tinnal,在测试 得到链接的路径代码,读取/proc进程下的fd下符号链接时,得不到路径,这是为什么,ln 建立却可以

回复  |  举报

大鬼不动2010-10-11 20:51

回复  |  举报
留言热议
请登录后留言。

登录 注册