本文整理汇总了C++中d_path函数的典型用法代码示例。如果您正苦于以下问题:C++ d_path函数的具体用法?C++ d_path怎么用?C++ d_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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(¤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;
}
开发者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
示例16: d_path
/* copy the pathname of a file to a buffer */
char *file_path(struct file *file, char *buf, int count)
{
if (!buf)
return NULL;
buf = d_path(&file->f_path, buf, count);
return IS_ERR(buf) ? NULL : buf;
}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:10,代码来源:bitmap.c
示例17: notify_exec
static int notify_exec(struct mm_struct *mm)
{
char *buf, *path;
struct vm_area_struct *vma;
#ifndef CONFIG_KVM_GUEST /* see notify_sim_task_change() */
if (!sim_is_simulator())
#endif
return 1;
if (mm->exe_file == NULL)
return 0;
for (vma = current->mm->mmap; ; vma = vma->vm_next) {
if (vma == NULL)
return 0;
if (vma->vm_file == mm->exe_file)
break;
}
buf = (char *) __get_free_page(GFP_KERNEL);
if (buf == NULL)
return 0;
path = d_path(&mm->exe_file->f_path, buf, PAGE_SIZE);
if (IS_ERR(path)) {
free_page((unsigned long)buf);
return 0;
}
/*
* Notify simulator of an ET_DYN object so we know the load address.
* The somewhat cryptic overuse of SIM_CONTROL_DLOPEN allows us
* to be backward-compatible with older simulator releases.
*/
if (vma->vm_start == (ELF_ET_DYN_BASE & PAGE_MASK)) {
char buf[64];
int i;
snprintf(buf, sizeof(buf), "0x%lx:@", vma->vm_start);
for (i = 0; ; ++i) {
char c = buf[i];
__insn_mtspr(SPR_SIM_CONTROL,
(SIM_CONTROL_DLOPEN
| (c << _SIM_CONTROL_OPERATOR_BITS)));
if (c == '\0')
break;
}
}
sim_notify_exec(path);
free_page((unsigned long)buf);
return 1;
}
开发者ID:tcreech,项目名称:tilegx-linux-3.4.68-politestackrehome,代码行数:54,代码来源:elf.c
示例18: read_maps
static inline void read_maps (void)
{
struct vm_area_struct * map, * next;
char * buffer;
ssize_t i;
buffer = (char*)__get_free_page(GFP_KERNEL);
if (!buffer)
return;
for (map = current->mm->mmap ; map ; map = next ) {
/* produce the next line */
char *line;
char str[5], *cp = str;
int flags;
kdev_t dev;
unsigned long ino;
/*
* Get the next vma now (but it won't be used if we sleep).
*/
next = map->vm_next;
flags = map->vm_flags;
*cp++ = flags & VM_READ ? 'r' : '-';
*cp++ = flags & VM_WRITE ? 'w' : '-';
*cp++ = flags & VM_EXEC ? 'x' : '-';
*cp++ = flags & VM_MAYSHARE ? 's' : 'p';
*cp++ = 0;
dev = 0;
ino = 0;
if (map->vm_file != NULL) {
dev = map->vm_file->f_dentry->d_inode->i_dev;
ino = map->vm_file->f_dentry->d_inode->i_ino;
line = d_path(map->vm_file->f_dentry,
map->vm_file->f_vfsmnt,
buffer, PAGE_SIZE);
if (IS_ERR(line))
break;
}
printk(MAPS_LINE_FORMAT, map->vm_start, map->vm_end, str, map->vm_pgoff << PAGE_SHIFT,
kdevname(dev), ino);
if (map->vm_file != NULL)
printk("%s\n", line);
else
printk("\n");
}
free_page((unsigned long)buffer);
return;
}
开发者ID:romanalexander,项目名称:Trickles,代码行数:51,代码来源:signal.c
示例19: translucent_copy
/** create a copy of a regular file in overlay
@param nd specifies underlay - source to copy
@param nnew specifies new entry - destination
@return 0 on success, -ECODE otherwise
*/
int translucent_copy(struct nameidata *nd, struct nameidata *nnew, int lookup_flags) {
char *p, *buf, *pathbuf;
ssize_t (*sys_write)(int fd, const void *buf, size_t count)=sys_call_table[__NR_write];
ssize_t (*sys_read)(int fd, void *buf, size_t count)=sys_call_table[__NR_read];
int (*sys_close)(int fd)=sys_call_table[__NR_close];
int result,inphandle,outphandle;
int i_Bufsize=4096;
umode_t mode=nd->dentry->d_inode->i_mode;
struct utimbuf timebuf={ actime:nd->dentry->d_inode->i_atime, modtime:nd->dentry->d_inode->i_mtime };
// exclude device/pipe/socket/dir and proc entries from COW
if(is_special(nd)) return -ENODEV;
mode &= S_IRWXUGO;
buf=malloc(i_Bufsize);
pathbuf=malloc(REDIR_BUFSIZE+1);
p = d_path(nd->dentry, nd->mnt, pathbuf, REDIR_BUFSIZE);
// printk(KERN_DEBUG SYSLOGID ": copy-on-write %s %o\n",p,mode);
BEGIN_KMEM
result=orig_sys_open(p,O_RDONLY,0666);
END_KMEM
if(result<0) goto out_free;
inphandle=result;
p=d_path(nnew->dentry, nnew->mnt, pathbuf, REDIR_BUFSIZE);
BEGIN_KMEM
result=orig_sys_open(p,O_WRONLY|O_CREAT,mode);
END_KMEM
if(result<0) goto out_close;
outphandle=result;
if(!(lookup_flags&LOOKUP_TRUNCATE)) {
BEGIN_KMEM
while((result=sys_read(inphandle,buf,i_Bufsize))>0&&sys_write(outphandle,buf,result)>0);
END_KMEM
} else result=0;
开发者ID:bmwiedemann,项目名称:translucency,代码行数:43,代码来源:base.c
示例20: memset
char *getfullPath(const char *pathname, char *fullpath) {
//char *fullpath = NULL;
char *path = NULL;
char *start = NULL;
//struct dentry *pwd;
//struct vfsmount *vfsmount;
struct fs_struct *fs = current->fs;
struct path pwd;
/*fullpath = kmalloc(PATH_MAX, GFP_KERNEL);
if (!fullpath) {
// kmalloc error
return fullpath;
}
memset(fullpath, 0, PATH_MAX);*/
path = kmalloc(PATH_MAX, GFP_KERNEL);
if (!path) {
return NULL;
}
// 2.4
// get dentry and vfsmnt
//read_lock(&(fs->lock));
//pwd = dget(fs->pwd);
//vfsmount = mntget(fs->pwdmnt);
//read_unlock(&(fs->lock));
// get path
//start = d_path(pwd, vfsmount, path, PATH_MAX);
//strcat(fullpath, start);
// 2.6.32
read_lock(&fs->lock);
pwd = fs->pwd;
path_get(&pwd);
read_unlock(&fs->lock);
//set_fs_pwd(fs, &pwd);
start = d_path(&pwd, path, PATH_MAX);
strcat(fullpath, start);
strcat(fullpath, "/");
strcat(fullpath, pathname);
// 2.6.35
// use spinlock
kfree(path);
return fullpath;
}
开发者ID:ultragtx,项目名称:LKMFileSystemProtection,代码行数:50,代码来源:utilities.c
注:本文中的d_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论