int syslog_dev_channel(void) { int ret; /* Initialize the character driver interface */ ret = syslog_dev_initialize(CONFIG_SYSLOG_DEVPATH, OPEN_FLAGS, OPEN_MODE); if (ret < 0) { return ret; } /* Use the character driver as the SYSLOG channel */ return syslog_channel(&g_syslog_dev_channel); }
int syslog_console_channel(void) { int ret; /* Initialize the character driver interface */ ret = syslog_dev_initialize("/dev/console", OPEN_FLAGS, OPEN_MODE); if (ret < 0) { return ret; } /* Use the character driver as the SYSLOG channel */ return syslog_channel(&g_syslog_console_channel); }
static int syslog_dev_outputready(void) { int ret; /* Cases (4) and (5) */ if (up_interrupt_context() || getpid() == 0) { return -ENOSYS; } /* We can save checks in the usual case: That after the SYSLOG device * has been successfully opened. */ if (g_syslog_dev.sl_state != SYSLOG_OPENED) { /* Case (1) and (2) */ if (g_syslog_dev.sl_state == SYSLOG_UNINITIALIZED || g_syslog_dev.sl_state == SYSLOG_INITIALIZING) { return -EAGAIN; /* Can't access the SYSLOG now... maybe next time? */ } /* Case (6) */ if (g_syslog_dev.sl_state == SYSLOG_FAILURE) { return -ENXIO; /* There is no SYSLOG device */ } /* syslog_dev_initialize() is called as soon as enough of the operating * system is in place to support the open operation... but it is * possible that the SYSLOG device is not yet registered at that time. * In this case, we know that the system is sufficiently initialized * to support an attempt to re-open the SYSLOG device. * * NOTE that the scheduler is locked. That is because we do not have * fully initialized semaphore capability until the SYSLOG device is * successfully initialized */ sched_lock(); if (g_syslog_dev.sl_state == SYSLOG_REOPEN) { /* Try again to initialize the device. We may do this repeatedly * because the log device might be something that was not ready * the first time that syslog_dev_initializee() was called (such as a * USB serial device that has not yet been connected or a file in * an NFS mounted file system that has not yet been mounted). */ DEBUGASSERT(g_syslog_dev.sl_devpath != NULL); ret = syslog_dev_initialize(g_syslog_dev.sl_devpath, (int)g_syslog_dev.sl_oflags, (int)g_syslog_dev.sl_mode); if (ret < 0) { sched_unlock(); return ret; } } sched_unlock(); DEBUGASSERT(g_syslog_dev.sl_state == SYSLOG_OPENED); } return OK; }