本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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(¤t->fs->lock);
pwd = current->fs->pwd;
path_get(&pwd);
read_unlock(¤t->fs->lock);
#endif
res = d_path(&pwd, buf, bufsize);
if (IS_ERR(res))
res = NULL;
path_put(&pwd);
return res;
}
示例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;
}
示例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
}