当前位置: 首页>>代码示例>>C++>>正文


C++ d_path函数代码示例

本文整理汇总了C++中d_path函数的典型用法代码示例。如果您正苦于以下问题:C++ d_path函数的具体用法?C++ d_path怎么用?C++ d_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了d_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: osi_abspath

int osi_abspath(char *aname, char *buf, int buflen,
		int followlink, char **pathp)
{
    struct dentry *dp = NULL;
    struct vfsmount *mnt = NULL;
    char *name, *path;
    int code;

    name = afs_getname(aname);
    if (IS_ERR(name))
	return -PTR_ERR(name);
    code = osi_lookupname_internal(name, followlink, &mnt, &dp);
    if (!code) {
#if defined(D_PATH_TAKES_STRUCT_PATH)
	afs_linux_path_t p = { mnt, dp };
	path = d_path(&p, buf, buflen);
#else
	path = d_path(dp, mnt, buf, buflen);
#endif

	if (IS_ERR(path)) {
	    code = -PTR_ERR(path);
	} else {
	    *pathp = path;
	}

	dput(dp);
	mntput(mnt);
    }

    afs_putname(name);
    return code;
}
开发者ID:bagdxk,项目名称:openafs,代码行数:33,代码来源:osi_misc.c

示例2: AuTraceEnter

static char *au_build_path(struct dentry *h_parent, struct path *h_rootpath,
			   char *buf, int len, struct super_block *sb)
{
	char *p;
	int n;

	AuTraceEnter();

	p = d_path(h_rootpath->dentry, h_rootpath->mnt, buf, len);
	if (IS_ERR(p))
		goto out;
	n = strlen(p);

	p = d_path(h_parent, h_rootpath->mnt, buf, len);
	if (IS_ERR(p))
		goto out;
	LKTRTrace("%s\n", p);
	if (n != 1)
		p += n;
	LKTRTrace("%p, %s, %ld\n",
		  p, p, (long)(p - buf));

	p = d_path(sb->s_root, au_sbi(sb)->si_mnt, buf, len - strlen(p));
	if (IS_ERR(p))
		goto out;
	if (n != 1)
		p[strlen(p)] = '/';
	LKTRTrace("%s\n", p);

 out:
	AuTraceErrPtr(p);
	return p;
}
开发者ID:wosigh,项目名称:patches,代码行数:33,代码来源:export.c

示例3: cr_getpath

/* Caller is responsible for path_get()/path_put() */
static char *
cr_getpath(struct path *path, char *buf, int size)
{
    char *name = NULL;

    if (path->dentry == NULL) {
        CR_WARN("path->dentry is NULL!");
	goto out;
    }
    if (path->mnt == NULL) {
        CR_WARN("path->vfsmnt is NULL!");
	goto out;
    }

#if HAVE_NAMEIDATA_DENTRY
    name = d_path(path->dentry, path->mnt, buf, size);
#elif HAVE_NAMEIDATA_PATH
    name = d_path(path, buf, size);
#else
    #error
#endif

out:
    return name;
}
开发者ID:AvengerMoJo,项目名称:apc-8750,代码行数:26,代码来源:cr_io.c

示例4: d_path

static char *au_build_path(struct dentry *h_parent, struct path *h_rootpath,
			   char *buf, int len, struct super_block *sb)
{
	char *p;
	int n;
	struct path path;

	p = d_path(h_rootpath, buf, len);
	if (IS_ERR(p))
		goto out;
	n = strlen(p);

	path.mnt = h_rootpath->mnt;
	path.dentry = h_parent;
	p = d_path(&path, buf, len);
	if (IS_ERR(p))
		goto out;
	if (n != 1)
		p += n;

	path.mnt = au_mnt_get(sb);
	path.dentry = sb->s_root;
	p = d_path(&path, buf, len - strlen(p));
	mntput(path.mnt);
	if (IS_ERR(p))
		goto out;
	if (n != 1)
		p[strlen(p)] = '/';

 out:
	AuTraceErrPtr(p);
	return p;
}
开发者ID:roalex,项目名称:bravo-kernel,代码行数:33,代码来源:export.c

示例5: f_covering_path

char *file_path(struct file *filp, char *buf, int buflen)
{
	struct path path;

	f_covering_path(filp, &path);
	return d_path(&path, buf, buflen);
}
开发者ID:akuster,项目名称:linux-meson,代码行数:7,代码来源:open.c

示例6: ltt_enumerate_task_fd

static inline void
ltt_enumerate_task_fd(struct ltt_probe_private_data *call_data,
		struct task_struct *t, char *tmp)
{
	struct fdtable *fdt;
	struct file *filp;
	unsigned int i;
	const unsigned char *path;

	if (!t->files)
		return;

