History

sysctl: simplify ->strategy

name and nlen parameters passed to ->strategy hook are unused, remove them. In general ->strategy hook should know what it's doing, and don't do something tricky for which, say, pointer to original userspace array may be needed (name).

Alexey Dobriyan committed 18 years ago

Commit f221e721 parent f40cbaa16 files · +56 −73Browse files

Showing the changes to kernel/sysctl.c (1 of 16 files). Show all

Unified · Split

kernel/sysctl.c+13−16
@@ -1500,7 +1500,6 @@ void register_sysctl_root(struct ctl_table_root *root) · 1499 unmodified lines
1500/* Perform the actual read/write of a sysctl table entry. */1500/* Perform the actual read/write of a sysctl table entry. */
1501static int do_sysctl_strategy(struct ctl_table_root *root,1501static int do_sysctl_strategy(struct ctl_table_root *root,
1502 struct ctl_table *table,1502 struct ctl_table *table,
1503 int __user *name, int nlen,
1504 void __user *oldval, size_t __user *oldlenp,1503 void __user *oldval, size_t __user *oldlenp,
1505 void __user *newval, size_t newlen)1504 void __user *newval, size_t newlen)
1506{1505{
@@ -1514,8 +1513,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root, · 7 unmodified lines
1514 return -EPERM;1513 return -EPERM;
1515 1514
1516 if (table->strategy) {1515 if (table->strategy) {
1517 rc = table->strategy(table, name, nlen, oldval, oldlenp,1516 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1518 newval, newlen);
1519 if (rc < 0)1517 if (rc < 0)
1520 return rc;1518 return rc;
1521 if (rc > 0)1519 if (rc > 0)
@@ -1525,8 +1523,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root, · 3 unmodified lines
1525 /* If there is no strategy routine, or if the strategy returns1523 /* If there is no strategy routine, or if the strategy returns
1526 * zero, proceed with automatic r/w */1524 * zero, proceed with automatic r/w */
1527 if (table->data && table->maxlen) {1525 if (table->data && table->maxlen) {
1528 rc = sysctl_data(table, name, nlen, oldval, oldlenp,1526 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1529 newval, newlen);
1530 if (rc < 0)1527 if (rc < 0)
1531 return rc;1528 return rc;
1532 }1529 }
@@ -1558,7 +1555,7 @@ repeat: · 25 unmodified lines
1558 table = table->child;1555 table = table->child;
1559 goto repeat;1556 goto repeat;
1560 }1557 }
1561 error = do_sysctl_strategy(root, table, name, nlen,1558 error = do_sysctl_strategy(root, table,
1562 oldval, oldlenp,1559 oldval, oldlenp,
1563 newval, newlen);1560 newval, newlen);
1564 return error;1561 return error;
@@ -2707,7 +2704,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, · 1142 unmodified lines
2707 */2704 */
2708 2705
2709/* The generic sysctl data routine (used if no strategy routine supplied) */2706/* The generic sysctl data routine (used if no strategy routine supplied) */
2710int sysctl_data(struct ctl_table *table, int __user *name, int nlen,2707int sysctl_data(struct ctl_table *table,
2711 void __user *oldval, size_t __user *oldlenp,2708 void __user *oldval, size_t __user *oldlenp,
2712 void __user *newval, size_t newlen)2709 void __user *newval, size_t newlen)
2713{2710{
@@ -2741,7 +2738,7 @@ int sysctl_data(struct ctl_table *table, int __user *name, int nlen, · 27 unmodified lines
2741}2738}
2742 2739
2743/* The generic string strategy routine: */2740/* The generic string strategy routine: */
2744int sysctl_string(struct ctl_table *table, int __user *name, int nlen,2741int sysctl_string(struct ctl_table *table,
2745 void __user *oldval, size_t __user *oldlenp,2742 void __user *oldval, size_t __user *oldlenp,
2746 void __user *newval, size_t newlen)2743 void __user *newval, size_t newlen)
2747{2744{
@@ -2787,7 +2784,7 @@ int sysctl_string(struct ctl_table *table, int __user *name, int nlen, · 39 unmodified lines
2787 * are between the minimum and maximum values given in the arrays2784 * are between the minimum and maximum values given in the arrays
2788 * table->extra1 and table->extra2, respectively.2785 * table->extra1 and table->extra2, respectively.
2789 */2786 */
2790int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,2787int sysctl_intvec(struct ctl_table *table,
2791 void __user *oldval, size_t __user *oldlenp,2788 void __user *oldval, size_t __user *oldlenp,
2792 void __user *newval, size_t newlen)2789 void __user *newval, size_t newlen)
2793{2790{
@@ -2823,7 +2820,7 @@ int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, · 29 unmodified lines
2823}2820}
2824 2821
2825/* Strategy function to convert jiffies to seconds */ 2822/* Strategy function to convert jiffies to seconds */
2826int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,2823int sysctl_jiffies(struct ctl_table *table,
2827 void __user *oldval, size_t __user *oldlenp,2824 void __user *oldval, size_t __user *oldlenp,
2828 void __user *newval, size_t newlen)2825 void __user *newval, size_t newlen)
2829{2826{
@@ -2857,7 +2854,7 @@ int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, · 27 unmodified lines
2857}2854}
2858 2855
2859/* Strategy function to convert jiffies to seconds */ 2856/* Strategy function to convert jiffies to seconds */
2860int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,2857int sysctl_ms_jiffies(struct ctl_table *table,
2861 void __user *oldval, size_t __user *oldlenp,2858 void __user *oldval, size_t __user *oldlenp,
2862 void __user *newval, size_t newlen)2859 void __user *newval, size_t newlen)
2863{2860{
@@ -2912,35 +2909,35 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args) · 48 unmodified lines
2912 return error;2909 return error;
2913}2910}
2914 2911
2915int sysctl_data(struct ctl_table *table, int __user *name, int nlen,2912int sysctl_data(struct ctl_table *table,
2916 void __user *oldval, size_t __user *oldlenp,2913 void __user *oldval, size_t __user *oldlenp,
2917 void __user *newval, size_t newlen)2914 void __user *newval, size_t newlen)
2918{2915{
2919 return -ENOSYS;2916 return -ENOSYS;
2920}2917}
2921 2918
2922int sysctl_string(struct ctl_table *table, int __user *name, int nlen,2919int sysctl_string(struct ctl_table *table,
2923 void __user *oldval, size_t __user *oldlenp,2920 void __user *oldval, size_t __user *oldlenp,
2924 void __user *newval, size_t newlen)2921 void __user *newval, size_t newlen)
2925{2922{
2926 return -ENOSYS;2923 return -ENOSYS;
2927}2924}
2928 2925
2929int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,2926int sysctl_intvec(struct ctl_table *table,
2930 void __user *oldval, size_t __user *oldlenp,2927 void __user *oldval, size_t __user *oldlenp,
2931 void __user *newval, size_t newlen)2928 void __user *newval, size_t newlen)
2932{2929{
2933 return -ENOSYS;2930 return -ENOSYS;
2934}2931}
2935 2932
2936int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,2933int sysctl_jiffies(struct ctl_table *table,
2937 void __user *oldval, size_t __user *oldlenp,2934 void __user *oldval, size_t __user *oldlenp,
2938 void __user *newval, size_t newlen)2935 void __user *newval, size_t newlen)
2939{2936{
2940 return -ENOSYS;2937 return -ENOSYS;
2941}2938}
2942 2939
2943int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,2940int sysctl_ms_jiffies(struct ctl_table *table,
2944 void __user *oldval, size_t __user *oldlenp,2941 void __user *oldval, size_t __user *oldlenp,
2945 void __user *newval, size_t newlen)2942 void __user *newval, size_t newlen)
2946{2943{