Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rpc_pipe: saner primitive for creating regular files

rpc_new_file(); similar to rpc_new_dir(), except that here we pass
file_operations as well. Callers don't care about dentry, just
return 0 or -E...

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 5c1da758 fc1abdca

+36 -25
+36 -25
net/sunrpc/rpc_pipe.c
··· 510 510 return -ENOMEM; 511 511 } 512 512 513 - static int __rpc_create(struct inode *dir, struct dentry *dentry, 514 - umode_t mode, 515 - const struct file_operations *i_fop, 516 - void *private) 517 - { 518 - int err; 519 - 520 - err = __rpc_create_common(dir, dentry, S_IFREG | mode, i_fop, private); 521 - if (err) 522 - return err; 523 - fsnotify_create(dir, dentry); 524 - return 0; 525 - } 526 - 527 513 static void 528 514 init_pipe(struct rpc_pipe *pipe) 529 515 { ··· 565 579 return 0; 566 580 } 567 581 582 + static int rpc_new_file(struct dentry *parent, 583 + const char *name, 584 + umode_t mode, 585 + const struct file_operations *i_fop, 586 + void *private) 587 + { 588 + struct dentry *dentry = simple_start_creating(parent, name); 589 + struct inode *dir = parent->d_inode; 590 + struct inode *inode; 591 + 592 + if (IS_ERR(dentry)) 593 + return PTR_ERR(dentry); 594 + 595 + inode = rpc_get_inode(dir->i_sb, S_IFREG | mode); 596 + if (unlikely(!inode)) { 597 + dput(dentry); 598 + inode_unlock(dir); 599 + return -ENOMEM; 600 + } 601 + inode->i_ino = iunique(dir->i_sb, 100); 602 + if (i_fop) 603 + inode->i_fop = i_fop; 604 + rpc_inode_setowner(inode, private); 605 + d_instantiate(dentry, inode); 606 + fsnotify_create(dir, dentry); 607 + inode_unlock(dir); 608 + return 0; 609 + } 610 + 568 611 static struct dentry *rpc_new_dir(struct dentry *parent, 569 612 const char *name, 570 613 umode_t mode, ··· 628 613 int start, int eof, 629 614 void *private) 630 615 { 631 - struct inode *dir = d_inode(parent); 632 616 struct dentry *dentry; 633 617 int i, err; 634 618 ··· 636 622 default: 637 623 BUG(); 638 624 case S_IFREG: 639 - dentry = simple_start_creating(parent, files[i].name); 640 - err = PTR_ERR(dentry); 641 - if (IS_ERR(dentry)) 642 - goto out_bad; 643 - err = __rpc_create(dir, dentry, 625 + err = rpc_new_file(parent, 626 + files[i].name, 644 627 files[i].mode, 645 628 files[i].i_fop, 646 629 private); 647 - inode_unlock(dir); 630 + if (err) 631 + goto out_bad; 648 632 break; 649 633 case S_IFDIR: 650 634 dentry = rpc_new_dir(parent, 651 635 files[i].name, 652 636 files[i].mode, 653 637 private); 654 - err = PTR_ERR(dentry); 655 - if (IS_ERR(dentry)) 638 + if (IS_ERR(dentry)) { 639 + err = PTR_ERR(dentry); 656 640 goto out_bad; 641 + } 657 642 } 658 - if (err != 0) 659 - goto out_bad; 660 643 } 661 644 return 0; 662 645 out_bad: