···15321532 return (sd->s_mode >> 12) & 15;15331533}1534153415351535-static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir)15351535+static int configfs_readdir(struct file *file, struct dir_context *ctx)15361536{15371537- struct dentry *dentry = filp->f_path.dentry;15371537+ struct dentry *dentry = file->f_path.dentry;15381538 struct super_block *sb = dentry->d_sb;15391539 struct configfs_dirent * parent_sd = dentry->d_fsdata;15401540- struct configfs_dirent *cursor = filp->private_data;15401540+ struct configfs_dirent *cursor = file->private_data;15411541 struct list_head *p, *q = &cursor->s_sibling;15421542 ino_t ino = 0;15431543- int i = filp->f_pos;1544154315451545- switch (i) {15461546- case 0:15471547- ino = dentry->d_inode->i_ino;15481548- if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)15491549- break;15501550- filp->f_pos++;15511551- i++;15521552- /* fallthrough */15531553- case 1:15541554- ino = parent_ino(dentry);15551555- if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)15561556- break;15571557- filp->f_pos++;15581558- i++;15591559- /* fallthrough */15601560- default:15611561- if (filp->f_pos == 2) {15621562- spin_lock(&configfs_dirent_lock);15631563- list_move(q, &parent_sd->s_children);15641564- spin_unlock(&configfs_dirent_lock);15651565- }15661566- for (p=q->next; p!= &parent_sd->s_children; p=p->next) {15671567- struct configfs_dirent *next;15681568- const char * name;15691569- int len;15701570- struct inode *inode = NULL;15441544+ if (!dir_emit_dots(file, ctx))15451545+ return 0;15461546+ if (ctx->pos == 2) {15471547+ spin_lock(&configfs_dirent_lock);15481548+ list_move(q, &parent_sd->s_children);15491549+ spin_unlock(&configfs_dirent_lock);15501550+ }15511551+ for (p = q->next; p != &parent_sd->s_children; p = p->next) {15521552+ struct configfs_dirent *next;15531553+ const char *name;15541554+ int len;15551555+ struct inode *inode = NULL;1571155615721572- next = list_entry(p, struct configfs_dirent,15731573- s_sibling);15741574- if (!next->s_element)15751575- continue;15571557+ next = list_entry(p, struct configfs_dirent, s_sibling);15581558+ if (!next->s_element)15591559+ continue;1576156015771577- name = configfs_get_name(next);15781578- len = strlen(name);15611561+ name = configfs_get_name(next);15621562+ len = strlen(name);1579156315801580- /*15811581- * We'll have a dentry and an inode for15821582- * PINNED items and for open attribute15831583- * files. We lock here to prevent a race15841584- * with configfs_d_iput() clearing15851585- * s_dentry before calling iput().15861586- *15871587- * Why do we go to the trouble? If15881588- * someone has an attribute file open,15891589- * the inode number should match until15901590- * they close it. Beyond that, we don't15911591- * care.15921592- */15931593- spin_lock(&configfs_dirent_lock);15941594- dentry = next->s_dentry;15951595- if (dentry)15961596- inode = dentry->d_inode;15971597- if (inode)15981598- ino = inode->i_ino;15991599- spin_unlock(&configfs_dirent_lock);16001600- if (!inode)16011601- ino = iunique(sb, 2);15641564+ /*15651565+ * We'll have a dentry and an inode for15661566+ * PINNED items and for open attribute15671567+ * files. We lock here to prevent a race15681568+ * with configfs_d_iput() clearing15691569+ * s_dentry before calling iput().15701570+ *15711571+ * Why do we go to the trouble? If15721572+ * someone has an attribute file open,15731573+ * the inode number should match until15741574+ * they close it. Beyond that, we don't15751575+ * care.15761576+ */15771577+ spin_lock(&configfs_dirent_lock);15781578+ dentry = next->s_dentry;15791579+ if (dentry)15801580+ inode = dentry->d_inode;15811581+ if (inode)15821582+ ino = inode->i_ino;15831583+ spin_unlock(&configfs_dirent_lock);15841584+ if (!inode)15851585+ ino = iunique(sb, 2);1602158616031603- if (filldir(dirent, name, len, filp->f_pos, ino,16041604- dt_type(next)) < 0)16051605- return 0;15871587+ if (!dir_emit(ctx, name, len, ino, dt_type(next)))15881588+ return 0;1606158916071607- spin_lock(&configfs_dirent_lock);16081608- list_move(q, p);16091609- spin_unlock(&configfs_dirent_lock);16101610- p = q;16111611- filp->f_pos++;16121612- }15901590+ spin_lock(&configfs_dirent_lock);15911591+ list_move(q, p);15921592+ spin_unlock(&configfs_dirent_lock);15931593+ p = q;15941594+ ctx->pos++;16131595 }16141596 return 0;16151597}···16431661 .release = configfs_dir_close,16441662 .llseek = configfs_dir_lseek,16451663 .read = generic_read_dir,16461646- .readdir = configfs_readdir,16641664+ .iterate = configfs_readdir,16471665};1648166616491667int configfs_register_subsystem(struct configfs_subsystem *subsys)