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

Merge tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux

Pull sysctl updates from Luis Chamberlain:
"To help make the move of sysctls out of kernel/sysctl.c not incur a
size penalty sysctl has been changed to allow us to not require the
sentinel, the final empty element on the sysctl array. Joel Granados
has been doing all this work.

In the v6.6 kernel we got the major infrastructure changes required to
support this. For v6.7 we had all arch/ and drivers/ modified to
remove the sentinel. For v6.8-rc1 we get a few more updates for fs/
directory only.

The kernel/ directory is left but we'll save that for v6.9-rc1 as
those patches are still being reviewed. After that we then can expect
also the removal of the no longer needed check for procname == NULL.

Let us recap the purpose of this work:

- this helps reduce the overall build time size of the kernel and run
time memory consumed by the kernel by about ~64 bytes per array

- the extra 64-byte penalty is no longer inncurred now when we move
sysctls out from kernel/sysctl.c to their own files

Thomas Weißschuh also sent a few cleanups, for v6.9-rc1 we expect to
see further work by Thomas Weißschuh with the constificatin of the
struct ctl_table.

Due to Joel Granados's work, and to help bring in new blood, I have
suggested for him to become a maintainer and he's accepted. So for
v6.9-rc1 I look forward to seeing him sent you a pull request for
further sysctl changes. This also removes Iurii Zaikin as a maintainer
as he has moved on to other projects and has had no time to help at
all"

* tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux:
sysctl: remove struct ctl_path
sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR
coda: Remove the now superfluous sentinel elements from ctl_table array
sysctl: Remove the now superfluous sentinel elements from ctl_table array
fs: Remove the now superfluous sentinel elements from ctl_table array
cachefiles: Remove the now superfluous sentinel element from ctl_table array
sysclt: Clarify the results of selftest run
sysctl: Add a selftest for handling empty dirs
sysctl: Fix out of bounds access for empty sysctl registers
MAINTAINERS: Add Joel Granados as co-maintainer for proc sysctl
MAINTAINERS: remove Iurii Zaikin from proc sysctl

