@@ -3329,6 +3329,15 @@ static loff_t shmem_dir_llseek(struct file *file, loff_t offset, int whence)
return offset;
}
+static bool shmem_dir_emit(struct dir_context *ctx, struct dentry *dentry)
+{
+ struct inode *inode = d_inode(dentry);
+
+ return ctx->actor(ctx, dentry->d_name.name, dentry->d_name.len,
+ ctx->pos, inode->i_ino,
+ fs_umode_to_dtype(inode->i_mode));
+}
+
/**
* shmem_readdir - Emit entries starting at offset @ctx->pos
* @file: an open directory to iterate over
@@ -3369,9 +3378,7 @@ static int shmem_readdir(struct file *file, struct dir_context *ctx)
return 0;
while ((next = scan_positives(cursor, p, 1, next)) != NULL) {
- if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
- d_inode(next)->i_ino,
- fs_umode_to_dtype(d_inode(next)->i_mode)))
+ if (!shmem_dir_emit(ctx, dentry))
break;
ctx->pos++;
p = &next->d_child;