	spin_lock(&t->files->file_lock);
	fdt = files_fdtable(t->files);
	for (i = 0; i < fdt->max_fds; i++) {
		filp = fcheck_files(t->files, i);
		if (!filp)
			continue;
		path = d_path(filp->f_dentry,
				filp->f_vfsmnt, tmp, PAGE_SIZE);
		/* Make sure we give at least some info */
		__trace_mark(0, list_file_descriptor, call_data,
			"filename %s pid %d fd %u",
			(IS_ERR(path))?(filp->f_dentry->d_name.name):(path),
			t->pid, i);
	}
	spin_unlock(&t->files->file_lock);
}
开发者ID:amalrajt,项目名称:linux-sh4-2.6.23.17_stm23_A18B,代码行数:28,代码来源:ltt-statedump.c

示例7: tpe_file_mmap

static int tpe_file_mmap(struct file *file, unsigned long reqprot,
			unsigned long prot,
			unsigned long flags,
			unsigned long addr,
			unsigned long addr_only)
#endif
{
	int retval;
	char *fptmp, *exepath;

	if((unlikely(current->uid == 0)) || (unlikely(reqprot != PROT_EXEC)) || (unlikely(file == NULL)))
		return 0;
	
	retval = tpe_acl_check(file, 1);
	if(retval) {
		fptmp = (char*)__get_free_page(GFP_KERNEL);
		if(unlikely(fptmp == NULL))
			return -ENOMEM;

		exepath = d_path(file->f_dentry, file->f_vfsmnt, fptmp, PAGE_SIZE);
		TPE_INFO("Denied mmap of %s by uid: %d gid: %d pid: %d", exepath, current->uid, current->gid, current->pid);

		free_page((unsigned long)fptmp);
	}

	return retval;
}
开发者ID:abhisek,项目名称:eos-india,代码行数:27,代码来源:tpe.c

示例8: zfsctl_snapshot_zpath

static int
zfsctl_snapshot_zpath(struct path *path, int len, char *zpath)
{
	char *path_buffer, *path_ptr;
	int path_len, error = 0;

	path_buffer = kmem_alloc(len, KM_SLEEP);

	path_ptr = d_path(path, path_buffer, len);
	if (IS_ERR(path_ptr)) {
		error = -PTR_ERR(path_ptr);
		goto out;
	}

	path_len = path_buffer + len - 1 - path_ptr;
	if (path_len > len) {
		error = EFAULT;
		goto out;
	}

	memcpy(zpath, path_ptr, path_len);
	zpath[path_len] = '\0';
out:
	kmem_free(path_buffer, len);

	return (error);
}
开发者ID:EW1,项目名称:zfs,代码行数:27,代码来源:zfs_ctldir.c

示例9: ltt_enumerate_task_fd

static inline void ltt_enumerate_task_fd(struct task_struct *t,
		char *tmp)
{
	struct fdtable *fdt;
	struct file * filp;
	unsigned int i;
	char *path;

	if (!t->files)
		return;

	spin_lock(&t->files->file_lock);
	fdt = files_fdtable(t->files);
	for (i = 0; i < fdt->max_fds; i++) {
		filp = fcheck_files(t->files, i);
		if (!filp)
			continue;
		path = d_path(filp->f_dentry,
				filp->f_vfsmnt, tmp, PAGE_SIZE);
		/* Make sure we give at least some info */
		if (IS_ERR(path))
			trace_statedump_enumerate_file_descriptors(
				filp->f_dentry->d_name.name, t->pid, i);
		else
			trace_statedump_enumerate_file_descriptors(
					path, t->pid, i);
	}
	spin_unlock(&t->files->file_lock);
}
开发者ID:jameshilliard,项目名称:20-4-4,代码行数:29,代码来源:ltt-statedump.c

示例10: cn_print_exe_file

static int cn_print_exe_file(struct core_name *cn)
{
    struct file *exe_file;
    char *pathbuf, *path;
    int ret;

    exe_file = get_mm_exe_file(current->mm);
    if (!exe_file)
        return cn_esc_printf(cn, "%s (path unknown)", current->comm);

    pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY);
    if (!pathbuf) {
        ret = -ENOMEM;
        goto put_exe_file;
    }

    path = d_path(&exe_file->f_path, pathbuf, PATH_MAX);
    if (IS_ERR(path)) {
        ret = PTR_ERR(path);
        goto free_buf;
    }

    ret = cn_esc_printf(cn, "%s", path);

free_buf:
    kfree(pathbuf);
put_exe_file:
    fput(exe_file);
    return ret;
}
开发者ID:borkmann,项目名称:kasan,代码行数:30,代码来源:coredump.c

示例11: do_fsync

