コード例 #1
0
/**
 *	sysfs_create_link - create symlink between two objects.
 *	@kobj:	object whose directory we're creating the link in.
 *	@target:	object we're pointing to.
 *	@name:		name of the symlink.
 */
int sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name)
{
	struct dentry * dentry = kobj->dentry;
	int error = -EEXIST;

	BUG_ON(!kobj || !kobj->dentry || !name);

	down(&dentry->d_inode->i_sem);
	if (!sysfs_dirent_exist(dentry->d_fsdata, name))
		error = sysfs_add_link(dentry, name, target);
	up(&dentry->d_inode->i_sem);
	return error;
}
コード例 #2
0
ファイル: file.c プロジェクト: Voskrese/mipsonqemu
int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
{
	struct sysfs_dirent * parent_sd = dir->d_fsdata;
	umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
	int error = -EEXIST;

	mutex_lock(&dir->d_inode->i_mutex);
	if (!sysfs_dirent_exist(parent_sd, attr->name))
		error = sysfs_make_dirent(parent_sd, NULL, (void *)attr,
					  mode, type);
	mutex_unlock(&dir->d_inode->i_mutex);

	return error;
}