secgateway/Platform/user/ulog/log-sched/log_tty.c

62 lines
1.8 KiB
C
Executable File

#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include "log_tty.h"
#include "log_common.h"
#define LOG_CONF_TTY_FILE_NAME "log-tty.conf"
#define LOG_DEV_DIR "/dev"
static int config_log_tty(const log_tty_t *conf)
{
DIR *dir;
if ((dir = opendir(LOG_DEV_DIR)) == NULL) {
ULOG_ERR(g_log, "Open dir:[%s] is failure:%d\n", LOG_DEV_DIR, strerror(errno));
return 1;
}
struct dirent *ptr;
while ((ptr = readdir(dir)) != NULL) {
if ((strcmp(ptr->d_name, ".") == 0)
|| (strcmp(ptr->d_name, "..") == 0)
|| (ptr->d_type == DT_DIR)) { ///current dir OR parrent dir
ULOG_DEBUG(g_log,"The file:[%s] or directory jump over\n", ptr->d_name);
continue;
}
if ((strstr(ptr->d_name, "tty") == NULL)
|| (strcmp(ptr->d_name, "tty") == 0)
|| (strcmp(ptr->d_name, "ttyprintk") == 0)
|| (strstr(ptr->d_name, "ttyS") != NULL)) {
ULOG_DEBUG(g_log,"The file:[%s] isn't redirected\n", ptr->d_name);
}
}
/*
if (write_log_conf_authorizing(conf->level, LOG_CONF_PATH,
LOG_CONF_COSOLE_FILE_NAME, LOG_REDIRECT_CONSOLE, conf->module_name) != 0) {
ULOG_ERR(g_log, "Writing tty[module:%s] of log is failure", conf->module_name);
return 1;
}
*/
return 0;
}
void rpc_conf_log_tty(rpc_conn *conn, pointer input, int input_len, pointer data)
{
u32 need_len = sizeof(log_tty_t);
if (input_len < need_len) {
ULOG_WARNING(g_log,
"The input paramter of rpc log console is needed length of %u, but the actual length is %u",
need_len, input_len);
return;
}
config_log_tty((const log_tty_t *)input);
}