Commit Graph

49 Commits

Author SHA1 Message Date
chao an 9abe737ef3 syslog/channel: add constant attribute if SYSLOG_IOCTL is not enabled
move all private channel define from data to rodata

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-26 16:10:29 +08:00
hujun5 e4d0f404f1 driver: There is no need to use sched_[un]lock
purpose:
1 sched_lock is very time-consuming, and reducing its invocations can improve performance.
2 sched_lock is prone to misuse, and narrowing its scope of use is to prevent people from referencing incorrect code and using it

test:
We can use qemu for testing.
compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx

We have also tested this patch on other ARM hardware platforms.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-04-30 11:35:13 -03:00
Petro Karashchenko 1b0baa8337 nuttx: use lib_free for memory de-allocation after strdup or asprintf
The memory allocated with strdup and asprintf is done via lib_malloc
so we need to use lib_free to deallocate memory otherwise the assertion
"Free memory from the wrong heap" is hit with flat mode and user separated
heap enabled mode.

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Xiang Xiao efd1b838e6 syslog: Add sc_write_force callback
It is used to write the log message to the channel immediately
when the log message is generated in the interrupt context, which
is faster than the normal force callback.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-23 09:55:19 -03:00
anjiahao d7b4e91dda Call nxsem_destroy or nxmutex_destry in the error path
1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-30 13:56:52 +01:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Nathan Hartman 1867bc2210 Fix compiler warnings (-Wunused-parameter) in various functions
Fixes the -Wunused-parameter warning in:
* group/group_signal.c: group_signal()
* irq/irq_unexpectedisr.c: irq_unexpected_isr()
* task/task_spawn.c: nxtask_spawn_proxy()
* timer/timer_getoverrun.c: timer_getoverrun()
* misc/dev_null.c: devnull_read(), devnull_write(), devnull_poll()
* misc/dev_zero.c: devzero_read(), devzero_write(), devzero_poll()
* syslog/syslog_channel.c: syslog_default_write()
* syslog/syslog_device.c: syslog_dev_flush()
* grp/lib_initgroups.c: initgroups()
* misc/lib_mknod.c: mknod()
* misc/lib_glob.c: ignore_err()
* pthread/pthread_barrierinit.c: pthread_barrier_init()
* pthread/pthread_atfork.c: pthread_atfork()
* semaphore/sem_init.c: nxsem_init()
* stream/lib_nullinstream.c: nullinstream_getc()
* stream/lib_nulloutstream.c: nulloutstream_putc()
* stream/lib_libnoflush.c: lib_noflush()
* stream/lib_libsnoflush.c: lib_snoflush()
* string/lib_strerror.c: strerror()
* time/lib_gettimeofday.c: gettimeofday()
* time/lib_settimeofday.c: settimeofday()
* unistd/lib_pathconf.c: fpathconf(), pathconf()
* unistd/lib_getrusage.c: getrusage()
* unistd/lib_setrlimit.c: setrlimit()
* unistd/lib_getrlimit.c: getrlimit()
* unistd/lib_setpriority.c: setpriority()
2022-07-12 11:42:34 +08:00
Xiang Xiao 22548d71eb drivers/syslog: reuse rmutex_t for the recursive check
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-16 19:01:49 +03:00
Petro Karashchenko e42e3aa642 drivers/syslog: fix deadlock by reverting part of the changes from b88a8cf39f
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-06-14 00:11:28 +08:00
anjiahao b88a8cf39f use rmutex inside of all repeated implementation
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-05-30 19:43:48 +08:00
Petro Karashchenko 68902d8732 pid_t: unify usage of special task IDs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Petro Karashchenko 74a4394352 drivers/syslog/syslog_device: fix flushing data when end of line is detected
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-05 03:10:31 +08:00
Fotis Panagiotopoulos b16de69e56 syslog: Added channel close callback. 2021-06-18 00:47:09 -05:00
Fotis Panagiotopoulos 3543ac95bf syslog_device: Device is re-opened in case of failure. 2021-04-10 06:47:44 -05:00
Fotis Panagiotopoulos ee7276e7a7 syslog: syslog_device ops are handled internally by the driver. 2021-04-09 08:02:38 -05:00
Fotis Panagiotopoulos ac7feda1bc syslog: Proper uninit of syslog_device. 2021-04-07 08:38:53 -05:00
Fotis Panagiotopoulos 1dee243e29 syslog: Added multi device support in syslog_device. 2021-04-06 07:32:23 -05:00
Alin Jerpelea ccff570e6f drivers: nxstyle fixes
nxstyle fixes to pass the CI.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-03-04 18:32:27 -08:00
Alin Jerpelea e5b6305f4a drivers: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-03-04 18:32:27 -08:00
Xiang Xiao c161dc07a9 syslog/file: Remove syslog_dev_uninitialize return value
To simplify the initializition process
2020-02-27 08:02:50 -06:00
Xiang Xiao 5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Juha Niskanen 219d99451a drivers/syslog/syslog_device.c: Fix assert that assumes re-opened syslog file is the same. Logic in syslog_file_channel() is calling syslog_initialize() for the default syslog device as a recovery action after failed syslog_dev_initialize(). 2019-11-08 07:43:24 -06:00
Juha Niskanen 8fa646f0e8 drivers/syslog: syslog_force does not set errno so do not test against it. Some changes to comments. 2019-09-16 07:48:48 -06:00
Nathan Hartman 68d43d3679 Fix typos. 2019-08-04 14:50:28 -06:00
Gregory Nutt a64869aa67 CONFIG_NFILE_DESCRIPTORS=0 can no longer be used to disable the file system. NuttX with no file system does not make sense.
Squashed commit of the following:

    configs/:  The few configurations that formerly set CONFIG_NFILE_DESCRIPTORS=0 should not default, rather they should set the number of descriptors to 3.
    fs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    tools/:  Tools updates for changes to usage of CONFIG_NFILE_DESCRIPTORS.
    syscall/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    libs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    include/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    drivers/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    Documentation/:  Remove all references to CONFIG_NFILE_DESCRIPTORS == 0
    binfmt/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    arch/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    net/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/Kconfig:  CONFIG_NFILE_DESCRIPTORS may no longer to set to a value less than 3
    configs/:  Remove all settings for CONFIG_NFILE_DESCRIPTORS < 3
