本文整理汇总了C++中d_set_d_op函数的典型用法代码示例。如果您正苦于以下问题:C++ d_set_d_op函数的具体用法?C++ d_set_d_op怎么用?C++ d_set_d_op使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_set_d_op函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_fdinfo_instantiate
static struct dentry *
proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
struct task_struct *task, const void *ptr)
{
struct dentry *error = ERR_PTR(-ENOENT);
unsigned fd = (unsigned long)ptr;
struct proc_inode *ei;
struct inode *inode;
inode = proc_pid_make_inode(dir->i_sb, task);
if (!inode)
goto out;
ei = PROC_I(inode);
ei->fd = fd;
inode->i_mode = S_IFREG | S_IRUSR;
inode->i_fop = &proc_fdinfo_file_operations;
d_set_d_op(dentry, &tid_fd_dentry_operations);
d_add(dentry, inode);
/* Close the race of the process dying before we return the dentry */
if (tid_fd_revalidate(dentry, 0))
error = NULL;
out:
return error;
}
示例2: dumpfs_read_sb
static int
dumpfs_read_sb(struct super_block *sb, void *data, int silent)
{
int err = 0;
struct inode *inode;
struct buffer_head *bh;
struct dumpfs_sb_info *sbi;
dumpfs_super_block_t *ds;
char *dev_name = (char *)data;
if (!dev_name) {
err = -EINVAL;
goto out;
}
/*
* dev_name is device_name or file that needs to be mounted
* mount -t dumpfs /mnt/filename /mnt/dumpfs, dev_name points
* to /mnt/filename.
*/
/* connect dumpfs superblock later */
sbi = kzalloc(sizeof(struct dumpfs_sb_info), GFP_KERNEL);
if (!sbi) {
err = -ENOMEM;
goto out;
}
sb->s_fs_info = sbi;
/* read the superblock from the disk */
if (!(bh = sb_bread(sb, 0))) {
goto free;
}
ds = (dumpfs_super_block_t *)bh->b_data;
sb->s_magic = ds->s_magic;
sb->s_time_gran = 1;
sb->s_op = &dumpfs_sops;
sbi->s_buf = ds;
printk(KERN_INFO "sbi->s_buf %p\n", sb->s_fs_info);
inode = dumpfs_iget(sb, DUMPFS_ROOT_INUM);
if (IS_ERR(inode)) {
printk(KERN_INFO "%d \n", __LINE__);
err = PTR_ERR(inode);
goto out;
}
printk(KERN_INFO "inode %p magic %x\n", inode, ds->s_magic);
sb->s_root = d_make_root(inode);
if (!sb->s_root) {
err = -ENOMEM;
goto free;
}
d_rehash(sb->s_root);
d_set_d_op(sb->s_root, &dumpfs_dops);
goto out;
free:
printk(KERN_INFO "Failed free superblock");
kfree(sb->s_fs_info);
out:
return (err);
}
示例3: KERNEL_VERSION
static struct dentry *prlfs_lookup(struct inode *dir, struct dentry *dentry
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
, unsigned int flags
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
, struct nameidata *nd
#endif
)
{
int ret;
struct prlfs_attr attr;
struct inode *inode;
DPRINTK("ENTER\n");
DPRINTK("dir ino %lld entry name \"%s\"\n",
(u64)dir->i_ino, dentry->d_name.name);
ret = do_prlfs_getattr(dentry, &attr);
if (ret < 0 ) {
if (ret == -ENOENT) {
inode = NULL;
ret = 0;
} else
goto out;
} else {
inode = prlfs_get_inode(dentry->d_sb, attr.mode);
if (inode)
prlfs_change_attributes(inode, &attr);
}
dentry->d_time = jiffies;
d_add(dentry, inode);
d_set_d_op(dentry, &prlfs_dentry_ops);
out:
DPRINTK("EXIT returning %d\n", ret);
return ERR_PTR(ret);
}
示例4: zpl_snapdir_mkdir
static int
zpl_snapdir_mkdir(struct inode *dip, struct dentry *dentry, zpl_umode_t mode)
{
cred_t *cr = CRED();
vattr_t *vap;
struct inode *ip;
int error;
crhold(cr);
vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
zpl_vap_init(vap, dip, mode | S_IFDIR, cr);
error = -zfsctl_snapdir_mkdir(dip, dname(dentry), vap, &ip, cr, 0);
if (error == 0) {
d_clear_d_op(dentry);
d_set_d_op(dentry, &zpl_dops_snapdirs);
d_instantiate(dentry, ip);
}
kmem_free(vap, sizeof (vattr_t));
ASSERT3S(error, <=, 0);
crfree(cr);
return (error);
}
示例5: zpl_snapdir_lookup
zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry,
unsigned int flags)
#endif
{
fstrans_cookie_t cookie;
cred_t *cr = CRED();
struct inode *ip = NULL;
int error;
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfsctl_snapdir_lookup(dip, dname(dentry), &ip,
0, cr, NULL, NULL);
ASSERT3S(error, <=, 0);
spl_fstrans_unmark(cookie);
crfree(cr);
if (error && error != -ENOENT)
return (ERR_PTR(error));
ASSERT(error == 0 || ip == NULL);
d_clear_d_op(dentry);
d_set_d_op(dentry, &zpl_dops_snapdirs);
#ifdef HAVE_AUTOMOUNT
dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
#endif
return (d_splice_alias(ip, dentry));
}
示例6: ERR_PTR
static struct dentry *proc_ns_instantiate(struct inode *dir,
struct dentry *dentry, struct task_struct *task, const void *ptr)
{
const struct proc_ns_operations *ns_ops = ptr;
struct inode *inode;
struct proc_inode *ei;
struct dentry *error = ERR_PTR(-ENOENT);
void *ns;
inode = proc_pid_make_inode(dir->i_sb, task);
if (!inode)
goto out;
ns = ns_ops->get(task);
if (!ns)
goto out_iput;
ei = PROC_I(inode);
inode->i_mode = S_IFREG|S_IRUSR;
inode->i_fop = &ns_file_operations;
ei->ns_ops = ns_ops;
ei->ns = ns;
d_set_d_op(dentry, &pid_dentry_operations);
d_add(dentry, inode);
/* Close the race of the process dying before we return the dentry */
if (pid_revalidate(dentry, 0))
error = NULL;
out:
return error;
out_iput:
iput(inode);
goto out;
}
示例7: proc_fd_instantiate
static int
proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
struct task_struct *task, const void *ptr)
{
unsigned fd = (unsigned long)ptr;
struct proc_inode *ei;
struct inode *inode;
inode = proc_pid_make_inode(dir->i_sb, task);
if (!inode)
goto out;
ei = PROC_I(inode);
ei->fd = fd;
inode->i_mode = S_IFLNK;
inode->i_op = &proc_pid_link_inode_operations;
inode->i_size = 64;
ei->op.proc_get_link = proc_fd_link;
d_set_d_op(dentry, &tid_fd_dentry_operations);
d_add(dentry, inode);
/* Close the race of the process dying before we return the dentry */
if (tid_fd_revalidate(dentry, 0))
return 0;
out:
return -ENOENT;
}
示例8: zpl_lookup
zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
#endif
{
cred_t *cr = CRED();
struct inode *ip;
int error;
fstrans_cookie_t cookie;
if (dlen(dentry) > ZFS_MAXNAMELEN)
return (ERR_PTR(-ENAMETOOLONG));
crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, NULL);
spl_fstrans_unmark(cookie);
ASSERT3S(error, <=, 0);
crfree(cr);
spin_lock(&dentry->d_lock);
dentry->d_time = jiffies;
#ifndef HAVE_S_D_OP
d_set_d_op(dentry, &zpl_dentry_operations);
#endif /* HAVE_S_D_OP */
spin_unlock(&dentry->d_lock);
if (error) {
if (error == -ENOENT)
return (d_splice_alias(NULL, dentry));
else
return (ERR_PTR(error));
}
return (d_splice_alias(ip, dentry));
}
示例9: ERR_PTR
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative. Set d_op to delete negative dentries.
*/
struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
{
if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG);
if (!dentry->d_sb->s_d_op)
d_set_d_op(dentry, &simple_dentry_operations);
d_add(dentry, NULL);
return NULL;
}
示例10: ERR_PTR
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative. Set d_op to delete negative dentries.
*/
struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{
static const struct dentry_operations simple_dentry_operations = {
.d_delete = simple_delete_dentry,
};
if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG);
d_set_d_op(dentry, &simple_dentry_operations);
d_add(dentry, NULL);
return NULL;
}
示例11: ceph_init_dentry
/*
* Initialize ceph dentry state.
*/
int ceph_init_dentry(struct dentry *dentry)
{
struct ceph_dentry_info *di;
if (dentry->d_fsdata)
return 0;
di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
if (!di)
return -ENOMEM; /* oh well */
spin_lock(&dentry->d_lock);
if (dentry->d_fsdata) {
/* lost a race */
kmem_cache_free(ceph_dentry_cachep, di);
goto out_unlock;
}
if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP)
d_set_d_op(dentry, &ceph_dentry_ops);
else if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
d_set_d_op(dentry, &ceph_snapdir_dentry_ops);
else
d_set_d_op(dentry, &ceph_snap_dentry_ops);
di->dentry = dentry;
di->lease_session = NULL;
di->time = jiffies;
/* avoid reordering d_fsdata setup so that the check above is safe */
smp_mb();
dentry->d_fsdata = di;
ceph_dentry_lru_add(dentry);
out_unlock:
spin_unlock(&dentry->d_lock);
return 0;
}
示例12: __fscrypt_prepare_lookup
int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry)
{
int err = fscrypt_get_encryption_info(dir);
if (err)
return err;
if (fscrypt_has_encryption_key(dir)) {
spin_lock(&dentry->d_lock);
dentry->d_flags |= DCACHE_ENCRYPTED_WITH_KEY;
spin_unlock(&dentry->d_lock);
}
d_set_d_op(dentry, &fscrypt_d_ops);
return 0;
}
示例13: reiserfs_lookup_privroot
int reiserfs_lookup_privroot(struct super_block *s)
{
struct dentry *dentry;
int err = 0;
/* If we don't have the privroot located yet - go find it */
reiserfs_mutex_lock_safe(&s->s_root->d_inode->i_mutex, s);
dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
strlen(PRIVROOT_NAME));
if (!IS_ERR(dentry)) {
REISERFS_SB(s)->priv_root = dentry;
d_set_d_op(dentry, &xattr_lookup_poison_ops);
if (dentry->d_inode)
dentry->d_inode->i_flags |= S_PRIVATE;
} else
err = PTR_ERR(dentry);
mutex_unlock(&s->s_root->d_inode->i_mutex);
return err;
}
示例14: proc_ns_instantiate
static int proc_ns_instantiate(struct inode *dir,
struct dentry *dentry, struct task_struct *task, const void *ptr)
{
const struct proc_ns_operations *ns_ops = ptr;
struct inode *inode;
struct proc_inode *ei;
inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK | S_IRWXUGO);
if (!inode)
goto out;
ei = PROC_I(inode);
inode->i_op = &proc_ns_link_inode_operations;
ei->ns_ops = ns_ops;
d_set_d_op(dentry, &pid_dentry_operations);
d_add(dentry, inode);
/* Close the race of the process dying before we return the dentry */
if (pid_revalidate(dentry, 0))
return 0;
out:
return -ENOENT;
}
示例15: proc_sys_fill_cache
static int proc_sys_fill_cache(struct file *filp, void *dirent,
filldir_t filldir,
struct ctl_table_header *head,
struct ctl_table *table)
{
struct dentry *child, *dir = filp->f_path.dentry;
struct inode *inode;
struct qstr qname;
ino_t ino = 0;
unsigned type = DT_UNKNOWN;
qname.name = table->procname;
qname.len = strlen(table->procname);
qname.hash = full_name_hash(qname.name, qname.len);
child = d_lookup(dir, &qname);
if (!child) {
child = d_alloc(dir, &qname);
if (child) {
inode = proc_sys_make_inode(dir->d_sb, head, table);
if (!inode) {
dput(child);
return -ENOMEM;
} else {
d_set_d_op(child, &proc_sys_dentry_operations);
d_add(child, inode);
}
} else {
return -ENOMEM;
}
}
inode = child->d_inode;
ino = inode->i_ino;
type = inode->i_mode >> 12;
dput(child);
return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type);
}