static int do_fsync(unsigned int fd, int datasync)
{
	struct file *file;
	int ret = -EBADF;
	ktime_t fsync_t, fsync_diff;
	char pathname[256], *path;

	file = fget(fd);
	if (file) {
		path = d_path(&(file->f_path), pathname, sizeof(pathname));
		if (IS_ERR(path))
			path = "(unknown)";
		fsync_t = ktime_get();
		ret = vfs_fsync(file, datasync);
		fput(file);

		fsync_diff = ktime_sub(ktime_get(), fsync_t);
		if (ktime_to_ms(fsync_diff) >= 5000) {
			pr_info("VFS: %s pid:%d(%s)(parent:%d/%s) takes %lld ms to fsync %s.\n", __func__,
				current->pid, current->comm, current->parent->pid, current->parent->comm,
				ktime_to_ms(fsync_diff), path);
		}
	}

	return ret;
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:26,代码来源:sync.c

示例12: ext4_file_open

static int ext4_file_open(struct inode * inode, struct file * filp)
{
	struct super_block *sb = inode->i_sb;
	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
	struct vfsmount *mnt = filp->f_path.mnt;
	struct path path;
	char buf[64], *cp;

	if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&
		     !(sb->s_flags & MS_RDONLY))) {
		sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;
		/*
		 * Sample where the filesystem has been mounted and
		 * store it in the superblock for sysadmin convenience
		 * when trying to sort through large numbers of block
		 * devices or filesystem images.
		 */
		memset(buf, 0, sizeof(buf));
		path.mnt = mnt->mnt_parent;
		path.dentry = mnt->mnt_mountpoint;
		path_get(&path);
		cp = d_path(&path, buf, sizeof(buf));
		path_put(&path);
		if (!IS_ERR(cp)) {
			memcpy(sbi->s_es->s_last_mounted, cp,
			       sizeof(sbi->s_es->s_last_mounted));
			sb->s_dirt = 1;
		}
	}
	return generic_file_open(inode, filp);
}
开发者ID:Austrie,项目名称:SpeedDemon-Kernel,代码行数:31,代码来源:file.c

示例13: ASSERT

char *npm_getcwd(char *buf, unsigned long bufsize)
{
	struct path pwd;
	char *res;

	ASSERT(bufsize >= PAGE_SIZE - 1);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || defined CONFIG_VE
	get_fs_pwd(current->fs, &pwd);
#else
	read_lock(&current->fs->lock);
	pwd = current->fs->pwd;
	path_get(&pwd);
	read_unlock(&current->fs->lock);
#endif

	res = d_path(&pwd, buf, bufsize);

	if (IS_ERR(res))
		res = NULL;

	path_put(&pwd);

	return res;
}
开发者ID:DalianDragon,项目名称:sysdig,代码行数:25,代码来源:ppm_events.c

示例14: do_fsync

static int do_fsync(unsigned int fd, int datasync)
{
	struct file *file;
	int ret = -EBADF;
	int fput_needed;
#ifdef CONFIG_ASYNC_FSYNC
	struct fsync_work *fwork;
#endif
	
	if (!fsync_enabled)
		return 0;
	
	file = fget_light(fd, &fput_needed);

	if (file) {
#ifdef CONFIG_ASYNC_FSYNC
		ktime_t fsync_t, fsync_diff;
		char pathname[256], *path;
		path = d_path(&(file->f_path), pathname, sizeof(pathname));
		if (IS_ERR(path))
			path = "(unknown)";
		else if (async_fsync(file, fd)) {
			if (!fsync_workqueue)
				fsync_workqueue =
					create_singlethread_workqueue("fsync");
			if (!fsync_workqueue)
				goto no_async;

			if (IS_ERR(path))
				goto no_async;

			fwork = kmalloc(sizeof(*fwork), GFP_KERNEL);
			if (fwork) {
				strncpy(fwork->pathname, path,
					sizeof(fwork->pathname) - 1);
				INIT_WORK(&fwork->work, do_afsync_work);
				queue_work(fsync_workqueue, &fwork->work);
				fput_light(file, fput_needed);
				return 0;
			}
		}
no_async:
		fsync_t = ktime_get();
#endif
		ret = vfs_fsync(file, datasync);
		fput_light(file, fput_needed);
#ifdef CONFIG_ASYNC_FSYNC
		fsync_diff = ktime_sub(ktime_get(), fsync_t);
		if (ktime_to_ms(fsync_diff) >= 5000) {
                        pr_info("VFS: %s pid:%d(%s)(parent:%d/%s)\
				takes %lld ms to fsync %s.\n", __func__,
				current->pid, current->comm,
				current->parent->pid, current->parent->comm,
				ktime_to_ms(fsync_diff), path);
		}
#endif
	}
	return ret;
}
开发者ID:robcore,项目名称:hammerheadcaf_kernel,代码行数:59,代码来源:sync.c

示例15: fd2path

inline char * fd2path(long fd,char *buffer,int pathmax){

  struct files_struct * files = 0;
  struct file         * f_ptr = 0;

  //----- need to convert inode to dentry.
   files = current->files;
    
   //-----  get file pointer associated with file descriptor 
   if(files) 
     f_ptr = fcheck_files(files,fd);

#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) ) 
   return d_path(f_ptr->f_dentry,f_ptr->f_vfsmnt,buffer,pathmax);
#else
   return d_path(&f_ptr->f_path,buffer,pathmax);
#endif
}
开发者ID:wmalik,项目名称:Qebek_Linux,代码行数:18,代码来源:util.c


注:本文中的d_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。