2019-02-11 12:09:26 -06:00
Gregory Nutt 3a4984a40b Rename file_close_detached() to juse file_close() for better consistency in naming. 2018-09-15 13:04:56 -06:00
Gregory Nutt a7fd58c4db Squashed commit of the following:
many locations:  Change occurences of open() followed by file_detach() to file_open().  Change most non-controversion calls to open() to nx_open().

    fs/inode/fs_fileopen.c:  Flesh out file_open() with some interim, placeholder logic.

    fs/inode/fs_fileopen.c:  Add a framework for a file_open() implementation (no real logic in place yet).

    fs/vfs/fs_open.c:  Add nx_open() which is the same as open() except that it does not create a cancellation point nor does it modify the errno variable.
2018-09-15 10:49:41 -06:00
Gregory Nutt 9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Gregory Nutt 8a75add6a0 drivers/syslog: syslog internal functions should not set the errno variable: ramlog_putc(), syslog_dev_putc(), syslog_dev_write(), syslog_force(). 2017-09-29 15:24:40 -06:00
Gregory Nutt fc7c3f5328 syslog: I think this might speed upt the CR-LF scan in syslog_dev_write(). 2017-05-12 08:50:56 -06:00
Gregory Nutt 1c9859520f syslog: There is yet another place where the output can get split. That is in syslog_dev_write(): It will break up the stream to insert a CR before the LF. This can that can be avoid be generating the CR-LF sequence in the buffer and then detecting and ignoring valid CR-LF sequences, rather than expecting syslog_dev_write() to insert the CR in this case.
I don't like the idea that syslog_dev_write() still scans the entire output buffer to expand CR-LF sequence.  This seems really wasteful, especially in this case where we can be sure that the is no CR or LF without a matching LF or CR.  Bu, I think, the existing behavior in syslog_dev_write() must be retained because it is needed in other contexts.
2017-05-12 07:31:50 -06:00
Gregory Nutt 0de294a586 Fix lots of occurrences of 'the the', 'the there', 'the these', 'the then', 'the they. 2017-05-11 13:35:56 -06:00
Gregory Nutt d8a83f16be Syslog buffering: Various corrections from early debug 2017-05-10 16:13:21 -06:00
Gregory Nutt 20727d17c3 SYSLOG: Add option to buffer SYSLOG output to avoid interleaving. 2017-05-10 14:42:43 -06:00
Gregory Nutt 9965cbe428 drivers/: Review and correct some stylistic inconsistencies 2016-08-07 09:43:48 -06:00
Gregory Nutt a39ce80add SYSLOG logic should use existing file interfaces, not re-invent them. 2016-07-05 12:12:44 -06:00
Gregory Nutt 3b825b3e00 Improve a debug assertion 2016-07-05 09:50:54 -06:00
Gregory Nutt 0cb137d021 SYSLOG device flush logic not meaningful if SYSLOG file channels not supported 2016-06-22 13:35:53 -06:00
Gregory Nutt 82c890db23 syslog_dev_flush() needs to check if the inode is a mountpoint before calling the flush() method. Noted by David Sidrane. 2016-06-22 05:58:33 -06:00
Gregory Nutt e6a1d53869 Extend SYSLOG logic so that we can send SYSLOG output to a file. Not verified on initial commit. 2016-06-21 12:54:47 -06:00
Gregory Nutt b68822805f Eliminate a warning 2016-06-19 13:56:49 -06:00
Gregory Nutt 9434d3e945 There is now one-and-only-one copy of syslog_putc. It is in the SYSLOG channel logic and can redirect syslog output as needed. All former syslog_putc versions were renamed and the corresponding SYSLOG device initializaiton now calls syslog_channel() 2016-06-19 13:03:20 -06:00
Gregory Nutt 9f260ca193 Some renaming so that future features will fit in better; If the architecture provides its only system logging (via CONFIG_ARCH_SYSLOG), then syslog_initialize() is stubbed out 2016-06-19 11:16:12 -06:00
Gregory Nutt 3bd953316f Add a hook before the existing syslog_initialize() call; rename the old syslog_initialize() to syslog_dev_initialize(). 2016-06-19 09:12:33 -06:00
Gregory Nutt e27491f5be Move fs/drivers/fs_devsyslog.c to drivers/syslog/syslog_device.c 2016-06-19 08:46:46 -06:00