提交 4deb398a 编写于 作者: A Al Viro

[readdir] convert qnx6

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 663f4dec
...@@ -65,8 +65,8 @@ static struct qnx6_long_filename *qnx6_longname(struct super_block *sb, ...@@ -65,8 +65,8 @@ static struct qnx6_long_filename *qnx6_longname(struct super_block *sb,
static int qnx6_dir_longfilename(struct inode *inode, static int qnx6_dir_longfilename(struct inode *inode,
struct qnx6_long_dir_entry *de, struct qnx6_long_dir_entry *de,
void *dirent, loff_t pos, struct dir_context *ctx,
unsigned de_inode, filldir_t filldir) unsigned de_inode)
{ {
struct qnx6_long_filename *lf; struct qnx6_long_filename *lf;
struct super_block *s = inode->i_sb; struct super_block *s = inode->i_sb;
...@@ -104,8 +104,7 @@ static int qnx6_dir_longfilename(struct inode *inode, ...@@ -104,8 +104,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
QNX6DEBUG((KERN_INFO "qnx6_readdir:%.*s inode:%u\n", QNX6DEBUG((KERN_INFO "qnx6_readdir:%.*s inode:%u\n",
lf_size, lf->lf_fname, de_inode)); lf_size, lf->lf_fname, de_inode));
if (filldir(dirent, lf->lf_fname, lf_size, pos, de_inode, if (!dir_emit(ctx, lf->lf_fname, lf_size, de_inode, DT_UNKNOWN)) {
DT_UNKNOWN) < 0) {
qnx6_put_page(page); qnx6_put_page(page);
return 0; return 0;
} }
...@@ -115,18 +114,19 @@ static int qnx6_dir_longfilename(struct inode *inode, ...@@ -115,18 +114,19 @@ static int qnx6_dir_longfilename(struct inode *inode,
return 1; return 1;
} }
static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) static int qnx6_readdir(struct file *file, struct dir_context *ctx)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(file);
struct super_block *s = inode->i_sb; struct super_block *s = inode->i_sb;
struct qnx6_sb_info *sbi = QNX6_SB(s); struct qnx6_sb_info *sbi = QNX6_SB(s);
loff_t pos = filp->f_pos & ~(QNX6_DIR_ENTRY_SIZE - 1); loff_t pos = ctx->pos & ~(QNX6_DIR_ENTRY_SIZE - 1);
unsigned long npages = dir_pages(inode); unsigned long npages = dir_pages(inode);
unsigned long n = pos >> PAGE_CACHE_SHIFT; unsigned long n = pos >> PAGE_CACHE_SHIFT;
unsigned start = (pos & ~PAGE_CACHE_MASK) / QNX6_DIR_ENTRY_SIZE; unsigned start = (pos & ~PAGE_CACHE_MASK) / QNX6_DIR_ENTRY_SIZE;
bool done = false; bool done = false;
if (filp->f_pos >= inode->i_size) ctx->pos = pos;
if (ctx->pos >= inode->i_size)
return 0; return 0;
for ( ; !done && n < npages; n++, start = 0) { for ( ; !done && n < npages; n++, start = 0) {
...@@ -137,11 +137,11 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -137,11 +137,11 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (IS_ERR(page)) { if (IS_ERR(page)) {
printk(KERN_ERR "qnx6_readdir: read failed\n"); printk(KERN_ERR "qnx6_readdir: read failed\n");
filp->f_pos = (n + 1) << PAGE_CACHE_SHIFT; ctx->pos = (n + 1) << PAGE_CACHE_SHIFT;
return PTR_ERR(page); return PTR_ERR(page);
} }
de = ((struct qnx6_dir_entry *)page_address(page)) + start; de = ((struct qnx6_dir_entry *)page_address(page)) + start;
for (; i < limit; i++, de++, pos += QNX6_DIR_ENTRY_SIZE) { for (; i < limit; i++, de++, ctx->pos += QNX6_DIR_ENTRY_SIZE) {
int size = de->de_size; int size = de->de_size;
u32 no_inode = fs32_to_cpu(sbi, de->de_inode); u32 no_inode = fs32_to_cpu(sbi, de->de_inode);
...@@ -154,8 +154,7 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -154,8 +154,7 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir)
structure / block */ structure / block */
if (!qnx6_dir_longfilename(inode, if (!qnx6_dir_longfilename(inode,
(struct qnx6_long_dir_entry *)de, (struct qnx6_long_dir_entry *)de,
dirent, pos, no_inode, ctx, no_inode)) {
filldir)) {
done = true; done = true;
break; break;
} }
...@@ -163,9 +162,8 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -163,9 +162,8 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir)
QNX6DEBUG((KERN_INFO "qnx6_readdir:%.*s" QNX6DEBUG((KERN_INFO "qnx6_readdir:%.*s"
" inode:%u\n", size, de->de_fname, " inode:%u\n", size, de->de_fname,
no_inode)); no_inode));
if (filldir(dirent, de->de_fname, size, if (!dir_emit(ctx, de->de_fname, size,
pos, no_inode, DT_UNKNOWN) no_inode, DT_UNKNOWN)) {
< 0) {
done = true; done = true;
break; break;
} }
...@@ -173,7 +171,6 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -173,7 +171,6 @@ static int qnx6_readdir(struct file *filp, void *dirent, filldir_t filldir)
} }
qnx6_put_page(page); qnx6_put_page(page);
} }
filp->f_pos = pos;
return 0; return 0;
} }
...@@ -282,7 +279,7 @@ unsigned qnx6_find_entry(int len, struct inode *dir, const char *name, ...@@ -282,7 +279,7 @@ unsigned qnx6_find_entry(int len, struct inode *dir, const char *name,
const struct file_operations qnx6_dir_operations = { const struct file_operations qnx6_dir_operations = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = qnx6_readdir, .iterate = qnx6_readdir,
.fsync = generic_file_fsync, .fsync = generic_file_fsync,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册