huojianchaoyy opened a new pull request, #22094:
URL: https://github.com/apache/nuttx/pull/22094

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   syslog, `/dev/log` and ramlog changes from Xiaomi Vela:
   
   - **drivers/syslog_chardev: output raw log without other format**: writes to 
`/dev/log` go out as raw syslog data instead of one formatted message per write 
(timestamp, prefix), so NSH can use `/dev/log` as its console (`NSH_ALTCONDEV`) 
without its output being reformatted.
   - **drivers/syslog: add O_DIRECT mode support**: a `/dev/log` opened with 
`O_DIRECT` writes straight to `up_nputs()`.
   - **syslog: ignore channel that not registered yet**: `SYSLOGIOC_SETFILTER` 
dereferenced the empty entries of `g_syslog_channel[]` while looking a channel 
up by name.
   - **syslog_chardev_ioctl return -ENOTTY if not supported** instead of OK.
   - **drivers/syslog: fix nx_vsyslog clobbering errno**: `strftime()` -> 
`tzset()` -> `open()` and `clock_gettime()` changed the caller's errno.
   - **drivers/ramlog: use header size as magic value**, so another CPU can 
tell where the data starts.
   - **drivers/syslog: add PIPEIOC_GETSIZE ioctl to ramlog driver**: the size 
of the buffer is written to the `unsigned int` that `arg` points to.
   
   ## Impact
   
   - `/dev/log` writes are no longer formatted as syslog messages. Unknown 
`/dev/log` ioctls now fail with `ENOTTY`.
   - A ramlog buffer kept across a reset with the old magic number is 
reinitialized once.
   - No Kconfig or API change.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86_64, GCC 13.4.0, CMake 3.23 + Ninja. Base: master 
46aaa10da85.
   
   `./tools/checkpatch.sh -c -u -m -g HEAD~7..HEAD` passes.
   
   `sim:nsh` with `SYSLOG_CHARDEV`, `SYSLOG_IOCTL`, `RAMLOG_SYSLOG` and the 
formatted local-time timestamp; a test program (not part of this PR):
   
   | step | master | this PR |
   |---|---|---|
   | `errno = EINVAL; syslog(...)`, then errno | 2 (ENOENT from `tzset()`) | 22 
|
   | `write("/dev/log", "slog2 raw line A\n")` | `[19/11/26 12:11:01] slog2 raw 
line A` | `slog2 raw line A` |
   | unknown ioctl on `/dev/log` | 0 | -1, ENOTTY |
   | write to `/dev/log` opened with `O_DIRECT` | formatted, also in the ramlog 
| on the console, not in the ramlog |
   | `ioctl(fd, PIPEIOC_GETSIZE, &size)` on the ramlog | -1, ENOTTY | 0, size 
1016 (1024-byte buffer minus the header) |
   | `ioctl(fd, PIPEIOC_GETSIZE, 0)` on the ramlog | -1, ENOTTY | -1, EINVAL |
   
   Not tested: a ramlog buffer shared with another CPU.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to