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

Function siftr_sysctl_logfile_name_handler

freebsd/netinet/siftr.c:1191–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189}
1190
1191static int
1192siftr_sysctl_logfile_name_handler(SYSCTL_HANDLER_ARGS)
1193{
1194 struct alq *new_alq;
1195 int error;
1196
1197 error = sysctl_handle_string(oidp, arg1, arg2, req);
1198
1199 /* Check for error or same filename */
1200 if (error != 0 || req->newptr == NULL ||
1201 strncmp(siftr_logfile, arg1, arg2) == 0)
1202 goto done;
1203
1204 /* Filname changed */
1205 error = alq_open(&new_alq, arg1, curthread->td_ucred,
1206 SIFTR_LOG_FILE_MODE, SIFTR_ALQ_BUFLEN, 0);
1207 if (error != 0)
1208 goto done;
1209
1210 /*
1211 * If disabled, siftr_alq == NULL so we simply close
1212 * the alq as we've proved it can be opened.
1213 * If enabled, close the existing alq and switch the old
1214 * for the new.
1215 */
1216 if (siftr_alq == NULL) {
1217 alq_close(new_alq);
1218 } else {
1219 alq_close(siftr_alq);
1220 siftr_alq = new_alq;
1221 }
1222
1223 /* Update filename upon success */
1224 strlcpy(siftr_logfile, arg1, arg2);
1225done:
1226 return (error);
1227}
1228
1229static int
1230siftr_manage_ops(uint8_t action)

Callers

nothing calls this directly

Calls 5

sysctl_handle_stringFunction · 0.85
strncmpFunction · 0.85
alq_openFunction · 0.85
alq_closeFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected