memset(sd, 0, sizeof(*sd));
atomic_set(&sd->s_count, 1);
- atomic_set(&sd->s_event, 0);
INIT_LIST_HEAD(&sd->s_children);
list_add(&sd->s_sibling, &parent_sd->s_children);
sd->s_element = element;
return sd;
}
-/*
- *
- * Return -EEXIST if there is already a sysfs element with the same name for
- * the same parent.
- *
- * called with parent inode's i_mutex held
- */
-int sysfs_dirent_exist(struct sysfs_dirent *parent_sd,
- const unsigned char *new)
-{
- struct sysfs_dirent * sd;
-
- list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
- if (sd->s_element) {
- const unsigned char *existing = sysfs_get_name(sd);
- if (strcmp(existing, new))
- continue;
- else
- return -EEXIST;
- }
- }
-
- return 0;
-}
-
-
int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry,
void * element, umode_t mode, int type)
{
mutex_lock(&p->d_inode->i_mutex);
*d = lookup_one_len(n, p, strlen(n));
if (!IS_ERR(*d)) {
- if (sysfs_dirent_exist(p->d_fsdata, n))
- error = -EEXIST;
- else
- error = sysfs_make_dirent(p->d_fsdata, *d, k, mode,
- SYSFS_DIR);
+ error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
if (!error) {
error = sysfs_create(*d, mode, init_dir);
if (!error) {
i++;
/* fallthrough */
default:
- if (filp->f_pos == 2)
- list_move(q, &parent_sd->s_children);
-
+ if (filp->f_pos == 2) {
+ list_del(q);
+ list_add(q, &parent_sd->s_children);
+ }
for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
struct sysfs_dirent *next;
const char * name;
dt_type(next)) < 0)
return 0;
- list_move(q, p);
+ list_del(q);
+ list_add(q, p);
p = q;
filp->f_pos++;
}
return offset;
}
-const struct file_operations sysfs_dir_operations = {
+struct file_operations sysfs_dir_operations = {
.open = sysfs_dir_open,
.release = sysfs_dir_close,
.llseek = sysfs_dir_lseek,
.read = generic_read_dir,
.readdir = sysfs_readdir,
};
+
+EXPORT_SYMBOL_GPL(sysfs_create_dir);
+EXPORT_SYMBOL_GPL(sysfs_remove_dir);
+EXPORT_SYMBOL_GPL(sysfs_rename_dir);