char *tmp;
char *pathname;

path_get(&file->f_path);

tmp = (char *)__get_free_page(GFP_TEMPORARY);
if (!tmp) {
    return -ENOMEM;
}

pathname = d_path(&file->f_path, tmp, PAGE_SIZE);
path_put(&file->f_path);

if (IS_ERR(pathname)) {
    free_page((unsigned long)tmp);
    return PTR_ERR(pathname);
}

printk(KERN_WARNING "File name: %s\n", pathname);
free_page((unsigned long)tmp);

相关文章:

  • 2022-02-16
  • 2022-12-23
  • 2022-02-24
  • 2021-08-12
  • 2021-07-13
  • 2021-12-14
  • 2022-01-12
  • 2021-10-10
猜你喜欢
  • 2021-06-10
  • 2021-07-22
  • 2021-07-17
  • 2022-12-23
  • 2021-06-28
  • 2021-09-04
  • 2022-12-23
相关资源
相似解决方案