aboutsummaryrefslogtreecommitdiff
path: root/nuttx/fs/fs_syslog.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-08-03 22:04:14 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-08-03 22:04:14 +0000
commit606c03100020570f7a40fcde3522c1bea3af05f8 (patch)
tree5a95a741d66c4cf2cced6bd05f1408b25d938895 /nuttx/fs/fs_syslog.c
parent07b635386da6ed220d4f5c2a36f7e869b4e5b2a5 (diff)
downloadpx4-firmware-606c03100020570f7a40fcde3522c1bea3af05f8.tar.gz
px4-firmware-606c03100020570f7a40fcde3522c1bea3af05f8.tar.bz2
px4-firmware-606c03100020570f7a40fcde3522c1bea3af05f8.zip
Improve capability to traverse inodes in the NuttX psuedo-filesystem; now returns statfs
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5005 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/fs/fs_syslog.c')
-rw-r--r--nuttx/fs/fs_syslog.c79
1 files changed, 48 insertions, 31 deletions
diff --git a/nuttx/fs/fs_syslog.c b/nuttx/fs/fs_syslog.c
index 6586b90bc..1fe8c03a1 100644
--- a/nuttx/fs/fs_syslog.c
+++ b/nuttx/fs/fs_syslog.c
@@ -390,49 +390,66 @@ int syslog_putc(int ch)
* that is why that case is handled in syslog_semtake().
*/
- if (g_sysdev.sl_state == SYSLOG_UNINITIALIZED ||
- g_sysdev.sl_state == SYSLOG_INITIALIZING ||
- up_interrupt_context())
- {
- return -EAGAIN;
- }
+ /* Case (4) */
- if (g_sysdev.sl_state == SYSLOG_FAILURE)
+ if (up_interrupt_context())
{
- return -ENXIO;
+ return -ENOSYS; /* Not supported */
}
- /* syslog_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
+ /* We can save checks in the usual case: That after the SYSLOG device
+ * has been successfully opened.
*/
- sched_lock();
- if (g_sysdev.sl_state == SYSLOG_REOPEN)
+ if (g_sysdev.sl_state != SYSLOG_OPENED)
{
- /* 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_intialize() 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).
+ /* Case (1) and (2) */
+
+ if (g_sysdev.sl_state == SYSLOG_UNINITIALIZED ||
+ g_sysdev.sl_state == SYSLOG_INITIALIZING)
+ {
+ return -EAGAIN; /* Can't access the SYSLOG now... maybe next time? */
+ }
+
+ /* Case (5) */
+
+ if (g_sysdev.sl_state == SYSLOG_FAILURE)
+ {
+ return -ENXIO; /* There is no SYSLOG device */
+ }
+
+ /* syslog_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
*/
- ret = syslog_initialize();
- if (ret < 0)
+ sched_lock();
+ if (g_sysdev.sl_state == SYSLOG_REOPEN)
{
- sched_unlock();
- return ret;
+ /* 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_intialize() 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).
+ */
+
+ ret = syslog_initialize();
+ if (ret < 0)
+ {
+ sched_unlock();
+ return ret;
+ }
}
- }
- sched_unlock();
- DEBUGASSERT(g_sysdev.sl_state == SYSLOG_OPENED);
+ sched_unlock();
+ DEBUGASSERT(g_sysdev.sl_state == SYSLOG_OPENED);
+ }
/* Ignore carriage returns */