Lines Matching defs:ctrl
223 int *count, plg_ctrl_t *ctrl)
231 DPRINT((ctrl->dbfp, "binfile: dirlist=%s\n", dirlist));
242 DPRINT((ctrl->dbfp, "binfile: p_dir = %s\n", dirname));
294 loadauditlist(char *dirstr, char *minfreestr, plg_ctrl_t *ctrl)
303 DPRINT((ctrl->dbfp, "binfile: Loading audit list from audit service "
307 DPRINT((ctrl->dbfp, "binfile: internal error"));
310 if ((rc = growauditlist(&listhead, dirstr, NULL, &node_count, ctrl))
321 DPRINT((ctrl->dbfp, "binfile: "
330 (void) fprintf(ctrl->dbfp, "Directory list:\n\t%s\n",
335 (void) fprintf(ctrl->dbfp,
346 if (node_count == ctrl->activeCount) {
348 n2 = ctrl->activeList;
351 DPRINT((ctrl->dbfp,
361 } while ((n1 != listhead) && (n2 != ctrl->activeList));
363 DPRINT((ctrl->dbfp, "binfile: dir counts differs\n"
366 ctrl->activeCount, node_count));
370 (void) pthread_mutex_lock(&(ctrl->log_mutex));
371 DPRINT((ctrl->dbfp,
373 if (open_log(listhead, ctrl) == 0) {
374 ctrl->openNewFile = B_TRUE; /* try again later */
376 ctrl->openNewFile = B_FALSE;
378 freedirlist(ctrl->activeList); /* old list */
379 ctrl->activeList = listhead; /* new list */
380 ctrl->startdir = thisdir;
381 ctrl->activeDir = thisdir;
382 ctrl->activeCount = node_count;
383 (void) pthread_mutex_unlock(&(ctrl->log_mutex));
395 if (ctrl->minfree != temp_minfree) {
396 DPRINT((ctrl->dbfp, "minfree: old = %d, new = %d\n",
397 ctrl->minfree, temp_minfree));
399 ctrl->minfree = temp_minfree;
438 write_file_token(int fd, char *name, plg_ctrl_t *ctrl)
463 DPRINT((ctrl->dbfp, "binfile: Bad write\n"));
481 plg_ctrl_t *ctrl)
516 (void) write_file_token(currentdir->dl_fd, newname, ctrl);
524 DPRINT((ctrl->dbfp, "binfile: Log closed %s\n", oldname));
544 open_log(dirlist_t *current_dir, plg_ctrl_t *ctrl)
556 if (ctrl->host[0] == '\0')
557 (void) gethostname(ctrl->host, MAXHOSTNAMELEN);
564 current_dir->dl_dirname, auditdate, ctrl->host);
570 DPRINT((ctrl->dbfp,
577 DPRINT((ctrl->dbfp,
589 DPRINT((ctrl->dbfp,
607 if ((ctrl->lastOpenDir != NULL) &&
608 (ctrl->lastOpenDir->dl_filename != NULL)) {
609 (void) strlcpy(oldname, ctrl->lastOpenDir->dl_filename,
616 close_log(&(ctrl->lastOpenDir), oldname, newname, ctrl);
618 error = write_file_token(newfd, oldname, ctrl);
636 if (ctrl->lastOpenDir == NULL) {
637 freedirlist(ctrl->lastOpenDir);
638 ctrl->lastOpenDir = dupdirnode(current_dir);
639 if (ctrl->lastOpenDir == NULL) {
645 DPRINT((ctrl->dbfp, "open_log created new lastOpenDir "
647 ctrl->lastOpenDir->dl_dirname == NULL ? "" :
648 ctrl->lastOpenDir->dl_dirname,
649 ctrl->lastOpenDir->dl_filename == NULL ? "" :
650 ctrl->lastOpenDir->dl_filename,
651 ctrl->lastOpenDir->dl_fd));
659 ctrl->binfile_cursize = 0;
661 DPRINT((ctrl->dbfp, "binfile: Log opened: %s\n", newname));
691 plg_ctrl_t *ctrl)
695 ctrl->ignore_size += next_buf_size;
697 if ((test_limit == PLENTY_SPACE) && (ctrl->ignore_size < IGNORE_SIZE))
704 ctrl->minfreeblocks = AVAIL_MIN;
707 ctrl->minfreeblocks =
708 ((ctrl->minfree * sb.f_blocks) / 100) + AVAIL_MIN;
712 else if (sb.f_bavail > ctrl->minfreeblocks) {
713 thisdir->dl_space = ctrl->fullness_state = PLENTY_SPACE;
714 ctrl->ignore_size = 0;
729 save_maxsize(char *maxsize, plg_ctrl_t *ctrl)
741 ctrl->binfile_maxsize = 0;
742 DPRINT((ctrl->dbfp, "binfile: p_fsize parameter out of "
748 ctrl->binfile_maxsize = proposed_maxsize;
751 ctrl->binfile_maxsize = 0;
754 DPRINT((ctrl->dbfp, "binfile: set maxsize to %llu\n", binfile_maxsize));
792 plg_ctrl_t *ctrl = plg_ctrl;
798 if (ctrl == NULL) {
804 if ((ctrl->last_sequence > 0) && (sequence != ctrl->last_sequence + 1))
805 (void) fprintf(ctrl->dbfp,
807 sequence, ctrl->last_sequence);
808 ctrl->last_sequence = sequence;
810 (void) fprintf(ctrl->dbfp, "binfile: input seq=%llu, len=%d\n",
817 (void) pthread_mutex_lock(&(ctrl->log_mutex));
824 if ((ctrl->binfile_maxsize != 0) &&
825 ((ctrl->binfile_cursize + in_len) > ctrl->binfile_maxsize)) {
826 DPRINT((ctrl->dbfp,
828 ctrl->openNewFile = B_TRUE;
833 if (ctrl->openNewFile) {
834 open_status = open_log(ctrl->activeDir, ctrl);
836 ctrl->openNewFile = B_FALSE;
844 (spacecheck(ctrl->activeDir, ctrl->fullness_state, in_len,
845 ctrl) != 0)) {
848 (statrc = spacecheck(ctrl->activeDir, ctrl->fullness_state,
849 in_len, ctrl) != 0)) {
850 DPRINT((ctrl->dbfp,
857 if ((ctrl->last_file_written_to != NULL) &&
858 (strcmp(ctrl->last_file_written_to,
859 ctrl->activeDir->dl_filename) != 0)) {
860 DPRINT((ctrl->dbfp,
862 ctrl->activeDir->dl_filename));
863 free(ctrl->last_file_written_to);
865 DPRINT((ctrl->dbfp,
867 ctrl->last_file_written_to =
868 strdup(ctrl->activeDir->dl_filename);
870 out_len = write(ctrl->activeDir->dl_fd, input, in_len);
871 DPRINT((ctrl->dbfp, "binfile: finished the write\n"));
873 ctrl->binfile_cursize += out_len;
876 DPRINT((ctrl->dbfp,
879 ++ctrl->write_count, sequence, out_len));
880 ctrl->allsoftfull_warning = 0;
881 ctrl->activeDir->dl_flags = 0;
885 } else if (!(ctrl->activeDir->dl_flags & HARD_WARNED)) {
886 DPRINT((ctrl->dbfp,
889 DPRINT((ctrl->dbfp, "hard warning sent.\n"));
891 ctrl->activeDir->dl_dirname, 0);
893 ctrl->activeDir->dl_flags |= HARD_WARNED;
896 DPRINT((ctrl->dbfp,
898 statrc, ctrl->fullness_state));
899 if (!(ctrl->activeDir->dl_flags & SOFT_WARNED) &&
900 (ctrl->activeDir->dl_space == SOFT_SPACE)) {
901 DPRINT((ctrl->dbfp, "soft warning sent\n"));
903 ctrl->activeDir->dl_dirname, 0);
904 ctrl->activeDir->dl_flags |= SOFT_WARNED;
906 if (!(ctrl->activeDir->dl_flags & HARD_WARNED) &&
907 (ctrl->activeDir->dl_space == SPACE_FULL)) {
908 DPRINT((ctrl->dbfp, "hard warning sent.\n"));
910 ctrl->activeDir->dl_dirname, 0);
911 ctrl->activeDir->dl_flags |= HARD_WARNED;
914 DPRINT((ctrl->dbfp, "binfile: activeDir=%s, next=%s\n",
915 ctrl->activeDir->dl_dirname,
916 ctrl->activeDir->dl_next->dl_dirname));
918 ctrl->activeDir = ctrl->activeDir->dl_next;
919 ctrl->openNewFile = B_TRUE;
921 if (ctrl->activeDir == ctrl->startdir) { /* full circle */
922 if (ctrl->fullness_state == PLENTY_SPACE) { /* once */
923 ctrl->fullness_state = SOFT_SPACE;
924 if (ctrl->allsoftfull_warning == 0) {
925 ctrl->allsoftfull_warning++;
929 if ((ctrl->hung_count > 0) &&
930 !(ctrl->allhard_pause)) {
931 ctrl->allhard_pause = 1;
933 &(ctrl->next_allhard), NULL);
934 ctrl->next_allhard.tv_sec
938 if (ctrl->allhard_pause) {
941 ctrl->next_allhard.tv_sec) {
942 ctrl->allhard_pause = 0;
944 ++ctrl->hung_count);
948 ++ctrl->hung_count);
950 ctrl->minfreeblocks = AVAIL_MIN;
957 (void) pthread_mutex_unlock(&(ctrl->log_mutex));
982 plg_ctrl_t *ctrl;
992 ctrl = *plg_ctrl;
994 if (ctrl->am_open) {
1002 ctrl->dbfp = __auditd_debug_file_open();
1005 DPRINT((ctrl->dbfp,
1006 "binfile: am_open=%d, reason=%d\n", ctrl->am_open, reason));
1008 ctrl->am_open = B_TRUE;
1021 if (!ctrl->binfile_is_open) {
1022 (void) pthread_mutex_init(&(ctrl->log_mutex), NULL);
1024 ctrl->binfile_is_open = B_TRUE;
1025 ctrl->openNewFile = B_TRUE;
1027 (void) snprintf(ctrl->host, sizeof (ctrl->host),
1034 save_maxsize(maxsize, ctrl);
1036 ctrl->fullness_state = PLENTY_SPACE;
1037 status = loadauditlist(dirlist, minfree, ctrl);
1046 ctrl->hung_count = 0;
1047 DPRINT((ctrl->dbfp,
1052 (void) pthread_mutex_lock(&(ctrl->log_mutex));
1053 if (open_log(ctrl->activeDir, ctrl) == 1) { /* ok */
1054 ctrl->openNewFile = 0;
1056 (void) pthread_mutex_unlock(&(ctrl->log_mutex));
1066 plg_ctrl_t *ctrl = *plg_ctrl;
1069 if (ctrl == NULL) {
1083 (void) pthread_mutex_lock(&(ctrl->log_mutex));
1084 close_log(&(ctrl->lastOpenDir), "", "", ctrl);
1085 freedirlist(ctrl->activeDir);
1086 (void) pthread_mutex_unlock(&(ctrl->log_mutex));
1087 (void) pthread_mutex_destroy(&(ctrl->log_mutex));
1091 free(ctrl);