aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ncpfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-22 15:11:27 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:56:57 -0400
commit76f582a8f60a94c116e0b92d07c9047410274b20 (patch)
tree2bb44b8436fe655ddc006c21414738d7ef5e54d4 /fs/ncpfs
parente72514e7adcfb2eff1cd9233d314451accaa669a (diff)
[readdir] convert ncpfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ncpfs')
-rw-r--r--fs/ncpfs/dir.c78
1 files changed, 35 insertions, 43 deletions
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 6792ce11f2bf..0e7f00298213 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -23,12 +23,12 @@
23 23
24#include "ncp_fs.h" 24#include "ncp_fs.h"
25 25
26static void ncp_read_volume_list(struct file *, void *, filldir_t, 26static void ncp_read_volume_list(struct file *, struct dir_context *,
27 struct ncp_cache_control *); 27 struct ncp_cache_control *);
28static void ncp_do_readdir(struct file *, void *, filldir_t, 28static void ncp_do_readdir(struct file *, struct dir_context *,
29 struct ncp_cache_control *); 29 struct ncp_cache_control *);
30 30
31static int ncp_readdir(struct file *, void *, filldir_t); 31static int ncp_readdir(struct file *, struct dir_context *);
32 32
33static int ncp_create(struct inode *, struct dentry *, umode_t, bool); 33static int ncp_create(struct inode *, struct dentry *, umode_t, bool);
34static struct dentry *ncp_lookup(struct inode *, struct dentry *, unsigned int); 34static struct dentry *ncp_lookup(struct inode *, struct dentry *, unsigned int);
@@ -49,7 +49,7 @@ const struct file_operations ncp_dir_operations =
49{ 49{
50 .llseek = generic_file_llseek, 50 .llseek = generic_file_llseek,
51 .read = generic_read_dir, 51 .read = generic_read_dir,
52 .readdir = ncp_readdir, 52 .iterate = ncp_readdir,
53 .unlocked_ioctl = ncp_ioctl, 53 .unlocked_ioctl = ncp_ioctl,
54#ifdef CONFIG_COMPAT 54#ifdef CONFIG_COMPAT
55 .compat_ioctl = ncp_compat_ioctl, 55 .compat_ioctl = ncp_compat_ioctl,
@@ -424,9 +424,9 @@ static time_t ncp_obtain_mtime(struct dentry *dentry)
424 return ncp_date_dos2unix(i.modifyTime, i.modifyDate); 424 return ncp_date_dos2unix(i.modifyTime, i.modifyDate);
425} 425}
426 426
427static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir) 427static int ncp_readdir(struct file *file, struct dir_context *ctx)
428{ 428{
429 struct dentry *dentry = filp->f_path.dentry; 429 struct dentry *dentry = file->f_path.dentry;
430 struct inode *inode = dentry->d_inode; 430 struct inode *inode = dentry->d_inode;
431 struct page *page = NULL; 431 struct page *page = NULL;
432 struct ncp_server *server = NCP_SERVER(inode); 432 struct ncp_server *server = NCP_SERVER(inode);
@@ -440,7 +440,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
440 440
441 DDPRINTK("ncp_readdir: reading %s/%s, pos=%d\n", 441 DDPRINTK("ncp_readdir: reading %s/%s, pos=%d\n",
442 dentry->d_parent->d_name.name, dentry->d_name.name, 442 dentry->d_parent->d_name.name, dentry->d_name.name,
443 (int) filp->f_pos); 443 (int) ctx->pos);
444 444
445 result = -EIO; 445 result = -EIO;
446 /* Do not generate '.' and '..' when server is dead. */ 446 /* Do not generate '.' and '..' when server is dead. */
@@ -448,16 +448,8 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
448 goto out; 448 goto out;
449 449
450 result = 0; 450 result = 0;
451 if (filp->f_pos == 0) { 451 if (!dir_emit_dots(file, ctx))
452 if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR)) 452 goto out;
453 goto out;
454 filp->f_pos = 1;
455 }
456 if (filp->f_pos == 1) {
457 if (filldir(dirent, "..", 2, 1, parent_ino(dentry), DT_DIR))
458 goto out;
459 filp->f_pos = 2;
460 }
461 453
462 page = grab_cache_page(&inode->i_data, 0); 454 page = grab_cache_page(&inode->i_data, 0);
463 if (!page) 455 if (!page)
@@ -469,7 +461,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
469 if (!PageUptodate(page) || !ctl.head.eof) 461 if (!PageUptodate(page) || !ctl.head.eof)
470 goto init_cache; 462 goto init_cache;
471 463
472 if (filp->f_pos == 2) { 464 if (ctx->pos == 2) {
473 if (jiffies - ctl.head.time >= NCP_MAX_AGE(server)) 465 if (jiffies - ctl.head.time >= NCP_MAX_AGE(server))
474 goto init_cache; 466 goto init_cache;
475 467
@@ -479,10 +471,10 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
479 goto init_cache; 471 goto init_cache;
480 } 472 }
481 473
482 if (filp->f_pos > ctl.head.end) 474 if (ctx->pos > ctl.head.end)
483 goto finished; 475 goto finished;
484 476
485 ctl.fpos = filp->f_pos + (NCP_DIRCACHE_START - 2); 477 ctl.fpos = ctx->pos + (NCP_DIRCACHE_START - 2);
486 ctl.ofs = ctl.fpos / NCP_DIRCACHE_SIZE; 478 ctl.ofs = ctl.fpos / NCP_DIRCACHE_SIZE;
487 ctl.idx = ctl.fpos % NCP_DIRCACHE_SIZE; 479 ctl.idx = ctl.fpos % NCP_DIRCACHE_SIZE;
488 480
@@ -497,21 +489,21 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
497 } 489 }
498 while (ctl.idx < NCP_DIRCACHE_SIZE) { 490 while (ctl.idx < NCP_DIRCACHE_SIZE) {
499 struct dentry *dent; 491 struct dentry *dent;
500 int res; 492 bool over;
501 493
502 dent = ncp_dget_fpos(ctl.cache->dentry[ctl.idx], 494 dent = ncp_dget_fpos(ctl.cache->dentry[ctl.idx],
503 dentry, filp->f_pos); 495 dentry, ctx->pos);
504 if (!dent) 496 if (!dent)
505 goto invalid_cache; 497 goto invalid_cache;
506 res = filldir(dirent, dent->d_name.name, 498 over = !dir_emit(ctx, dent->d_name.name,
507 dent->d_name.len, filp->f_pos, 499 dent->d_name.len,
508 dent->d_inode->i_ino, DT_UNKNOWN); 500 dent->d_inode->i_ino, DT_UNKNOWN);
509 dput(dent); 501 dput(dent);
510 if (res) 502 if (over)
511 goto finished; 503 goto finished;
512 filp->f_pos += 1; 504 ctx->pos += 1;
513 ctl.idx += 1; 505 ctl.idx += 1;
514 if (filp->f_pos > ctl.head.end) 506 if (ctx->pos > ctl.head.end)
515 goto finished; 507 goto finished;
516 } 508 }
517 if (ctl.page) { 509 if (ctl.page) {
@@ -548,9 +540,9 @@ init_cache:
548 ctl.valid = 1; 540 ctl.valid = 1;
549read_really: 541read_really:
550 if (ncp_is_server_root(inode)) { 542 if (ncp_is_server_root(inode)) {
551 ncp_read_volume_list(filp, dirent, filldir, &ctl); 543 ncp_read_volume_list(file, ctx, &ctl);
552 } else { 544 } else {
553 ncp_do_readdir(filp, dirent, filldir, &ctl); 545 ncp_do_readdir(file, ctx, &ctl);
554 } 546 }
555 ctl.head.end = ctl.fpos - 1; 547 ctl.head.end = ctl.fpos - 1;
556 ctl.head.eof = ctl.valid; 548 ctl.head.eof = ctl.valid;
@@ -573,11 +565,11 @@ out:
573} 565}
574 566
575static int 567static int
576ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 568ncp_fill_cache(struct file *file, struct dir_context *ctx,
577 struct ncp_cache_control *ctrl, struct ncp_entry_info *entry, 569 struct ncp_cache_control *ctrl, struct ncp_entry_info *entry,
578 int inval_childs) 570 int inval_childs)
579{ 571{
580 struct dentry *newdent, *dentry = filp->f_path.dentry; 572 struct dentry *newdent, *dentry = file->f_path.dentry;
581 struct inode *dir = dentry->d_inode; 573 struct inode *dir = dentry->d_inode;
582 struct ncp_cache_control ctl = *ctrl; 574 struct ncp_cache_control ctl = *ctrl;
583 struct qstr qname; 575 struct qstr qname;
@@ -666,15 +658,15 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
666end_advance: 658end_advance:
667 if (!valid) 659 if (!valid)
668 ctl.valid = 0; 660 ctl.valid = 0;
669 if (!ctl.filled && (ctl.fpos == filp->f_pos)) { 661 if (!ctl.filled && (ctl.fpos == ctx->pos)) {
670 if (!ino) 662 if (!ino)
671 ino = find_inode_number(dentry, &qname); 663 ino = find_inode_number(dentry, &qname);
672 if (!ino) 664 if (!ino)
673 ino = iunique(dir->i_sb, 2); 665 ino = iunique(dir->i_sb, 2);
674 ctl.filled = filldir(dirent, qname.name, qname.len, 666 ctl.filled = !dir_emit(ctx, qname.name, qname.len,
675 filp->f_pos, ino, DT_UNKNOWN); 667 ino, DT_UNKNOWN);
676 if (!ctl.filled) 668 if (!ctl.filled)
677 filp->f_pos += 1; 669 ctx->pos += 1;
678 } 670 }
679 ctl.fpos += 1; 671 ctl.fpos += 1;
680 ctl.idx += 1; 672 ctl.idx += 1;
@@ -683,10 +675,10 @@ end_advance:
683} 675}
684 676
685static void 677static void
686ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir, 678ncp_read_volume_list(struct file *file, struct dir_context *ctx,
687 struct ncp_cache_control *ctl) 679 struct ncp_cache_control *ctl)
688{ 680{
689 struct dentry *dentry = filp->f_path.dentry; 681 struct dentry *dentry = file->f_path.dentry;
690 struct inode *inode = dentry->d_inode; 682 struct inode *inode = dentry->d_inode;
691 struct ncp_server *server = NCP_SERVER(inode); 683 struct ncp_server *server = NCP_SERVER(inode);
692 struct ncp_volume_info info; 684 struct ncp_volume_info info;
@@ -694,7 +686,7 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir,
694 int i; 686 int i;
695 687
696 DPRINTK("ncp_read_volume_list: pos=%ld\n", 688 DPRINTK("ncp_read_volume_list: pos=%ld\n",
697 (unsigned long) filp->f_pos); 689 (unsigned long) ctx->pos);
698 690
699 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { 691 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) {
700 int inval_dentry; 692 int inval_dentry;
@@ -715,16 +707,16 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir,
715 } 707 }
716 inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL); 708 inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL);
717 entry.volume = entry.i.volNumber; 709 entry.volume = entry.i.volNumber;
718 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, inval_dentry)) 710 if (!ncp_fill_cache(file, ctx, ctl, &entry, inval_dentry))
719 return; 711 return;
720 } 712 }
721} 713}
722 714
723static void 715static void
724ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir, 716ncp_do_readdir(struct file *file, struct dir_context *ctx,
725 struct ncp_cache_control *ctl) 717 struct ncp_cache_control *ctl)
726{ 718{
727 struct dentry *dentry = filp->f_path.dentry; 719 struct dentry *dentry = file->f_path.dentry;
728 struct inode *dir = dentry->d_inode; 720 struct inode *dir = dentry->d_inode;
729 struct ncp_server *server = NCP_SERVER(dir); 721 struct ncp_server *server = NCP_SERVER(dir);
730 struct nw_search_sequence seq; 722 struct nw_search_sequence seq;
@@ -736,7 +728,7 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
736 728
737 DPRINTK("ncp_do_readdir: %s/%s, fpos=%ld\n", 729 DPRINTK("ncp_do_readdir: %s/%s, fpos=%ld\n",
738 dentry->d_parent->d_name.name, dentry->d_name.name, 730 dentry->d_parent->d_name.name, dentry->d_name.name,
739 (unsigned long) filp->f_pos); 731 (unsigned long) ctx->pos);
740 PPRINTK("ncp_do_readdir: init %s, volnum=%d, dirent=%u\n", 732 PPRINTK("ncp_do_readdir: init %s, volnum=%d, dirent=%u\n",
741 dentry->d_name.name, NCP_FINFO(dir)->volNumber, 733 dentry->d_name.name, NCP_FINFO(dir)->volNumber,
742 NCP_FINFO(dir)->dirEntNum); 734 NCP_FINFO(dir)->dirEntNum);
@@ -778,7 +770,7 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
778 rpl += onerpl; 770 rpl += onerpl;
779 rpls -= onerpl; 771 rpls -= onerpl;
780 entry.volume = entry.i.volNumber; 772 entry.volume = entry.i.volNumber;
781 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, 0)) 773 if (!ncp_fill_cache(file, ctx, ctl, &entry, 0))
782 break; 774 break;
783 } 775 }
784 } while (more); 776 } while (more);