| 1189 | } |
| 1190 | |
| 1191 | static int |
| 1192 | siftr_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); |
| 1225 | done: |
| 1226 | return (error); |
| 1227 | } |
| 1228 | |
| 1229 | static int |
| 1230 | siftr_manage_ops(uint8_t action) |
nothing calls this directly
no test coverage detected