本文整理汇总了C++中parent_ino函数的典型用法代码示例。如果您正苦于以下问题:C++ parent_ino函数的具体用法?C++ parent_ino怎么用?C++ parent_ino使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parent_ino函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hfsplus_ioctl_bless
/*
* "Blessing" an HFS+ filesystem writes metadata to the superblock informing
* the platform firmware which file to boot from
*/
static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
{
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
struct hfsplus_vh *vh = sbi->s_vhdr;
struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
u32 cnid = (unsigned long)dentry->d_fsdata;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
mutex_lock(&sbi->vh_mutex);
/* Directory containing the bootable system */
vh->finder_info[0] = bvh->finder_info[0] =
cpu_to_be32(parent_ino(dentry));
/*
* Bootloader. Just using the inode here breaks in the case of
* hard links - the firmware wants the ID of the hard link file,
* but the inode points at the indirect inode
*/
vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
/* Per spec, the OS X system folder - same as finder_info[0] here */
vh->finder_info[5] = bvh->finder_info[5] =
cpu_to_be32(parent_ino(dentry));
mutex_unlock(&sbi->vh_mutex);
return 0;
}
示例2: hfsplus_ioctl_bless
/*
* "Blessing" an HFS+ filesystem writes metadata to the superblock informing
* the platform firmware which file to boot from
*/
static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
{
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
struct hfsplus_vh *vh = sbi->s_vhdr;
struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
mutex_lock(&sbi->vh_mutex);
/* Directory containing the bootable system */
vh->finder_info[0] = bvh->finder_info[0] =
cpu_to_be32(parent_ino(dentry));
/* Bootloader */
vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(inode->i_ino);
/* Per spec, the OS X system folder - same as finder_info[0] here */
vh->finder_info[5] = bvh->finder_info[5] =
cpu_to_be32(parent_ino(dentry));
mutex_unlock(&sbi->vh_mutex);
return 0;
}
示例3: zfsctl_readdir
static int
zfsctl_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct dentry *dentry = filp->f_path.dentry;
u64 ino;
int i = filp->f_pos;
switch (i) {
case 0:
ino = dentry->d_inode->i_ino;
if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
break;
filp->f_pos++;
i++;
case 1:
ino = parent_ino(dentry);
if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
break;
filp->f_pos++;
i++;
case 2:
if (filldir(dirent, ZFS_SNAPDIR_NAME, strlen(ZFS_SNAPDIR_NAME), i,
LZFS_ZFSCTL_INO_SNAPDIR, DT_DIR) < 0)
break;
filp->f_pos++;
}
return 0;
}
示例4: proc_readfd_common
static int proc_readfd_common(struct file * filp, void * dirent,
filldir_t filldir, instantiate_t instantiate)
{
struct dentry *dentry = filp->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct task_struct *p = get_proc_task(inode);
struct files_struct *files;
unsigned int fd, ino;
int retval;
retval = -ENOENT;
if (!p)
goto out_no_task;
retval = 0;
fd = filp->f_pos;
switch (fd) {
case 0:
if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
goto out;
filp->f_pos++;
case 1:
ino = parent_ino(dentry);
if (filldir(dirent, "..", 2, 1, ino, DT_DIR) < 0)
goto out;
filp->f_pos++;
default:
files = get_files_struct(p);
if (!files)
goto out;
rcu_read_lock();
for (fd = filp->f_pos - 2;
fd < files_fdtable(files)->max_fds;
fd++, filp->f_pos++) {
char name[PROC_NUMBUF];
int len;
int rv;
if (!fcheck_files(files, fd))
continue;
rcu_read_unlock();
len = snprintf(name, sizeof(name), "%d", fd);
rv = proc_fill_cache(filp, dirent, filldir,
name, len, instantiate, p,
(void *)(unsigned long)fd);
if (rv < 0)
goto out_fd_loop;
cond_resched();
rcu_read_lock();
}
rcu_read_unlock();
out_fd_loop:
put_files_struct(files);
}
out:
put_task_struct(p);
out_no_task:
return retval;
}
示例5: proc_ns_dir_readdir
static int proc_ns_dir_readdir(struct file *filp, void *dirent,
filldir_t filldir)
{
int i;
struct dentry *dentry = filp->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct task_struct *task = get_proc_task(inode);
const struct proc_ns_operations **entry, **last;
ino_t ino;
int ret;
ret = -ENOENT;
if (!task)
goto out_no_task;
ret = -EPERM;
if (!ptrace_may_access(task, PTRACE_MODE_READ))
goto out;
ret = 0;
i = filp->f_pos;
switch (i) {
case 0:
ino = inode->i_ino;
if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
goto out;
i++;
filp->f_pos++;
/* fall through */
case 1:
ino = parent_ino(dentry);
if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
goto out;
i++;
filp->f_pos++;
/* fall through */
default:
i -= 2;
if (i >= ARRAY_SIZE(ns_entries)) {
ret = 1;
goto out;
}
entry = ns_entries + i;
last = &ns_entries[ARRAY_SIZE(ns_entries) - 1];
while (entry <= last) {
if (proc_ns_fill_cache(filp, dirent, filldir,
task, *entry) < 0)
goto out;
filp->f_pos++;
entry++;
}
}
ret = 1;
out:
put_task_struct(task);
out_no_task:
return ret;
}
示例6: jffs2_readdir
static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct jffs2_inode_info *f;
struct inode *inode = filp->f_path.dentry->d_inode;
struct jffs2_full_dirent *fd;
unsigned long offset, curofs;
jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n",
filp->f_path.dentry->d_inode->i_ino);
f = JFFS2_INODE_INFO(inode);
offset = filp->f_pos;
if (offset == 0) {
jffs2_dbg(1, "Dirent 0: \".\", ino #%lu\n", inode->i_ino);
if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
goto out;
offset++;
}
if (offset == 1) {
unsigned long pino = parent_ino(filp->f_path.dentry);
jffs2_dbg(1, "Dirent 1: \"..\", ino #%lu\n", pino);
if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0)
goto out;
offset++;
}
curofs=1;
mutex_lock(&f->sem);
for (fd = f->dents; fd; fd = fd->next) {
curofs++;
/* First loop: curofs = 2; offset = 2 */
if (curofs < offset) {
jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n",
fd->name, fd->ino, fd->type, curofs, offset);
continue;
}
if (!fd->ino) {
jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n",
fd->name);
offset++;
continue;
}
jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n",
offset, fd->name, fd->ino, fd->type);
if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0)
break;
offset++;
}
mutex_unlock(&f->sem);
out:
filp->f_pos = offset;
return 0;
}
示例7: proc_sys_readdir
static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct dentry *dentry = filp->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct ctl_table_header *head = grab_header(inode);
struct ctl_table *table = PROC_I(inode)->sysctl_entry;
struct ctl_table_header *h = NULL;
unsigned long pos;
int ret = -EINVAL;
if (IS_ERR(head))
return PTR_ERR(head);
if (table && !table->child) {
WARN_ON(1);
goto out;
}
table = table ? table->child : head->ctl_table;
ret = 0;
/* Avoid a switch here: arm builds fail with missing __cmpdi2 */
if (filp->f_pos == 0) {
if (filldir(dirent, ".", 1, filp->f_pos,
inode->i_ino, DT_DIR) < 0)
goto out;
filp->f_pos++;
}
if (filp->f_pos == 1) {
if (filldir(dirent, "..", 2, filp->f_pos,
parent_ino(dentry), DT_DIR) < 0)
goto out;
filp->f_pos++;
}
pos = 2;
ret = scan(head, table, &pos, filp, dirent, filldir);
if (ret)
goto out;
for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
if (h->attached_to != table)
continue;
ret = scan(h, h->attached_by, &pos, filp, dirent, filldir);
if (ret) {
sysctl_head_finish(h);
break;
}
}
ret = 1;
out:
sysctl_head_finish(head);
return ret;
}
示例8: snap_readdir
static int
snap_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
vnode_t *dir_vp;
struct inode *dir = filp->f_path.dentry->d_inode;
char snapname[MAXNAMELEN];
uint64_t id, cookie;
boolean_t case_conflict;
int error, rc;
vfs_t *vfsp = NULL;
dir_vp = LZFS_ITOV(dir);
vfsp = dir_vp->v_vfsp;
cookie = filp->f_pos;
rc = error = 0;
if (!filp->f_pos) {
rc = filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR);
if(rc)
goto done;
filp->f_pos++;
}
if (filp->f_pos == 1) {
rc = filldir(dirent, "..", 2, filp->f_pos,
parent_ino(filp->f_path.dentry), DT_DIR);
if(rc) {
goto done;
}
filp->f_pos++;
}
while (!(error = zfs_snapshot_list_next(vfsp->vfs_data, snapname, &id,
&cookie, &case_conflict))) {
ASSERT(id > 0);
rc = filldir(dirent, snapname, strlen(snapname), filp->f_pos,
LZFS_ZFSCTL_INO_SHARES - id, DT_DIR);
filp->f_pos = cookie; // next position ptr
}
if (error) {
if (error == ENOENT) {
return (0);
}
return PTR_ERR(ERR_PTR(-error));
}
done:
return 0;
}
示例9: reval_inode
/*
* successful returns with iinfo write_locked
* minus: errno
* zero: success, matched
* plus: no error, but unmatched
*/
static int reval_inode(struct inode *inode, struct dentry *dentry)
{
int err;
unsigned int gen;
struct au_iigen iigen;
aufs_bindex_t bindex, bend;
struct inode *h_inode, *h_dinode;
/*
* before this function, if aufs got any iinfo lock, it must be only
* one, the parent dir.
* it can happen by UDBA and the obsoleted inode number.
*/
err = -EIO;
if (unlikely(inode->i_ino == parent_ino(dentry)))
goto out;
err = 1;
ii_write_lock_new_child(inode);
h_dinode = au_h_dptr(dentry, au_dbstart(dentry))->d_inode;
bend = au_ibend(inode);
for (bindex = au_ibstart(inode); bindex <= bend; bindex++) {
h_inode = au_h_iptr(inode, bindex);
if (!h_inode || h_inode != h_dinode)
continue;
err = 0;
gen = au_iigen(inode, &iigen);
if (gen == au_digen(dentry)
&& !au_ig_ftest(iigen.ig_flags, HALF_REFRESHED))
break;
/* fully refresh inode using dentry */
err = au_refresh_hinode(inode, dentry);
if (!err)
au_update_iigen(inode, /*half*/0);
break;
}
if (unlikely(err))
ii_write_unlock(inode);
out:
return err;
}
示例10: get_parent_ino
static int get_parent_ino(struct inode *inode, nid_t *pino)
{
struct dentry *dentry;
inode = igrab(inode);
dentry = d_find_any_alias(inode);
iput(inode);
if (!dentry)
return 0;
if (update_dent_inode(inode, inode, &dentry->d_name)) {
dput(dentry);
return 0;
}
*pino = parent_ino(dentry);
dput(dentry);
return 1;
}
示例11: phuang_readdir
static int phuang_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct inode *inode;
unsigned int ino;
int i;
int ret = 0;
printk(KERN_DEBUG "%s", __func__);
inode = filp->f_path.dentry->d_inode;
ino = inode->i_ino;
i = filp->f_pos;
switch(i) {
case 0:
if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
goto out;
i++;
filp->f_pos++;
case 1:
if (filldir(dirent, "..", 2, i,
parent_ino(filp->f_path.dentry),
DT_DIR) < 0)
goto out;
i++;
filp->f_pos++;
#if 1
case 2:
if (filldir(dirent, "dir", 3, i, 1, DT_DIR) < 0)
goto out;
i++;
filp->f_pos++;
case 3:
if (filldir(dirent, "file", 4, i, 2, DT_REG) < 0)
goto out;
i++;
filp->f_pos++;
#endif
}
ret = 0;
out:
return ret;
}
示例12: partsfs_readdir
/*
* Returns the root directory entries
*/
static int partsfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct dentry *dentry = filp->f_path.dentry;
switch (filp->f_pos) {
case 0:
if (filldir(dirent, ".", 1, filp->f_pos,
dentry->d_inode->i_ino, DT_DIR) < 0)
return 0;
filp->f_pos++;
case 1:
if (filldir(dirent, "..", 2, filp->f_pos,
parent_ino(dentry), DT_DIR) < 0)
return 0;
filp->f_pos++;
default:
partsfs_readdir_fill_files(filp, dirent, filldir);
}
return 0;
}
示例13: fh_compose
//.........这里部分代码省略.........
* type. If it doesn't we loop around again without
* ref_fh set.
*/
switch(fsid_type) {
case FSID_DEV:
if (!old_valid_dev(ex_dev))
goto retry;
/* FALL THROUGH */
case FSID_MAJOR_MINOR:
case FSID_ENCODE_DEV:
if (!(exp->ex_path.dentry->d_inode->i_sb->s_type->fs_flags
& FS_REQUIRES_DEV))
goto retry;
break;
case FSID_NUM:
if (! (exp->ex_flags & NFSEXP_FSID))
goto retry;
break;
case FSID_UUID8:
case FSID_UUID16:
if (!root_export)
goto retry;
/* fall through */
case FSID_UUID4_INUM:
case FSID_UUID16_INUM:
if (exp->ex_uuid == NULL)
goto retry;
break;
}
} else if (exp->ex_uuid) {
if (fhp->fh_maxsize >= 64) {
if (root_export)
fsid_type = FSID_UUID16;
else
fsid_type = FSID_UUID16_INUM;
} else {
if (root_export)
fsid_type = FSID_UUID8;
else
fsid_type = FSID_UUID4_INUM;
}
} else if (exp->ex_flags & NFSEXP_FSID)
fsid_type = FSID_NUM;
else if (!old_valid_dev(ex_dev))
/* for newer device numbers, we must use a newer fsid format */
fsid_type = FSID_ENCODE_DEV;
else
fsid_type = FSID_DEV;
if (ref_fh == fhp)
fh_put(ref_fh);
if (fhp->fh_locked || fhp->fh_dentry) {
printk(KERN_ERR "fh_compose: fh %s/%s not initialized!\n",
parent->d_name.name, dentry->d_name.name);
}
if (fhp->fh_maxsize < NFS_FHSIZE)
printk(KERN_ERR "fh_compose: called with maxsize %d! %s/%s\n",
fhp->fh_maxsize,
parent->d_name.name, dentry->d_name.name);
fhp->fh_dentry = dget(dentry); /* our internal copy */
fhp->fh_export = exp;
cache_get(&exp->h);
if (version == 0xca) {
/* old style filehandle please */
memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE);
fhp->fh_handle.fh_size = NFS_FHSIZE;
fhp->fh_handle.ofh_dcookie = 0xfeebbaca;
fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev);
fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev;
fhp->fh_handle.ofh_xino =
ino_t_to_u32(exp->ex_path.dentry->d_inode->i_ino);
fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry));
if (inode)
_fh_update_old(dentry, exp, &fhp->fh_handle);
} else {
int len;
fhp->fh_handle.fh_version = 1;
fhp->fh_handle.fh_auth_type = 0;
datap = fhp->fh_handle.fh_auth+0;
fhp->fh_handle.fh_fsid_type = fsid_type;
mk_fsid(fsid_type, datap, ex_dev,
exp->ex_path.dentry->d_inode->i_ino,
exp->ex_fsid, exp->ex_uuid);
len = key_len(fsid_type);
datap += len/4;
fhp->fh_handle.fh_size = 4 + len;
if (inode)
_fh_update(fhp, exp, dentry);
if (fhp->fh_handle.fh_fileid_type == 255)
return nfserr_opnotsupp;
}
nfsd_nr_verified++;
return 0;
}
示例14: rawfs_readdir
int rawfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct inode *inode = filp->f_path.dentry->d_inode;
struct dentry *dentry = filp->f_path.dentry;
struct super_block *sb = inode->i_sb;
struct rawfs_sb_info *sbi = RAWFS_SB(sb);
int total_cnt = 0; /* Total entries we found in hlist */
loff_t cpos;
unsigned long ino;
cpos = filp->f_pos;
/* Read dir will execute twice. */
if (inode->i_ino == RAWFS_ROOT_INO)
RAWFS_PRINT(RAWFS_DBG_DIR, "rawfs_readdir, root, pos %lld\n", cpos);
else
RAWFS_PRINT(RAWFS_DBG_DIR, "rawfs_readdir, %s, i_id %X, i_ino %X, pos %lld\n",
dentry->d_name.name, RAWFS_I(inode)->i_id, (unsigned)inode->i_ino, cpos);
switch (cpos) {
case 0:
ino = dentry->d_inode->i_ino;
if (filldir(dirent, ".", 1, cpos, ino, DT_DIR) < 0)
break;
filp->f_pos++;
cpos++;
/* fallthrough */
case 1:
ino = parent_ino(dentry);
if (filldir(dirent, "..", 2, cpos, ino, DT_DIR) < 0)
break;
filp->f_pos++;
cpos++;
/* fallthrough */
default:
{
struct rawfs_file_list_entry *entry;
struct list_head *lists[2];
int i;
lists[0] = &sbi->folder_list;
lists[1] = &sbi->file_list;
mutex_lock(&sbi->file_list_lock);
for (i = 0; i < 2; i++) {
list_for_each_entry(entry, lists[i], list)
{
int name_len;
/* Matching sub-directory */
if (entry->file_info.i_parent_folder_id !=
RAWFS_I(dentry->d_inode)->i_id) {
RAWFS_PRINT(RAWFS_DBG_DIR,
"readdir: skip %s, parent folder id %X, target folder %X\n",
entry->file_info.i_name,
entry->file_info.i_parent_folder_id,
RAWFS_I(dentry->d_inode)->i_id);
continue;
}
total_cnt++;
if ((total_cnt+2) <= cpos) { /* skip first N + 2 (. & ..)
entiries, if cpos doesn't start from zero */
RAWFS_PRINT(RAWFS_DBG_DIR,
"readdir: cpos=%lld, total cnt=%d, %s\n", cpos, total_cnt,
entry->file_info.i_name);
continue;
}
name_len = strlen(entry->file_info.i_name);
if (filldir(dirent,
entry->file_info.i_name,
name_len,
cpos,
entry->file_info.i_id,
(S_ISDIR(entry->file_info.i_mode)?DT_DIR:DT_REG)) < 0)
goto out;
filp->f_pos++;
cpos++;
}
}
}
out:
mutex_unlock(&sbi->file_list_lock);
break;
}
示例15: coda_venus_readdir
static int coda_venus_readdir(struct file *coda_file, void *buf,
filldir_t filldir)
{
int result = 0;
struct coda_file_info *cfi;
struct coda_inode_info *cii;
struct file *host_file;
struct dentry *de;
struct venus_dirent *vdir;
unsigned long vdir_size = offsetof(struct venus_dirent, d_name);
unsigned int type;
struct qstr name;
ino_t ino;
int ret;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
de = coda_file->f_path.dentry;
cii = ITOC(de->d_inode);
vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
if (!vdir) return -ENOMEM;
if (coda_file->f_pos == 0) {
ret = filldir(buf, ".", 1, 0, de->d_inode->i_ino, DT_DIR);
if (ret < 0)
goto out;
result++;
coda_file->f_pos++;
}
if (coda_file->f_pos == 1) {
ret = filldir(buf, "..", 2, 1, parent_ino(de), DT_DIR);
if (ret < 0)
goto out;
result++;
coda_file->f_pos++;
}
while (1) {
ret = kernel_read(host_file, coda_file->f_pos - 2, (char *)vdir,
sizeof(*vdir));
if (ret < 0) {
printk(KERN_ERR "coda readdir: read dir %s failed %d\n",
coda_f2s(&cii->c_fid), ret);
break;
}
if (ret == 0) break;
if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) {
printk(KERN_ERR "coda readdir: short read on %s\n",
coda_f2s(&cii->c_fid));
ret = -EBADF;
break;
}
if (vdir->d_reclen < vdir_size + vdir->d_namlen) {
printk(KERN_ERR "coda readdir: invalid dir %s\n",
coda_f2s(&cii->c_fid));
ret = -EBADF;
break;
}
name.len = vdir->d_namlen;
name.name = vdir->d_name;
if (name.name[0] == '.' && (name.len == 1 ||
(vdir->d_name[1] == '.' && name.len == 2)))
vdir->d_fileno = name.len = 0;
if (vdir->d_fileno && name.len) {
ino = find_inode_number(de, &name);
if (!ino) ino = vdir->d_fileno;
type = CDT2DT(vdir->d_type);
ret = filldir(buf, name.name, name.len,
coda_file->f_pos, ino, type);
if (ret < 0) break;
result++;
}
coda_file->f_pos += vdir->d_reclen;
}
out:
kfree(vdir);
return result ? result : ret;
}