+122 -102
+1 -1
MAINTAINERS
··· 17412 17412 PROC SYSCTL 17413 17413 M: Luis Chamberlain <mcgrof@kernel.org> 17414 17414 M: Kees Cook <keescook@chromium.org> 17415 - M: Iurii Zaikin <yzaikin@google.com> 17415 + M: Joel Granados <j.granados@samsung.com> 17416 17416 L: linux-kernel@vger.kernel.org 17417 17417 L: linux-fsdevel@vger.kernel.org 17418 17418 S: Maintained
-1
fs/aio.c
··· 239 239 .mode = 0644, 240 240 .proc_handler = proc_doulongvec_minmax, 241 241 }, 242 - {} 243 242 }; 244 243 245 244 static void __init aio_sysctl_init(void)
-1
fs/cachefiles/error_inject.c
··· 19 19 .mode = 0644, 20 20 .proc_handler = proc_douintvec, 21 21 }, 22 - {} 23 22 }; 24 23 25 24 int __init cachefiles_register_error_injection(void)
-1
fs/coda/sysctl.c
··· 36 36 .mode = 0600, 37 37 .proc_handler = proc_dointvec 38 38 }, 39 - {} 40 39 }; 41 40 42 41 void coda_sysctl_init(void)
-1
fs/coredump.c
··· 981 981 .mode = 0644, 982 982 .proc_handler = proc_dointvec, 983 983 }, 984 - { } 985 984 }; 986 985 987 986 static int __init init_fs_coredump_sysctls(void)
-1
fs/dcache.c
··· 191 191 .mode = 0444, 192 192 .proc_handler = proc_nr_dentry, 193 193 }, 194 - { } 195 194 }; 196 195 197 196 static int __init init_fs_dcache_sysctls(void)
-1
fs/devpts/inode.c
··· 69 69 .data = &pty_count, 70 70 .proc_handler = proc_dointvec, 71 71 }, 72 - {} 73 72 }; 74 73 75 74 struct pts_mount_opts {
-1
fs/eventpoll.c
··· 322 322 .extra1 = &long_zero, 323 323 .extra2 = &long_max, 324 324 }, 325 - { } 326 325 }; 327 326 328 327 static void __init epoll_sysctls_init(void)
-1
fs/exec.c
··· 2165 2165 .extra1 = SYSCTL_ZERO, 2166 2166 .extra2 = SYSCTL_TWO, 2167 2167 }, 2168 - { } 2169 2168 }; 2170 2169 2171 2170 static int __init init_fs_exec_sysctls(void)
-1
fs/file_table.c
··· 130 130 .extra1 = &sysctl_nr_open_min, 131 131 .extra2 = &sysctl_nr_open_max, 132 132 }, 133 - { } 134 133 }; 135 134 136 135 static int __init init_fs_stat_sysctls(void)
-1
fs/inode.c
··· 129 129 .mode = 0444, 130 130 .proc_handler = proc_nr_inodes, 131 131 }, 132 - { } 133 132 }; 134 133 135 134 static int __init init_fs_inode_sysctls(void)
-1
fs/lockd/svc.c
··· 473 473 .mode = 0644, 474 474 .proc_handler = proc_dointvec, 475 475 }, 476 - { } 477 476 }; 478 477 479 478 #endif /* CONFIG_SYSCTL */
-1
fs/locks.c
··· 111 111 .proc_handler = proc_dointvec, 112 112 }, 113 113 #endif /* CONFIG_MMU */ 114 - {} 115 114 }; 116 115 117 116 static int __init init_fs_locks_sysctls(void)
-1
fs/namei.c
··· 1071 1071 .extra1 = SYSCTL_ZERO, 1072 1072 .extra2 = SYSCTL_TWO, 1073 1073 }, 1074 - { } 1075 1074 }; 1076 1075 1077 1076 static int __init init_fs_namei_sysctls(void)
-1
fs/namespace.c
··· 5447 5447 .proc_handler = proc_dointvec_minmax, 5448 5448 .extra1 = SYSCTL_ONE, 5449 5449 }, 5450 - { } 5451 5450 }; 5452 5451 5453 5452 static int __init init_fs_namespace_sysctls(void)
-1
fs/nfs/nfs4sysctl.c
··· 34 34 .mode = 0644, 35 35 .proc_handler = proc_dointvec, 36 36 }, 37 - { } 38 37 }; 39 38 40 39 int nfs4_register_sysctl(void)
-1
fs/nfs/sysctl.c
··· 29 29 .mode = 0644, 30 30 .proc_handler = proc_dointvec, 31 31 }, 32 - { } 33 32 }; 34 33 35 34 int nfs_register_sysctl(void)
-1
fs/notify/dnotify/dnotify.c
··· 29 29 .mode = 0644, 30 30 .proc_handler = proc_dointvec, 31 31 }, 32 - {} 33 32 }; 34 33 static void __init dnotify_sysctl_init(void) 35 34 {
-1
fs/notify/fanotify/fanotify_user.c
··· 86 86 .proc_handler = proc_dointvec_minmax, 87 87 .extra1 = SYSCTL_ZERO 88 88 }, 89 - { } 90 89 }; 91 90 92 91 static void __init fanotify_sysctls_init(void)
-1
fs/notify/inotify/inotify_user.c
··· 85 85 .proc_handler = proc_dointvec_minmax, 86 86 .extra1 = SYSCTL_ZERO 87 87 }, 88 - { } 89 88 }; 90 89 91 90 static void __init inotify_sysctls_init(void)
-1
fs/ntfs/sysctl.c
··· 28 28 .mode = 0644, /* Mode, proc handler. */ 29 29 .proc_handler = proc_dointvec 30 30 }, 31 - {} 32 31 }; 33 32 34 33 /* Storage for the sysctls header. */
-1
fs/ocfs2/stackglue.c
··· 658 658 .mode = 0644, 659 659 .proc_handler = proc_dostring, 660 660 }, 661 - { } 662 661 }; 663 662 664 663 static struct ctl_table_header *ocfs2_table_header;
-1
fs/pipe.c
··· 1507 1507 .mode = 0644, 1508 1508 .proc_handler = proc_doulongvec_minmax, 1509 1509 }, 1510 - { } 1511 1510 }; 1512 1511 #endif 1513 1512
+7 -3
fs/proc/proc_sysctl.c
··· 44 44 */ 45 45 struct ctl_table_header *register_sysctl_mount_point(const char *path) 46 46 { 47 - return register_sysctl_sz(path, sysctl_mount_point, 0); 47 + return register_sysctl(path, sysctl_mount_point); 48 48 } 49 49 EXPORT_SYMBOL(register_sysctl_mount_point); 50 50 ··· 71 71 .procname = "", 72 72 .mode = S_IFDIR|S_IRUGO|S_IXUGO, 73 73 }, 74 - { } 75 74 }; 76 75 static struct ctl_table_root sysctl_table_root = { 77 76 .default_set.dir.header = { ··· 232 233 return -EROFS; 233 234 234 235 /* Am I creating a permanently empty directory? */ 235 - if (sysctl_is_perm_empty_ctl_table(header->ctl_table)) { 236 + if (header->ctl_table_size > 0 && 237 + sysctl_is_perm_empty_ctl_table(header->ctl_table)) { 236 238 if (!RB_EMPTY_ROOT(&dir->root)) 237 239 return -EINVAL; 238 240 sysctl_set_perm_empty_ctl_header(dir_h); ··· 1212 1212 { 1213 1213 struct ctl_table_header *tmp_head; 1214 1214 struct ctl_table *entry, *link; 1215 + 1216 + if (header->ctl_table_size == 0 || 1217 + sysctl_is_perm_empty_ctl_table(header->ctl_table)) 1218 + return true; 1215 1219 1216 1220 /* Are there links available for every entry in table? */ 1217 1221 list_for_each_table_entry(entry, header) {
-1
fs/quota/dquot.c
··· 2969 2969 .proc_handler = proc_dointvec, 2970 2970 }, 2971 2971 #endif 2972 - { }, 2973 2972 }; 2974 2973 2975 2974 static int __init dquot_init(void)
-1
fs/sysctls.c
··· 26 26 .extra1 = SYSCTL_ZERO, 27 27 .extra2 = SYSCTL_MAXOLDUID, 28 28 }, 29 - { } 30 29 }; 31 30 32 31 static int __init init_fs_sysctls(void)
-1
fs/userfaultfd.c
··· 45 45 .extra1 = SYSCTL_ZERO, 46 46 .extra2 = SYSCTL_ONE, 47 47 }, 48 - { } 49 48 }; 50 49 #endif 51 50
-1
fs/verity/init.c
··· 24 24 .extra2 = SYSCTL_ONE, 25 25 }, 26 26 #endif 27 - { } 28 27 }; 29 28 30 29 static void __init fsverity_init_sysctl(void)
-2
fs/xfs/xfs_sysctl.c
··· 206 206 .extra2 = &xfs_params.stats_clear.max 207 207 }, 208 208 #endif /* CONFIG_PROC_FS */ 209 - 210 - {} 211 209 }; 212 210 213 211 int
-7
include/linux/sysctl.h
··· 210 210 int (*permissions)(struct ctl_table_header *head, struct ctl_table *table); 211 211 }; 212 212 213 - /* struct ctl_path describes where in the hierarchy a table is added */ 214 - struct ctl_path { 215 - const char *procname; 216 - }; 217 - 218 213 #define register_sysctl(path, table) \ 219 214 register_sysctl_sz(path, table, ARRAY_SIZE(table)) 220 215 ··· 249 254 extern int unaligned_enabled; 250 255 extern int unaligned_dump_stack; 251 256 extern int no_unaligned_warning; 252 - 253 - #define SYSCTL_PERM_EMPTY_DIR (1 << 0) 254 257 255 258 #else /* CONFIG_SYSCTL */ 256 259
+29 -2
lib/test_sysctl.c
··· 35 35 struct ctl_table_header *test_h_setup_node; 36 36 struct ctl_table_header *test_h_mnt; 37 37 struct ctl_table_header *test_h_mnterror; 38 + struct ctl_table_header *empty_add; 39 + struct ctl_table_header *empty; 38 40 } sysctl_test_headers; 39 41 40 42 struct test_sysctl_data { ··· 132 130 .mode = 0644, 133 131 .proc_handler = proc_do_large_bitmap, 134 132 }, 135 - { } 136 133 }; 137 134 138 135 static void test_sysctl_calc_match_int_ok(void) ··· 185 184 .mode = 0644, 186 185 .proc_handler = proc_dointvec_minmax, 187 186 }, 188 - {} 189 187 }; 190 188 191 189 static int test_sysctl_run_unregister_nested(void) ··· 220 220 return 0; 221 221 } 222 222 223 + static struct ctl_table test_table_empty[] = { }; 224 + 225 + static int test_sysctl_run_register_empty(void) 226 + { 227 + /* Tets that an empty dir can be created */ 228 + sysctl_test_headers.empty_add 229 + = register_sysctl("debug/test_sysctl/empty_add", test_table_empty); 230 + if (!sysctl_test_headers.empty_add) 231 + return -ENOMEM; 232 + 233 + /* Test that register on top of an empty dir works */ 234 + sysctl_test_headers.empty 235 + = register_sysctl("debug/test_sysctl/empty_add/empty", test_table_empty); 236 + if (!sysctl_test_headers.empty) 237 + return -ENOMEM; 238 + 239 + return 0; 240 + } 241 + 223 242 static int __init test_sysctl_init(void) 224 243 { 225 244 int err; ··· 252 233 goto out; 253 234 254 235 err = test_sysctl_run_register_mount_point(); 236 + if (err) 237 + goto out; 238 + 239 + err = test_sysctl_run_register_empty(); 255 240 256 241 out: 257 242 return err; ··· 271 248 unregister_sysctl_table(sysctl_test_headers.test_h_mnt); 272 249 if (sysctl_test_headers.test_h_mnterror) 273 250 unregister_sysctl_table(sysctl_test_headers.test_h_mnterror); 251 + if (sysctl_test_headers.empty) 252 + unregister_sysctl_table(sysctl_test_headers.empty); 253 + if (sysctl_test_headers.empty_add) 254 + unregister_sysctl_table(sysctl_test_headers.empty_add); 274 255 } 275 256 276 257 module_exit(test_sysctl_exit);
+85 -61
tools/testing/selftests/sysctl/sysctl.sh
··· 35 35 ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1" 36 36 ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0" 37 37 ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0" 38 + ALL_TESTS="$ALL_TESTS 0011:1:1:empty_add:0" 38 39 39 40 function allow_user_defaults() 40 41 { ··· 64 63 else 65 64 old_strict=$(cat ${WRITES_STRICT}) 66 65 if [ "$old_strict" = "1" ]; then 67 - echo "ok" 66 + echo "OK" 68 67 else 69 68 echo "FAIL, strict value is 0 but force to 1 to continue" >&2 70 69 echo "1" > ${WRITES_STRICT} ··· 226 225 echo "FAIL" >&2 227 226 exit 1 228 227 else 229 - echo "ok" 228 + echo "OK" 230 229 fi 231 230 232 231 echo -n "Checking sysctl is not set to test value ... " ··· 234 233 echo "FAIL" >&2 235 234 exit 1 236 235 else 237 - echo "ok" 236 + echo "OK" 238 237 fi 239 238 240 239 echo -n "Writing sysctl from shell ... " ··· 243 242 echo "FAIL" >&2 244 243 exit 1 245 244 else 246 - echo "ok" 245 + echo "OK" 247 246 fi 248 247 249 248 echo -n "Resetting sysctl to original value ... " ··· 252 251 echo "FAIL" >&2 253 252 exit 1 254 253 else 255 - echo "ok" 254 + echo "OK" 256 255 fi 257 256 258 257 # Now that we've validated the sanity of "set_test" and "set_orig", ··· 266 265 echo "FAIL" >&2 267 266 rc=1 268 267 else 269 - echo "ok" 268 + echo "OK" 270 269 fi 271 270 272 271 echo -n "Writing middle of sysctl after synchronized seek ... " ··· 276 275 echo "FAIL" >&2 277 276 rc=1 278 277 else 279 - echo "ok" 278 + echo "OK" 280 279 fi 281 280 282 281 echo -n "Writing beyond end of sysctl ... " ··· 286 285 echo "FAIL" >&2 287 286 rc=1 288 287 else 289 - echo "ok" 288 + echo "OK" 290 289 fi 291 290 292 291 echo -n "Writing sysctl with multiple long writes ... " ··· 297 296 echo "FAIL" >&2 298 297 rc=1 299 298 else 300 - echo "ok" 299 + echo "OK" 301 300 fi 302 301 test_rc 303 302 } 304 303 305 304 check_failure() 306 305 { 307 - echo -n "Testing that $1 fails as expected..." 306 + echo -n "Testing that $1 fails as expected ... " 308 307 reset_vals 309 308 TEST_STR="$1" 310 309 orig="$(cat $TARGET)" ··· 315 314 echo "FAIL" >&2 316 315 rc=1 317 316 else 318 - echo "ok" 317 + echo "OK" 319 318 fi 320 319 test_rc 321 320 } ··· 357 356 # Your test must accept digits 3 and 4 to use this 358 357 run_limit_digit() 359 358 { 360 - echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ..." 359 + echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ... " 361 360 reset_vals 362 361 363 362 LIMIT=$((MAX_DIGITS -1)) ··· 369 368 echo "FAIL" >&2 370 369 rc=1 371 370 else 372 - echo "ok" 371 + echo "OK" 373 372 fi 374 373 test_rc 375 374 376 - echo -n "Checking passing PAGE_SIZE of spaces fails on write ..." 375 + echo -n "Checking passing PAGE_SIZE of spaces fails on write ... " 377 376 reset_vals 378 377 379 378 LIMIT=$((MAX_DIGITS)) ··· 385 384 echo "FAIL" >&2 386 385 rc=1 387 386 else 388 - echo "ok" 387 + echo "OK" 389 388 fi 390 389 test_rc 391 390 } ··· 393 392 # You are using an int 394 393 run_limit_digit_int() 395 394 { 396 - echo -n "Testing INT_MAX works ..." 395 + echo -n "Testing INT_MAX works ... " 397 396 reset_vals 398 397 TEST_STR="$INT_MAX" 399 398 echo -n $TEST_STR > $TARGET ··· 402 401 echo "FAIL" >&2 403 402 rc=1 404 403 else 405 - echo "ok" 404 + echo "OK" 406 405 fi 407 406 test_rc 408 407 409 - echo -n "Testing INT_MAX + 1 will fail as expected..." 408 + echo -n "Testing INT_MAX + 1 will fail as expected ... " 410 409 reset_vals 411 410 let TEST_STR=$INT_MAX+1 412 411 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 415 414 echo "FAIL" >&2 416 415 rc=1 417 416 else 418 - echo "ok" 417 + echo "OK" 419 418 fi 420 419 test_rc 421 420 422 - echo -n "Testing negative values will work as expected..." 421 + echo -n "Testing negative values will work as expected ... " 423 422 reset_vals 424 423 TEST_STR="-3" 425 424 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 427 426 echo "FAIL" >&2 428 427 rc=1 429 428 else 430 - echo "ok" 429 + echo "OK" 431 430 fi 432 431 test_rc 433 432 } ··· 443 442 echo "FAIL" >&2 444 443 rc=1 445 444 else 446 - echo "ok" 445 + echo "OK" 447 446 fi 448 447 test_rc 449 448 ··· 460 459 echo "FAIL" >&2 461 460 rc=1 462 461 else 463 - echo "ok" 462 + echo "OK" 464 463 fi 465 464 test_rc 466 465 ··· 478 477 echo "FAIL" >&2 479 478 rc=1 480 479 else 481 - echo "ok" 480 + echo "OK" 482 481 fi 483 482 test_rc 484 483 ··· 495 494 echo "FAIL" >&2 496 495 rc=1 497 496 else 498 - echo "ok" 497 + echo "OK" 499 498 fi 500 499 test_rc 501 500 } ··· 503 502 # You are using an unsigned int 504 503 run_limit_digit_uint() 505 504 { 506 - echo -n "Testing UINT_MAX works ..." 505 + echo -n "Testing UINT_MAX works ... " 507 506 reset_vals 508 507 TEST_STR="$UINT_MAX" 509 508 echo -n $TEST_STR > $TARGET ··· 512 511 echo "FAIL" >&2 513 512 rc=1 514 513 else 515 - echo "ok" 514 + echo "OK" 516 515 fi 517 516 test_rc 518 517 519 - echo -n "Testing UINT_MAX + 1 will fail as expected..." 518 + echo -n "Testing UINT_MAX + 1 will fail as expected ... " 520 519 reset_vals 521 520 TEST_STR=$(($UINT_MAX+1)) 522 521 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 525 524 echo "FAIL" >&2 526 525 rc=1 527 526 else 528 - echo "ok" 527 + echo "OK" 529 528 fi 530 529 test_rc 531 530 532 - echo -n "Testing negative values will not work as expected ..." 531 + echo -n "Testing negative values will not work as expected ... " 533 532 reset_vals 534 533 TEST_STR="-3" 535 534 echo -n $TEST_STR > $TARGET 2> /dev/null ··· 538 537 echo "FAIL" >&2 539 538 rc=1 540 539 else 541 - echo "ok" 540 + echo "OK" 542 541 fi 543 542 test_rc 544 543 } ··· 552 551 echo "FAIL" >&2 553 552 rc=1 554 553 else 555 - echo "ok" 554 + echo "OK" 556 555 fi 557 556 558 557 echo -n "Writing middle of sysctl after unsynchronized seek ... " ··· 562 561 echo "FAIL" >&2 563 562 rc=1 564 563 else 565 - echo "ok" 564 + echo "OK" 566 565 fi 567 566 568 567 echo -n "Checking sysctl maxlen is at least $MAXLEN ... " ··· 573 572 echo "FAIL" >&2 574 573 rc=1 575 574 else 576 - echo "ok" 575 + echo "OK" 577 576 fi 578 577 579 578 echo -n "Checking sysctl keeps original string on overflow append ... " ··· 584 583 echo "FAIL" >&2 585 584 rc=1 586 585 else 587 - echo "ok" 586 + echo "OK" 588 587 fi 589 588 590 589 echo -n "Checking sysctl stays NULL terminated on write ... " ··· 595 594 echo "FAIL" >&2 596 595 rc=1 597 596 else 598 - echo "ok" 597 + echo "OK" 599 598 fi 600 599 601 600 echo -n "Checking sysctl stays NULL terminated on overwrite ... " ··· 606 605 echo "FAIL" >&2 607 606 rc=1 608 607 else 609 - echo "ok" 608 + echo "OK" 610 609 fi 611 610 612 611 test_rc ··· 651 650 fi 652 651 done 653 652 654 - echo -n "Checking bitmap handler... " 653 + echo -n "Checking bitmap handler ... " 655 654 TEST_FILE=$(mktemp) 656 655 echo -n "$TEST_STR" > $TEST_FILE 657 656 ··· 666 665 echo "FAIL" >&2 667 666 rc=1 668 667 else 669 - echo "ok" 668 + echo "OK" 670 669 rc=0 671 670 fi 672 671 test_rc ··· 743 742 sysctl_test_0007() 744 743 { 745 744 TARGET="${SYSCTL}/$(get_test_target 0007)" 745 + echo -n "Testing if $TARGET is set to 1 ... " 746 + 746 747 if [ ! -f $TARGET ]; then 747 - echo "Skipping test for $TARGET as it is not present ..." 748 + echo -e "SKIPPING\n$TARGET is not present" 748 749 return $ksft_skip 749 750 fi 750 751 751 752 if [ -d $DIR ]; then 752 - echo "Boot param test only possible sysctl_test is built-in, not module:" 753 + echo -e "SKIPPING\nTest only possible if sysctl_test is built-in, not module:" 753 754 cat $TEST_DIR/config >&2 754 755 return $ksft_skip 755 756 fi 756 757 757 - echo -n "Testing if $TARGET is set to 1 ..." 758 758 ORIG=$(cat "${TARGET}") 759 759 760 760 if [ x$ORIG = "x1" ]; then 761 - echo "ok" 761 + echo "OK" 762 762 return 0 763 763 fi 764 - echo "FAIL" 765 - echo "Checking if /proc/cmdline contains setting of the expected parameter ..." 764 + 766 765 if [ ! -f /proc/cmdline ]; then 767 - echo "/proc/cmdline does not exist, test inconclusive" 768 - return 0 766 + echo -e "SKIPPING\nThere is no /proc/cmdline to check for paramter" 767 + return $ksft_skip 769 768 fi 770 769 771 770 FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline) 772 771 if [ $FOUND = "1" ]; then 773 - echo "Kernel param found but $TARGET is not 1, TEST FAILED" 772 + echo -e "FAIL\nKernel param found but $TARGET is not 1." >&2 774 773 rc=1 775 774 test_rc 776 775 fi 777 776 778 - echo "Skipping test, expected kernel parameter missing." 779 - echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1" 777 + echo -e "SKIPPING\nExpected kernel parameter missing." 778 + echo "Kernel must be booted with parameter: sysctl.debug.test_sysctl.boot_int=1" 780 779 return $ksft_skip 781 780 } 782 781 783 782 sysctl_test_0008() 784 783 { 785 784 TARGET="${SYSCTL}/$(get_test_target 0008)" 785 + echo -n "Testing if $TARGET is matched in kernel ... " 786 + 786 787 if [ ! -f $TARGET ]; then 787 - echo "Skipping test for $TARGET as it is not present ..." 788 + echo -e "SKIPPING\n$TARGET is not present" 788 789 return $ksft_skip 789 790 fi 790 791 791 - echo -n "Testing if $TARGET is matched in kernel" 792 792 ORIG_VALUE=$(cat "${TARGET}") 793 793 794 794 if [ $ORIG_VALUE -ne 1 ]; then 795 - echo "TEST FAILED" 795 + echo "FAIL" >&2 796 796 rc=1 797 797 test_rc 798 798 fi 799 799 800 - echo "ok" 800 + echo "OK" 801 801 return 0 802 802 } 803 803 804 804 sysctl_test_0009() 805 805 { 806 806 TARGET="${SYSCTL}/$(get_test_target 0009)" 807 - echo -n "Testing if $TARGET unregistered correctly ..." 807 + echo -n "Testing if $TARGET unregistered correctly ... " 808 808 if [ -d $TARGET ]; then 809 - echo "TEST FAILED" 809 + echo "FAIL" >&2 810 810 rc=1 811 811 test_rc 812 812 fi 813 813 814 - echo "ok" 814 + echo "OK" 815 815 return 0 816 816 } 817 817 818 818 sysctl_test_0010() 819 819 { 820 820 TARGET="${SYSCTL}/$(get_test_target 0010)" 821 - echo -n "Testing that $TARGET was not created ..." 821 + echo -n "Testing that $TARGET was not created ... " 822 822 if [ -d $TARGET ]; then 823 - echo "TEST FAILED" 823 + echo "FAIL" >&2 824 824 rc=1 825 825 test_rc 826 826 fi 827 827 828 - echo "ok" 828 + echo "OK" 829 + return 0 830 + } 831 + 832 + sysctl_test_0011() 833 + { 834 + TARGET="${SYSCTL}/$(get_test_target 0011)" 835 + echo -n "Testing empty dir handling in ${TARGET} ... " 836 + if [ ! -d ${TARGET} ]; then 837 + echo -e "FAIL\nCould not create ${TARGET}" >&2 838 + rc=1 839 + test_rc 840 + fi 841 + 842 + TARGET2="${TARGET}/empty" 843 + if [ ! -d ${TARGET2} ]; then 844 + echo -e "FAIL\nCould not create ${TARGET2}" >&2 845 + rc=1 846 + test_rc 847 + fi 848 + 849 + echo "OK" 829 850 return 0 830 851 } 831 852 ··· 869 846 echo "0008 x $(get_test_count 0008) - tests sysctl macro values match" 870 847 echo "0009 x $(get_test_count 0009) - tests sysct unregister" 871 848 echo "0010 x $(get_test_count 0010) - tests sysct mount point" 849 + echo "0011 x $(get_test_count 0011) - tests empty directories" 872 850 } 873 851 874 852 usage() ··· 958 934 if target_exists $TEST_TARGET $TEST_ID; then 959 935 TEST_SKIP=$(get_test_skip_no_target $TEST_ID) 960 936 if [[ $TEST_SKIP -eq "1" ]]; then 961 - echo "Target for test $TEST_ID: $TEST_TARGET not exist, skipping test ..." 937 + echo "Target $TEST_TARGET for test $TEST_ID does not exist ... SKIPPING" 962 938 return 0 963 939 fi 964 940 fi