本文整理汇总了C++中d_alloc_name函数的典型用法代码示例。如果您正苦于以下问题:C++ d_alloc_name函数的具体用法?C++ d_alloc_name怎么用?C++ d_alloc_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_alloc_name函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: d_alloc_name
static struct dentry *xenfs_create_file(struct super_block *sb,
struct dentry *parent,
const char *name,
const struct file_operations *fops,
void *data,
int mode)
{
struct dentry *dentry;
struct inode *inode;
dentry = d_alloc_name(parent, name);
if (!dentry)
return NULL;
inode = xenfs_make_inode(sb, S_IFREG | mode);
if (!inode) {
dput(dentry);
return NULL;
}
inode->i_fop = fops;
inode->i_private = data;
d_add(dentry, inode);
return dentry;
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:26,代码来源:super.c
示例2: sel_make_avc_files
static int sel_make_avc_files(struct dentry *dir)
{
int i;
static struct tree_descr files[] = {
{ "cache_threshold",
&sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR },
{ "hash_stats", &sel_avc_hash_stats_ops, S_IRUGO },
#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
{ "cache_stats", &sel_avc_cache_stats_ops, S_IRUGO },
#endif
};
for (i = 0; i < ARRAY_SIZE(files); i++) {
struct inode *inode;
struct dentry *dentry;
dentry = d_alloc_name(dir, files[i].name);
if (!dentry)
return -ENOMEM;
inode = sel_make_inode(dir->d_sb, S_IFREG|files[i].mode);
if (!inode)
return -ENOMEM;
inode->i_fop = files[i].ops;
inode->i_ino = ++sel_last_ino;
d_add(dentry, inode);
}
return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:31,代码来源:selinuxfs.c
示例3: sel_make_initcon_files
static int sel_make_initcon_files(struct dentry *dir)
{
int i, ret = 0;
for (i = 1; i <= SECINITSID_NUM; i++) {
struct inode *inode;
struct dentry *dentry;
dentry = d_alloc_name(dir, security_get_initial_sid_context(i));
if (!dentry) {
ret = -ENOMEM;
goto out;
}
inode = sel_make_inode(dir->d_sb, S_IFREG|S_IRUGO);
if (!inode) {
ret = -ENOMEM;
goto out;
}
inode->i_fop = &sel_initcon_ops;
inode->i_ino = i|SEL_INITCON_INO_OFFSET;
d_add(dentry, inode);
}
out:
return ret;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:25,代码来源:selinuxfs.c
示例4: proc_setup_self
int proc_setup_self(struct super_block *s)
{
struct inode *root_inode = s->s_root->d_inode;
struct pid_namespace *ns = s->s_fs_info;
struct dentry *self;
mutex_lock(&root_inode->i_mutex);
self = d_alloc_name(s->s_root, "self");
if (self) {
struct inode *inode = new_inode_pseudo(s);
if (inode) {
inode->i_ino = self_inum;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_mode = S_IFLNK | S_IRWXUGO;
inode->i_uid = GLOBAL_ROOT_UID;
inode->i_gid = GLOBAL_ROOT_GID;
inode->i_op = &proc_self_inode_operations;
d_add(self, inode);
} else {
dput(self);
self = ERR_PTR(-ENOMEM);
}
} else {
self = ERR_PTR(-ENOMEM);
}
mutex_unlock(&root_inode->i_mutex);
if (IS_ERR(self)) {
pr_err("proc_fill_super: can't allocate /proc/self\n");
return PTR_ERR(self);
}
ns->proc_self = self;
return 0;
}
开发者ID:dkati,项目名称:Hulk-Kernel-V2,代码行数:33,代码来源:self.c
示例5: mknod_ptmx
static int mknod_ptmx(struct super_block *sb)
{
int mode;
int rc = -ENOMEM;
struct dentry *dentry;
struct inode *inode;
struct dentry *root = sb->s_root;
struct pts_fs_info *fsi = DEVPTS_SB(sb);
struct pts_mount_opts *opts = &fsi->mount_opts;
kuid_t root_uid;
kgid_t root_gid;
root_uid = make_kuid(current_user_ns(), 0);
root_gid = make_kgid(current_user_ns(), 0);
if (!uid_valid(root_uid) || !gid_valid(root_gid))
return -EINVAL;
mutex_lock(&root->d_inode->i_mutex);
/* If we have already created ptmx node, return */
if (fsi->ptmx_dentry) {
rc = 0;
goto out;
}
dentry = d_alloc_name(root, "ptmx");
if (!dentry) {
printk(KERN_NOTICE "Unable to alloc dentry for ptmx node\n");
goto out;
}
/*
* Create a new 'ptmx' node in this mount of devpts.
*/
inode = new_inode(sb);
if (!inode) {
printk(KERN_ERR "Unable to alloc inode for ptmx node\n");
dput(dentry);
goto out;
}
inode->i_ino = 2;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
mode = S_IFCHR|opts->ptmxmode;
init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
inode->i_uid = root_uid;
inode->i_gid = root_gid;
d_add(dentry, inode);
fsi->ptmx_dentry = dentry;
rc = 0;
out:
mutex_unlock(&root->d_inode->i_mutex);
return rc;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:57,代码来源:inode.c
示例6: mknod_ptmx
static int mknod_ptmx(struct super_block *sb)
{
int mode;
int rc = -ENOMEM;
struct dentry *dentry;
struct inode *inode;
struct dentry *root = sb->s_root;
struct pts_fs_info *fsi = DEVPTS_SB(sb);
struct pts_mount_opts *opts = &fsi->mount_opts;
kuid_t ptmx_uid = current_fsuid();
kgid_t ptmx_gid = current_fsgid();
inode_lock(d_inode(root));
/* If we have already created ptmx node, return */
if (fsi->ptmx_dentry) {
rc = 0;
goto out;
}
dentry = d_alloc_name(root, "ptmx");
if (!dentry) {
pr_err("Unable to alloc dentry for ptmx node\n");
goto out;
}
/*
* Create a new 'ptmx' node in this mount of devpts.
*/
inode = new_inode(sb);
if (!inode) {
pr_err("Unable to alloc inode for ptmx node\n");
dput(dentry);
goto out;
}
inode->i_ino = 2;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
mode = S_IFCHR|opts->ptmxmode;
init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
inode->i_uid = ptmx_uid;
inode->i_gid = ptmx_gid;
d_add(dentry, inode);
fsi->ptmx_dentry = dentry;
rc = 0;
out:
inode_unlock(d_inode(root));
return rc;
}
开发者ID:guribe94,项目名称:linux,代码行数:52,代码来源:inode.c
示例7: oprofilefs_mkdir
struct dentry * oprofilefs_mkdir(struct super_block * sb,
struct dentry * root, char const * name)
{
struct dentry * dentry;
struct inode * inode;
dentry = d_alloc_name(root, name);
if (!dentry)
return NULL;
inode = oprofilefs_get_inode(sb, S_IFDIR | 0755);
if (!inode) {
dput(dentry);
return NULL;
}
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
d_add(dentry, inode);
return dentry;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:19,代码来源:oprofilefs.c
示例8: __oprofilefs_create_file
static struct dentry * __oprofilefs_create_file(struct super_block * sb,
struct dentry * root, char const * name, const struct file_operations * fops,
int perm)
{
struct dentry * dentry;
struct inode * inode;
dentry = d_alloc_name(root, name);
if (!dentry)
return NULL;
inode = oprofilefs_get_inode(sb, S_IFREG | perm);
if (!inode) {
dput(dentry);
return NULL;
}
inode->i_fop = fops;
d_add(dentry, inode);
return dentry;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:19,代码来源:oprofilefs.c
示例9: __oprofilefs_create_file
static int __oprofilefs_create_file(struct super_block *sb,
struct dentry *root, char const *name, const struct file_operations *fops,
int perm, void *priv)
{
struct dentry *dentry;
struct inode *inode;
dentry = d_alloc_name(root, name);
if (!dentry)
return -ENOMEM;
inode = oprofilefs_get_inode(sb, S_IFREG | perm);
if (!inode) {
dput(dentry);
return -ENOMEM;
}
inode->i_fop = fops;
d_add(dentry, inode);
dentry->d_inode->i_private = priv;
return 0;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:20,代码来源:oprofilefs.c
示例10: pts_sb_from_inode
/**
* devpts_pty_new -- create a new inode in /dev/pts/
* @ptmx_inode: inode of the master
* @device: major+minor of the node to be created
* @index: used as a name of the node
* @priv: what's given back by devpts_get_priv
*
* The created inode is returned. Remove it from /dev/pts/ by devpts_pty_kill.
*/
struct inode *devpts_pty_new(struct inode *ptmx_inode, dev_t device, int index,
void *priv)
{
struct dentry *dentry;
struct super_block *sb = pts_sb_from_inode(ptmx_inode);
struct inode *inode;
struct dentry *root = sb->s_root;
struct pts_fs_info *fsi = DEVPTS_SB(sb);
struct pts_mount_opts *opts = &fsi->mount_opts;
char s[12];
inode = new_inode(sb);
if (!inode)
return ERR_PTR(-ENOMEM);
inode->i_ino = index + 3;
inode->i_uid = opts->setuid ? opts->uid : current_fsuid();
inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
init_special_inode(inode, S_IFCHR|opts->mode, device);
inode->i_private = priv;
sprintf(s, "%d", index);
mutex_lock(&root->d_inode->i_mutex);
dentry = d_alloc_name(root, s);
if (dentry) {
d_add(dentry, inode);
fsnotify_create(root->d_inode, dentry);
} else {
iput(inode);
inode = ERR_PTR(-ENOMEM);
}
mutex_unlock(&root->d_inode->i_mutex);
return inode;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:48,代码来源:inode.c
示例11: inode_lock
struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name)
{
struct dentry *dentry;
struct inode *inode;
inode_lock(d_inode(parent));
dentry = d_alloc_name(parent, name);
if (!dentry) {
inode_unlock(d_inode(parent));
return NULL;
}
inode = oprofilefs_get_inode(parent->d_sb, S_IFDIR | 0755);
if (!inode) {
dput(dentry);
inode_unlock(d_inode(parent));
return NULL;
}
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
d_add(dentry, inode);
inode_unlock(d_inode(parent));
return dentry;
}
开发者ID:acton393,项目名称:linux,代码行数:23,代码来源:oprofilefs.c
示例12: new_inode
/**
* devpts_pty_new -- create a new inode in /dev/pts/
* @ptmx_inode: inode of the master
* @device: major+minor of the node to be created
* @index: used as a name of the node
* @priv: what's given back by devpts_get_priv
*
* The created inode is returned. Remove it from /dev/pts/ by devpts_pty_kill.
*/
struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
{
struct dentry *dentry;
struct super_block *sb = fsi->sb;
struct inode *inode;
struct dentry *root;
struct pts_mount_opts *opts;
char s[12];
root = sb->s_root;
opts = &fsi->mount_opts;
inode = new_inode(sb);
if (!inode)
return ERR_PTR(-ENOMEM);
inode->i_ino = index + 3;
inode->i_uid = opts->setuid ? opts->uid : current_fsuid();
inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
init_special_inode(inode, S_IFCHR|opts->mode, MKDEV(UNIX98_PTY_SLAVE_MAJOR, index));
sprintf(s, "%d", index);
dentry = d_alloc_name(root, s);
if (dentry) {
dentry->d_fsdata = priv;
d_add(dentry, inode);
fsnotify_create(d_inode(root), dentry);
} else {
iput(inode);
dentry = ERR_PTR(-ENOMEM);
}
return dentry;
}
开发者ID:guribe94,项目名称:linux,代码行数:45,代码来源:inode.c
示例13: sel_make_bools
static int sel_make_bools(void)
{
int i, ret;
ssize_t len;
struct dentry *dentry = NULL;
struct dentry *dir = bool_dir;
struct inode *inode = NULL;
struct inode_security_struct *isec;
char **names = NULL, *page;
int num;
int *values = NULL;
u32 sid;
/* remove any existing files */
for (i = 0; i < bool_num; i++)
kfree(bool_pending_names[i]);
kfree(bool_pending_names);
kfree(bool_pending_values);
bool_num = 0;
bool_pending_names = NULL;
bool_pending_values = NULL;
sel_remove_entries(dir);
ret = -ENOMEM;
page = (char *)get_zeroed_page(GFP_KERNEL);
if (!page)
goto out;
ret = security_get_bools(&num, &names, &values);
if (ret)
goto out;
for (i = 0; i < num; i++) {
ret = -ENOMEM;
dentry = d_alloc_name(dir, names[i]);
if (!dentry)
goto out;
ret = -ENOMEM;
inode = sel_make_inode(dir->d_sb, S_IFREG | S_IRUGO | S_IWUSR);
if (!inode)
goto out;
ret = -EINVAL;
len = snprintf(page, PAGE_SIZE, "/%s/%s", BOOL_DIR_NAME, names[i]);
if (len < 0)
goto out;
ret = -ENAMETOOLONG;
if (len >= PAGE_SIZE)
goto out;
isec = (struct inode_security_struct *)inode->i_security;
ret = security_genfs_sid("selinuxfs", page, SECCLASS_FILE, &sid);
if (ret)
goto out;
isec->sid = sid;
isec->initialized = 1;
inode->i_fop = &sel_bool_ops;
inode->i_ino = i|SEL_BOOL_INO_OFFSET;
d_add(dentry, inode);
}
bool_num = num;
bool_pending_names = names;
bool_pending_values = values;
free_page((unsigned long)page);
return 0;
out:
free_page((unsigned long)page);
if (names) {
for (i = 0; i < num; i++)
kfree(names[i]);
kfree(names);
}
kfree(values);
sel_remove_entries(dir);
return ret;
}
开发者ID:NicolFever,项目名称:Googy-Max3-Kernel-for-CM,代码行数:83,代码来源:selinuxfs.c
示例14: lzfs_zfsctl_create
void
lzfs_zfsctl_create(vfs_t *vfsp)
{
vnode_t *vp_zfsctl_dir = NULL, *vp_snap_dir = NULL;
struct dentry *zfsctl_dir_dentry = NULL, *snap_dir_dentry = NULL;
struct inode *inode_ctldir = NULL, *inode_snapdir = NULL;
timestruc_t now;
inode_ctldir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_ROOT);
ASSERT(inode_ctldir != NULL);
vp_zfsctl_dir = LZFS_ITOV(inode_ctldir);
gethrestime(&now);
ASSERT(inode_ctldir->i_state & I_NEW);
mutex_enter(&vp_zfsctl_dir->v_lock);
vp_zfsctl_dir->v_count = 1;
VN_SET_VFS_TYPE_DEV(vp_zfsctl_dir, vfsp, VDIR, 0);
bcopy(&now, &(vp_zfsctl_dir->v_inode.i_ctime),
sizeof (timestruc_t));
bcopy(&now, &(vp_zfsctl_dir->v_inode.i_atime),
sizeof (timestruc_t));
bcopy(&now,&(vp_zfsctl_dir->v_inode.i_mtime),sizeof (timestruc_t));
#ifdef HAVE_CRED_STRUCT
inode_ctldir->i_uid = current->cred->uid;
inode_ctldir->i_gid = current->cred->gid;
#else
inode_ctldir->i_uid = current->uid;
inode_ctldir->i_gid = current->gid;
#endif
inode_ctldir->i_version = 1;
inode_ctldir->i_mode |= (S_IFDIR | S_IRWXU);
inode_ctldir->i_op = &zfsctl_dir_inode_operations;
inode_ctldir->i_fop = &zfsctl_dir_file_operations;
ASSERT(vfsp);
inode_ctldir->i_sb = vfsp->vfs_super;
ASSERT(vfsp->vfs_super);
ASSERT(vfsp->vfs_super->s_root);
unlock_new_inode(inode_ctldir);
zfsctl_dir_dentry = d_alloc_name(vfsp->vfs_super->s_root,
ZFS_CTLDIR_NAME);
if (zfsctl_dir_dentry) {
d_add(zfsctl_dir_dentry, LZFS_VTOI(vp_zfsctl_dir));
vfsp->zfsctl_dir_dentry = zfsctl_dir_dentry;
} else {
goto dentry_out;
}
set_zfsvfs_ctldir(vfsp->vfs_data, vp_zfsctl_dir);
mutex_exit(&vp_zfsctl_dir->v_lock);
inode_snapdir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_SNAPDIR);
ASSERT(inode_snapdir != NULL);
ASSERT(inode_snapdir->i_state & I_NEW);
vp_snap_dir = LZFS_ITOV(inode_snapdir);
gethrestime(&now);
vfsp->vfs_snap_dir = vp_snap_dir;
mutex_enter(&vp_snap_dir->v_lock);
vp_snap_dir->v_count = 1;
VN_SET_VFS_TYPE_DEV(vp_snap_dir, vfsp, VDIR, 0);
bcopy(&now,&(vp_snap_dir->v_inode.i_ctime),sizeof (timestruc_t));
bcopy(&now,&(vp_snap_dir->v_inode.i_atime),sizeof (timestruc_t));
bcopy(&now,&(vp_snap_dir->v_inode.i_mtime),sizeof (timestruc_t));
#ifdef HAVE_CRED_STRUCT
inode_snapdir->i_uid = current->cred->uid;
inode_snapdir->i_gid = current->cred->gid;
#else
inode_snapdir->i_uid = current->uid;
inode_snapdir->i_gid = current->gid;
#endif
inode_snapdir->i_version = 1;
inode_snapdir->i_mode |= (S_IFDIR | S_IRWXU);
inode_snapdir->i_op = &snap_dir_inode_operations;
inode_snapdir->i_fop = &snap_dir_file_operations;
inode_snapdir->i_sb = vfsp->vfs_super;
unlock_new_inode(inode_snapdir);
ASSERT(zfsctl_dir_dentry);
snap_dir_dentry = d_alloc_name(zfsctl_dir_dentry, ZFS_SNAPDIR_NAME);
if (snap_dir_dentry) {
d_add(snap_dir_dentry, LZFS_VTOI(vp_snap_dir));
vfsp->snap_dir_dentry = snap_dir_dentry;
mutex_exit(&vp_snap_dir->v_lock);
} else {
goto dentry_out;
}
return;
dentry_out:
// free vnode
vn_free(vp_zfsctl_dir);
ASSERT(0 && "TODO");
}
开发者ID:glycerine,项目名称:lzfs,代码行数:87,代码来源:lzfs_snap.c
注:本文中的d_alloc_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论