Lines Matching +full:open +full:- +full:firmware

1 // SPDX-License-Identifier: GPL-2.0
2 /* Test triggering of loading of firmware from different mount
3 * namespaces. Expect firmware to be always loaded from the mount
35 umount("/lib/firmware"); in die()
43 fd = open(sys_path, O_WRONLY); in trigger_fw()
45 die("open failed: %s\n", in trigger_fw()
57 fd = open(fw_path, O_WRONLY | O_CREAT, 0600); in setup_fw()
59 die("open failed: %s\n", in setup_fw()
61 if (write(fd, fw, sizeof(fw) -1) != sizeof(fw) -1) in setup_fw()
72 if (mount("test", "/lib/firmware", "tmpfs", MS_RDONLY, NULL) == -1) in test_fw_in_ns()
73 die("blocking firmware in parent ns failed\n"); in test_fw_in_ns()
76 if (child == -1) { in test_fw_in_ns()
85 if (pid == -1) { in test_fw_in_ns()
97 umount("/lib/firmware"); in test_fw_in_ns()
105 if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) == -1) in test_fw_in_ns()
109 if (mount("test", "/lib/firmware", "tmpfs", MS_RDONLY, NULL) == -1) in test_fw_in_ns()
110 die("blocking firmware in child ns failed\n"); in test_fw_in_ns()
112 umount("/lib/firmware"); in test_fw_in_ns()
121 const char *fw_name = "test-firmware.bin"; in main()
126 /* Mount tmpfs to /lib/firmware so we don't have to assume in main()
128 if (mount("test", "/lib/firmware", "tmpfs", 0, NULL) == -1) in main()
129 die("mounting tmpfs to /lib/firmware failed\n"); in main()
132 if (asprintf(&fw_path, "/lib/firmware/%s", fw_name) < 0) in main()
138 /* Positive case: firmware in PID1 mount namespace */ in main()
139 printf("Testing with firmware in parent namespace (assumed to be same file system as PID1)\n"); in main()
141 die("error: failed to access firmware\n"); in main()
143 /* Negative case: firmware in child mount namespace, expected to fail */ in main()
144 printf("Testing with firmware in child namespace\n"); in main()
146 die("error: firmware access did not fail\n"); in main()
150 umount("/lib/firmware"); in main()