MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fail_point_sysctl

Function fail_point_sysctl

freebsd/kern/kern_fail.c:867–921  ·  view source on GitHub ↗

* Handle kernel failpoint set/get. */

Source from the content-addressed store, hash-verified

865 * Handle kernel failpoint set/get.
866 */
867int
868fail_point_sysctl(SYSCTL_HANDLER_ARGS)
869{
870 struct fail_point *fp;
871 char *buf;
872 struct sbuf sb, *sb_check;
873 int error;
874
875 buf = NULL;
876 error = 0;
877 fp = arg1;
878
879 sb_check = sbuf_new(&sb, NULL, 1024, SBUF_AUTOEXTEND);
880 if (sb_check != &sb)
881 return (ENOMEM);
882
883 sbuf_set_drain(&sb, (sbuf_drain_func *)fail_sysctl_drain_func, req);
884
885 /* Setting */
886 /**
887 * Lock protects any new entries from being garbage collected before we
888 * can link them to the fail point.
889 */
890 sx_xlock(&sx_fp_set);
891 if (req->newptr) {
892 if (req->newlen > MAX_FAIL_POINT_BUF) {
893 error = EINVAL;
894 goto out;
895 }
896
897 buf = fp_malloc(req->newlen + 1, M_WAITOK);
898
899 error = SYSCTL_IN(req, buf, req->newlen);
900 if (error)
901 goto out;
902 buf[req->newlen] = '\0';
903
904 error = fail_point_set(fp, buf);
905 }
906
907 fail_point_garbage_collect();
908 sx_xunlock(&sx_fp_set);
909
910 /* Retrieving. */
911 fail_point_get(fp, &sb, false);
912
913out:
914 sbuf_finish(&sb);
915 sbuf_delete(&sb);
916
917 if (buf)
918 fp_free(buf);
919
920 return (error);
921}
922
923int
924fail_point_sysctl_status(SYSCTL_HANDLER_ARGS)

Callers

nothing calls this directly

Calls 7

sbuf_newFunction · 0.85
sbuf_set_drainFunction · 0.85
fail_point_setFunction · 0.85
fail_point_getFunction · 0.85
sbuf_finishFunction · 0.85
sbuf_deleteFunction · 0.85

Tested by

no test coverage detected