linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / sysfs / dir.c
index 61c4243..cfd290d 100644 (file)
@@ -43,7 +43,6 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
 
        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;
@@ -51,32 +50,6 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
        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)
 {
@@ -129,11 +102,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
        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) {
@@ -430,9 +399,10 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
                        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;
@@ -454,7 +424,8 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
                                                 dt_type(next)) < 0)
                                        return 0;
 
-                               list_move(q, p);
+                               list_del(q);
+                               list_add(q, p);
                                p = q;
                                filp->f_pos++;
                        }
@@ -502,10 +473,14 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
        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);