2 * dir.c - Operations for sysfs directories.
8 #include <linux/mount.h>
9 #include <linux/module.h>
10 #include <linux/kobject.h>
11 #include <linux/namei.h>
12 #include <linux/idr.h>
13 #include <linux/completion.h>
14 #include <asm/semaphore.h>
17 DEFINE_MUTEX(sysfs_mutex);
18 spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
20 static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
21 static DEFINE_IDA(sysfs_ino_ida);
24 * sysfs_link_sibling - link sysfs_dirent into sibling list
25 * @sd: sysfs_dirent of interest
27 * Link @sd into its sibling list which starts from
28 * sd->s_parent->s_children.
31 * mutex_lock(sysfs_mutex)
33 static void sysfs_link_sibling(struct sysfs_dirent *sd)
35 struct sysfs_dirent *parent_sd = sd->s_parent;
37 BUG_ON(sd->s_sibling);
38 sd->s_sibling = parent_sd->s_children;
39 parent_sd->s_children = sd;
43 * sysfs_unlink_sibling - unlink sysfs_dirent from sibling list
44 * @sd: sysfs_dirent of interest
46 * Unlink @sd from its sibling list which starts from
47 * sd->s_parent->s_children.
50 * mutex_lock(sysfs_mutex)
52 static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
54 struct sysfs_dirent **pos;
56 for (pos = &sd->s_parent->s_children; *pos; pos = &(*pos)->s_sibling) {
66 * sysfs_get_active - get an active reference to sysfs_dirent
67 * @sd: sysfs_dirent to get an active reference to
69 * Get an active reference of @sd. This function is noop if @sd
73 * Pointer to @sd on success, NULL on failure.
75 struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
83 v = atomic_read(&sd->s_active);
87 t = atomic_cmpxchg(&sd->s_active, v, v + 1);
98 * sysfs_put_active - put an active reference to sysfs_dirent
99 * @sd: sysfs_dirent to put an active reference to
101 * Put an active reference to @sd. This function is noop if @sd
104 void sysfs_put_active(struct sysfs_dirent *sd)
106 struct completion *cmpl;
112 v = atomic_dec_return(&sd->s_active);
113 if (likely(v != SD_DEACTIVATED_BIAS))
116 /* atomic_dec_return() is a mb(), we'll always see the updated
119 cmpl = (void *)sd->s_sibling;
124 * sysfs_get_active_two - get active references to sysfs_dirent and parent
125 * @sd: sysfs_dirent of interest
127 * Get active reference to @sd and its parent. Parent's active
128 * reference is grabbed first. This function is noop if @sd is
132 * Pointer to @sd on success, NULL on failure.
134 struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd)
137 if (sd->s_parent && unlikely(!sysfs_get_active(sd->s_parent)))
139 if (unlikely(!sysfs_get_active(sd))) {
140 sysfs_put_active(sd->s_parent);
148 * sysfs_put_active_two - put active references to sysfs_dirent and parent
149 * @sd: sysfs_dirent of interest
151 * Put active references to @sd and its parent. This function is
152 * noop if @sd is NULL.
154 void sysfs_put_active_two(struct sysfs_dirent *sd)
157 sysfs_put_active(sd);
158 sysfs_put_active(sd->s_parent);
163 * sysfs_deactivate - deactivate sysfs_dirent
164 * @sd: sysfs_dirent to deactivate
166 * Deny new active references and drain existing ones.
168 void sysfs_deactivate(struct sysfs_dirent *sd)
170 DECLARE_COMPLETION_ONSTACK(wait);
173 BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED));
174 sd->s_sibling = (void *)&wait;
176 /* atomic_add_return() is a mb(), put_active() will always see
177 * the updated sd->s_sibling.
179 v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active);
181 if (v != SD_DEACTIVATED_BIAS)
182 wait_for_completion(&wait);
184 sd->s_sibling = NULL;
187 static int sysfs_alloc_ino(ino_t *pino)
192 spin_lock(&sysfs_ino_lock);
193 rc = ida_get_new_above(&sysfs_ino_ida, 2, &ino);
194 spin_unlock(&sysfs_ino_lock);
197 if (ida_pre_get(&sysfs_ino_ida, GFP_KERNEL))
206 static void sysfs_free_ino(ino_t ino)
208 spin_lock(&sysfs_ino_lock);
209 ida_remove(&sysfs_ino_ida, ino);
210 spin_unlock(&sysfs_ino_lock);
213 void release_sysfs_dirent(struct sysfs_dirent * sd)
215 struct sysfs_dirent *parent_sd;
218 /* Moving/renaming is always done while holding reference.
219 * sd->s_parent won't change beneath us.
221 parent_sd = sd->s_parent;
223 if (sysfs_type(sd) == SYSFS_KOBJ_LINK)
224 sysfs_put(sd->s_elem.symlink.target_sd);
225 if (sysfs_type(sd) & SYSFS_COPY_NAME)
228 sysfs_free_ino(sd->s_ino);
229 kmem_cache_free(sysfs_dir_cachep, sd);
232 if (sd && atomic_dec_and_test(&sd->s_count))
236 static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
238 struct sysfs_dirent * sd = dentry->d_fsdata;
241 /* sd->s_dentry is protected with sysfs_assoc_lock.
242 * This allows sysfs_drop_dentry() to dereference it.
244 spin_lock(&sysfs_assoc_lock);
246 /* The dentry might have been deleted or another
247 * lookup could have happened updating sd->s_dentry to
248 * point the new dentry. Ignore if it isn't pointing
251 if (sd->s_dentry == dentry)
253 spin_unlock(&sysfs_assoc_lock);
259 static struct dentry_operations sysfs_dentry_ops = {
260 .d_iput = sysfs_d_iput,
263 struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
265 char *dup_name = NULL;
266 struct sysfs_dirent *sd = NULL;
268 if (type & SYSFS_COPY_NAME) {
269 name = dup_name = kstrdup(name, GFP_KERNEL);
274 sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
278 if (sysfs_alloc_ino(&sd->s_ino))
281 atomic_set(&sd->s_count, 1);
282 atomic_set(&sd->s_active, 0);
283 atomic_set(&sd->s_event, 1);
293 kmem_cache_free(sysfs_dir_cachep, sd);
298 * sysfs_attach_dentry - associate sysfs_dirent with dentry
299 * @sd: target sysfs_dirent
300 * @dentry: dentry to associate
302 * Associate @sd with @dentry. This is protected by
303 * sysfs_assoc_lock to avoid race with sysfs_d_iput().
306 * mutex_lock(sysfs_mutex)
308 static void sysfs_attach_dentry(struct sysfs_dirent *sd, struct dentry *dentry)
310 dentry->d_op = &sysfs_dentry_ops;
311 dentry->d_fsdata = sysfs_get(sd);
313 /* protect sd->s_dentry against sysfs_d_iput */
314 spin_lock(&sysfs_assoc_lock);
315 sd->s_dentry = dentry;
316 spin_unlock(&sysfs_assoc_lock);
322 * sysfs_attach_dirent - attach sysfs_dirent to its parent and dentry
323 * @sd: sysfs_dirent to attach
324 * @parent_sd: parent to attach to (optional)
325 * @dentry: dentry to be associated to @sd (optional)
327 * Attach @sd to @parent_sd and/or @dentry. Both are optional.
330 * mutex_lock(sysfs_mutex)
332 void sysfs_attach_dirent(struct sysfs_dirent *sd,
333 struct sysfs_dirent *parent_sd, struct dentry *dentry)
336 sysfs_attach_dentry(sd, dentry);
339 sd->s_parent = sysfs_get(parent_sd);
340 sysfs_link_sibling(sd);
345 * sysfs_find_dirent - find sysfs_dirent with the given name
346 * @parent_sd: sysfs_dirent to search under
347 * @name: name to look for
349 * Look for sysfs_dirent with name @name under @parent_sd.
352 * mutex_lock(sysfs_mutex)
355 * Pointer to sysfs_dirent if found, NULL if not.
357 struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
358 const unsigned char *name)
360 struct sysfs_dirent *sd;
362 for (sd = parent_sd->s_children; sd; sd = sd->s_sibling)
363 if (sysfs_type(sd) && !strcmp(sd->s_name, name))
369 * sysfs_get_dirent - find and get sysfs_dirent with the given name
370 * @parent_sd: sysfs_dirent to search under
371 * @name: name to look for
373 * Look for sysfs_dirent with name @name under @parent_sd and get
377 * Kernel thread context (may sleep). Grabs sysfs_mutex.
380 * Pointer to sysfs_dirent if found, NULL if not.
382 struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
383 const unsigned char *name)
385 struct sysfs_dirent *sd;
387 mutex_lock(&sysfs_mutex);
388 sd = sysfs_find_dirent(parent_sd, name);
390 mutex_unlock(&sysfs_mutex);
395 static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
396 const char *name, struct sysfs_dirent **p_sd)
398 struct dentry *parent = parent_sd->s_dentry;
400 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
401 struct dentry *dentry;
403 struct sysfs_dirent *sd;
405 mutex_lock(&parent->d_inode->i_mutex);
408 dentry = lookup_one_len(name, parent, strlen(name));
409 if (IS_ERR(dentry)) {
410 error = PTR_ERR(dentry);
419 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
422 sd->s_elem.dir.kobj = kobj;
424 inode = sysfs_get_inode(sd);
428 if (inode->i_state & I_NEW) {
429 inode->i_op = &sysfs_dir_inode_operations;
430 inode->i_fop = &sysfs_dir_operations;
431 /* directory inodes start off with i_nlink == 2 (for ".") */
436 mutex_lock(&sysfs_mutex);
439 if (sysfs_find_dirent(parent_sd, name)) {
440 mutex_unlock(&sysfs_mutex);
444 sysfs_instantiate(dentry, inode);
445 inc_nlink(parent->d_inode);
446 sysfs_attach_dirent(sd, parent_sd, dentry);
448 mutex_unlock(&sysfs_mutex);
452 goto out_unlock; /* pin directory dentry in core */
463 mutex_unlock(&parent->d_inode->i_mutex);
467 int sysfs_create_subdir(struct kobject *kobj, const char *name,
468 struct sysfs_dirent **p_sd)
470 return create_dir(kobj, kobj->sd, name, p_sd);
474 * sysfs_create_dir - create a directory for an object.
475 * @kobj: object we're creating directory for.
476 * @shadow_parent: parent object.
478 int sysfs_create_dir(struct kobject *kobj,
479 struct sysfs_dirent *shadow_parent_sd)
481 struct sysfs_dirent *parent_sd, *sd;
486 if (shadow_parent_sd)
487 parent_sd = shadow_parent_sd;
488 else if (kobj->parent)
489 parent_sd = kobj->parent->sd;
490 else if (sysfs_mount && sysfs_mount->mnt_sb)
491 parent_sd = sysfs_mount->mnt_sb->s_root->d_fsdata;
495 error = create_dir(kobj, parent_sd, kobject_name(kobj), &sd);
501 static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
502 struct nameidata *nd)
504 struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata;
505 struct sysfs_dirent * sd;
506 struct bin_attribute *bin_attr;
510 for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) {
511 if ((sysfs_type(sd) & SYSFS_NOT_PINNED) &&
512 !strcmp(sd->s_name, dentry->d_name.name)) {
522 /* attach dentry and inode */
523 inode = sysfs_get_inode(sd);
525 return ERR_PTR(-ENOMEM);
527 mutex_lock(&sysfs_mutex);
529 if (inode->i_state & I_NEW) {
530 /* initialize inode according to type */
531 switch (sysfs_type(sd)) {
532 case SYSFS_KOBJ_ATTR:
533 inode->i_size = PAGE_SIZE;
534 inode->i_fop = &sysfs_file_operations;
536 case SYSFS_KOBJ_BIN_ATTR:
537 bin_attr = sd->s_elem.bin_attr.bin_attr;
538 inode->i_size = bin_attr->size;
539 inode->i_fop = &bin_fops;
541 case SYSFS_KOBJ_LINK:
542 inode->i_op = &sysfs_symlink_inode_operations;
549 sysfs_instantiate(dentry, inode);
550 sysfs_attach_dentry(sd, dentry);
552 mutex_unlock(&sysfs_mutex);
557 const struct inode_operations sysfs_dir_inode_operations = {
558 .lookup = sysfs_lookup,
559 .setattr = sysfs_setattr,
562 static void remove_dir(struct sysfs_dirent *sd)
564 mutex_lock(&sysfs_mutex);
565 sysfs_unlink_sibling(sd);
566 sd->s_flags |= SYSFS_FLAG_REMOVED;
567 mutex_unlock(&sysfs_mutex);
569 pr_debug(" o %s removing done\n", sd->s_name);
571 sysfs_drop_dentry(sd);
572 sysfs_deactivate(sd);
576 void sysfs_remove_subdir(struct sysfs_dirent *sd)
582 static void __sysfs_remove_dir(struct sysfs_dirent *dir_sd)
584 struct sysfs_dirent *removed = NULL;
585 struct sysfs_dirent **pos;
590 pr_debug("sysfs %s: removing dir\n", dir_sd->s_name);
591 mutex_lock(&sysfs_mutex);
592 pos = &dir_sd->s_children;
594 struct sysfs_dirent *sd = *pos;
596 if (sysfs_type(sd) && (sysfs_type(sd) & SYSFS_NOT_PINNED)) {
597 sd->s_flags |= SYSFS_FLAG_REMOVED;
598 *pos = sd->s_sibling;
599 sd->s_sibling = removed;
602 pos = &(*pos)->s_sibling;
604 mutex_unlock(&sysfs_mutex);
607 struct sysfs_dirent *sd = removed;
609 removed = sd->s_sibling;
610 sd->s_sibling = NULL;
612 sysfs_drop_dentry(sd);
613 sysfs_deactivate(sd);
621 * sysfs_remove_dir - remove an object's directory.
624 * The only thing special about this is that we remove any files in
625 * the directory before we remove the directory, and we've inlined
626 * what used to be sysfs_rmdir() below, instead of calling separately.
629 void sysfs_remove_dir(struct kobject * kobj)
631 struct sysfs_dirent *sd = kobj->sd;
633 spin_lock(&sysfs_assoc_lock);
635 spin_unlock(&sysfs_assoc_lock);
637 __sysfs_remove_dir(sd);
640 int sysfs_rename_dir(struct kobject *kobj, struct sysfs_dirent *new_parent_sd,
641 const char *new_name)
643 struct sysfs_dirent *sd = kobj->sd;
644 struct dentry *new_parent = new_parent_sd->s_dentry;
645 struct dentry *new_dentry;
652 mutex_lock(&new_parent->d_inode->i_mutex);
654 new_dentry = lookup_one_len(new_name, new_parent, strlen(new_name));
655 if (IS_ERR(new_dentry)) {
656 error = PTR_ERR(new_dentry);
660 /* By allowing two different directories with the same
661 * d_parent we allow this routine to move between different
662 * shadows of the same directory
665 if (sd->s_parent->s_dentry->d_inode != new_parent->d_inode ||
666 new_dentry->d_parent->d_inode != new_parent->d_inode ||
667 new_dentry == sd->s_dentry)
671 if (new_dentry->d_inode)
674 /* rename kobject and sysfs_dirent */
676 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
680 error = kobject_set_name(kobj, "%s", new_name);
685 sd->s_name = new_name;
687 /* move under the new parent */
688 d_add(new_dentry, NULL);
689 d_move(sd->s_dentry, new_dentry);
691 mutex_lock(&sysfs_mutex);
693 sysfs_unlink_sibling(sd);
694 sysfs_get(new_parent_sd);
695 sysfs_put(sd->s_parent);
696 sd->s_parent = new_parent_sd;
697 sysfs_link_sibling(sd);
699 mutex_unlock(&sysfs_mutex);
711 mutex_unlock(&new_parent->d_inode->i_mutex);
715 int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent)
717 struct dentry *old_parent_dentry, *new_parent_dentry, *new_dentry;
718 struct sysfs_dirent *new_parent_sd, *sd;
721 old_parent_dentry = kobj->parent ?
722 kobj->parent->sd->s_dentry : sysfs_mount->mnt_sb->s_root;
723 new_parent_dentry = new_parent ?
724 new_parent->sd->s_dentry : sysfs_mount->mnt_sb->s_root;
726 if (old_parent_dentry->d_inode == new_parent_dentry->d_inode)
727 return 0; /* nothing to move */
729 mutex_lock(&old_parent_dentry->d_inode->i_mutex);
730 if (!mutex_trylock(&new_parent_dentry->d_inode->i_mutex)) {
731 mutex_unlock(&old_parent_dentry->d_inode->i_mutex);
735 new_parent_sd = new_parent_dentry->d_fsdata;
738 new_dentry = lookup_one_len(kobj->name, new_parent_dentry,
740 if (IS_ERR(new_dentry)) {
741 error = PTR_ERR(new_dentry);
745 d_add(new_dentry, NULL);
746 d_move(sd->s_dentry, new_dentry);
749 /* Remove from old parent's list and insert into new parent's list. */
750 mutex_lock(&sysfs_mutex);
752 sysfs_unlink_sibling(sd);
753 sysfs_get(new_parent_sd);
754 sysfs_put(sd->s_parent);
755 sd->s_parent = new_parent_sd;
756 sysfs_link_sibling(sd);
758 mutex_unlock(&sysfs_mutex);
760 mutex_unlock(&new_parent_dentry->d_inode->i_mutex);
761 mutex_unlock(&old_parent_dentry->d_inode->i_mutex);
766 static int sysfs_dir_open(struct inode *inode, struct file *file)
768 struct dentry * dentry = file->f_path.dentry;
769 struct sysfs_dirent * parent_sd = dentry->d_fsdata;
770 struct sysfs_dirent * sd;
772 sd = sysfs_new_dirent("_DIR_", 0, 0);
774 mutex_lock(&sysfs_mutex);
775 sysfs_attach_dirent(sd, parent_sd, NULL);
776 mutex_unlock(&sysfs_mutex);
779 file->private_data = sd;
780 return sd ? 0 : -ENOMEM;
783 static int sysfs_dir_close(struct inode *inode, struct file *file)
785 struct sysfs_dirent * cursor = file->private_data;
787 mutex_lock(&sysfs_mutex);
788 sysfs_unlink_sibling(cursor);
789 mutex_unlock(&sysfs_mutex);
791 release_sysfs_dirent(cursor);
796 /* Relationship between s_mode and the DT_xxx types */
797 static inline unsigned char dt_type(struct sysfs_dirent *sd)
799 return (sd->s_mode >> 12) & 15;
802 static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
804 struct dentry *dentry = filp->f_path.dentry;
805 struct sysfs_dirent * parent_sd = dentry->d_fsdata;
806 struct sysfs_dirent *cursor = filp->private_data;
807 struct sysfs_dirent **pos;
813 ino = parent_sd->s_ino;
814 if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
820 if (parent_sd->s_parent)
821 ino = parent_sd->s_parent->s_ino;
823 ino = parent_sd->s_ino;
824 if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
830 mutex_lock(&sysfs_mutex);
832 pos = &parent_sd->s_children;
833 while (*pos != cursor)
834 pos = &(*pos)->s_sibling;
837 *pos = cursor->s_sibling;
839 if (filp->f_pos == 2)
840 pos = &parent_sd->s_children;
842 for ( ; *pos; pos = &(*pos)->s_sibling) {
843 struct sysfs_dirent *next = *pos;
847 if (!sysfs_type(next))
854 if (filldir(dirent, name, len, filp->f_pos, ino,
861 /* put cursor back in */
862 cursor->s_sibling = *pos;
865 mutex_unlock(&sysfs_mutex);
870 static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
872 struct dentry * dentry = file->f_path.dentry;
876 offset += file->f_pos;
883 if (offset != file->f_pos) {
884 mutex_lock(&sysfs_mutex);
886 file->f_pos = offset;
887 if (file->f_pos >= 2) {
888 struct sysfs_dirent *sd = dentry->d_fsdata;
889 struct sysfs_dirent *cursor = file->private_data;
890 struct sysfs_dirent **pos;
891 loff_t n = file->f_pos - 2;
893 sysfs_unlink_sibling(cursor);
895 pos = &sd->s_children;
897 struct sysfs_dirent *next = *pos;
898 if (sysfs_type(next))
900 pos = &(*pos)->s_sibling;
903 cursor->s_sibling = *pos;
907 mutex_unlock(&sysfs_mutex);
915 * sysfs_make_shadowed_dir - Setup so a directory can be shadowed
916 * @kobj: object we're creating shadow of.
919 int sysfs_make_shadowed_dir(struct kobject *kobj,
920 void * (*follow_link)(struct dentry *, struct nameidata *))
923 struct inode_operations *i_op;
925 inode = kobj->sd->s_dentry->d_inode;
926 if (inode->i_op != &sysfs_dir_inode_operations)
929 i_op = kmalloc(sizeof(*i_op), GFP_KERNEL);
933 memcpy(i_op, &sysfs_dir_inode_operations, sizeof(*i_op));
934 i_op->follow_link = follow_link;
936 /* Locking of inode->i_op?
937 * Since setting i_op is a single word write and they
938 * are atomic we should be ok here.
945 * sysfs_create_shadow_dir - create a shadow directory for an object.
946 * @kobj: object we're creating directory for.
948 * sysfs_make_shadowed_dir must already have been called on this
952 struct sysfs_dirent *sysfs_create_shadow_dir(struct kobject *kobj)
954 struct dentry *dir = kobj->sd->s_dentry;
955 struct inode *inode = dir->d_inode;
956 struct dentry *parent = dir->d_parent;
957 struct sysfs_dirent *parent_sd = parent->d_fsdata;
958 struct dentry *shadow;
959 struct sysfs_dirent *sd;
961 sd = ERR_PTR(-EINVAL);
962 if (!sysfs_is_shadowed_inode(inode))
965 shadow = d_alloc(parent, &dir->d_name);
969 sd = sysfs_new_dirent("_SHADOW_", inode->i_mode, SYSFS_DIR);
972 sd->s_elem.dir.kobj = kobj;
973 /* point to parent_sd but don't attach to it */
974 sd->s_parent = sysfs_get(parent_sd);
975 mutex_lock(&sysfs_mutex);
976 sysfs_attach_dirent(sd, NULL, shadow);
977 mutex_unlock(&sysfs_mutex);
979 d_instantiate(shadow, igrab(inode));
981 inc_nlink(parent->d_inode);
983 dget(shadow); /* Extra count - pin the dentry in core */
989 sd = ERR_PTR(-ENOMEM);
994 * sysfs_remove_shadow_dir - remove an object's directory.
995 * @shadow_sd: sysfs_dirent of shadow directory
997 * The only thing special about this is that we remove any files in
998 * the directory before we remove the directory, and we've inlined
999 * what used to be sysfs_rmdir() below, instead of calling separately.
1002 void sysfs_remove_shadow_dir(struct sysfs_dirent *shadow_sd)
1004 __sysfs_remove_dir(shadow_sd);
1007 const struct file_operations sysfs_dir_operations = {
1008 .open = sysfs_dir_open,
1009 .release = sysfs_dir_close,
1010 .llseek = sysfs_dir_lseek,
1011 .read = generic_read_dir,
1012 .readdir = sysfs_readdir,