Commit 6319194
Al Viro
Unify the primitives for file descriptor closing
Currently we have 3 primitives for removing an opened file from descriptor
table - pick_file(), __close_fd_get_file() and close_fd_get_file(). Their
calling conventions are rather odd and there's a code duplication for no
good reason. They can be unified -
1) have __range_close() cap max_fd in the very beginning; that way
we don't need separate way for pick_file() to report being past the end
of descriptor table.
2) make {__,}close_fd_get_file() return file (or NULL) directly, rather
than returning it via struct file ** argument. Don't bother with
(bogus) return value - nobody wants that -ENOENT.
3) make pick_file() return NULL on unopened descriptor - the only caller
that used to care about the distinction between descriptor past the end
of descriptor table and finding NULL in descriptor table doesn't give
a damn after (1).
4) lift ->files_lock out of pick_file()
That actually simplifies the callers, as well as the primitives themselves.
Code duplication is also gone...
Reviewed-by: Christian Brauner (Microsoft) <[email protected]>
Signed-off-by: Al Viro <[email protected]>1 parent 81132a3 commit 6319194
File tree
5 files changed
+34
-56
lines changed- drivers/android
- fs
- include/linux
5 files changed
+34
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1855 | 1855 | | |
1856 | 1856 | | |
1857 | 1857 | | |
1858 | | - | |
| 1858 | + | |
1859 | 1859 | | |
1860 | 1860 | | |
1861 | 1861 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
633 | | - | |
634 | | - | |
| 633 | + | |
635 | 634 | | |
636 | | - | |
| 635 | + | |
637 | 636 | | |
638 | 637 | | |
639 | 638 | | |
| 639 | + | |
640 | 640 | | |
641 | | - | |
642 | 641 | | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
649 | 645 | | |
650 | | - | |
651 | | - | |
652 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
653 | 649 | | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | 650 | | |
660 | 651 | | |
661 | 652 | | |
| |||
664 | 655 | | |
665 | 656 | | |
666 | 657 | | |
| 658 | + | |
667 | 659 | | |
668 | | - | |
| 660 | + | |
| 661 | + | |
669 | 662 | | |
670 | 663 | | |
671 | 664 | | |
| |||
702 | 695 | | |
703 | 696 | | |
704 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
708 | 709 | | |
709 | | - | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
710 | 713 | | |
711 | 714 | | |
712 | 715 | | |
713 | | - | |
714 | 716 | | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | 717 | | |
720 | 718 | | |
721 | 719 | | |
| |||
795 | 793 | | |
796 | 794 | | |
797 | 795 | | |
798 | | - | |
| 796 | + | |
799 | 797 | | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
| 798 | + | |
818 | 799 | | |
819 | 800 | | |
820 | 801 | | |
821 | 802 | | |
822 | 803 | | |
823 | 804 | | |
824 | 805 | | |
825 | | - | |
| 806 | + | |
826 | 807 | | |
827 | 808 | | |
828 | | - | |
| 809 | + | |
829 | 810 | | |
830 | 811 | | |
831 | | - | |
| 812 | + | |
832 | 813 | | |
833 | 814 | | |
834 | | - | |
| 815 | + | |
835 | 816 | | |
836 | 817 | | |
837 | 818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5137 | 5137 | | |
5138 | 5138 | | |
5139 | 5139 | | |
5140 | | - | |
| 5140 | + | |
5141 | 5141 | | |
5142 | | - | |
5143 | | - | |
5144 | | - | |
| 5142 | + | |
5145 | 5143 | | |
5146 | | - | |
5147 | 5144 | | |
5148 | 5145 | | |
5149 | 5146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
0 commit comments