You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/03/01 00:23:18 UTC

[incubator-nuttx] branch master updated (59a5d03 -> 151cf49)

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 59a5d03  boards: raspberrypi-pico: Update defconfigs
     new cf73496  fs/fs.h: Reference the argumnet 'r' in _NX_SETERRNO
     new 9473434  Ensure the kernel component don't call userspace API
     new 151cf49  Fix nxstyle warning

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/cxd56xx/cxd56_gnss.c                  |  29 ++-
 arch/arm/src/cxd56xx/cxd56_icc.c                   |   3 +-
 arch/arm/src/lc823450/lc823450_ipl2.c              |  19 +-
 arch/arm/src/nrf52/nrf52_radio.c                   |   2 -
 arch/arm/src/sama5/sam_ssc.c                       |   4 +-
 arch/arm/src/samv7/sam_ssc.c                       |   4 +-
 arch/arm/src/stm32/stm32_i2s.c                     |   4 +-
 boards/arm/a1x/pcduino-a10/src/a1x_bringup.c       |   4 +-
 .../am335x/beaglebone-black/src/am335x_bringup.c   |   5 +-
 boards/arm/cxd56xx/common/src/cxd56_emmcdev.c      |   6 +-
 boards/arm/cxd56xx/common/src/cxd56_flash.c        |  10 +-
 boards/arm/cxd56xx/common/src/cxd56_imageproc.c    |  19 +-
 boards/arm/cxd56xx/common/src/cxd56_spisd.c        |   6 +-
 boards/arm/cxd56xx/spresense/src/cxd56_bringup.c   |  13 +-
 boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c    |  10 +-
 boards/arm/eoss3/quickfeather/src/eoss3_bringup.c  |   1 -
 boards/arm/imx6/sabre-6quad/src/imx_bringup.c      |   5 +-
 boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c |   4 +-
 boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c |   5 +-
 boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c |   4 +-
 boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c    |   4 +-
 boards/arm/kinetis/freedom-k28f/src/k28_bringup.c  |  15 +-
 .../arm/kinetis/freedom-k28f/src/k28_usbhshost.c   |  16 +-
 boards/arm/kinetis/freedom-k64f/src/k64_bringup.c  |  18 +-
 boards/arm/kinetis/freedom-k66f/src/k66_bringup.c  |  18 +-
 boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c  |   7 +-
 .../lc823450/lc823450-xgevk/src/lc823450_bringup.c |   6 +-
 .../lpc4088-devkit/src/lpc17_40_bringup.c          |   4 +-
 .../lpc4088-quickstart/src/lpc17_40_bringup.c      |   4 +-
 .../arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c |   4 +-
 .../lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c    |   4 +-
 .../olimex-lpc1766stk/src/lpc17_40_bringup.c       |   4 +-
 .../lpc17xx_40xx/open1788/src/lpc17_40_bringup.c   |   4 +-
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c  |  35 +--
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c    |  11 +-
 .../u-blox-c027/src/lpc17_40_appinit.c             |   8 +-
 boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c  |   2 +-
 boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c     |  14 +-
 boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c     |  14 +-
 .../arm/lpc43xx/bambino-200e/src/lpc43_appinit.c   |   8 +-
 .../lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c    |   8 +-
 boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c |   8 +-
 .../lpcxpresso-lpc54628/src/lpc54_bringup.c        |   5 +-
 .../max326xx/max32660-evsys/src/max326_bringup.c   |   5 +-
 boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c  |   4 +-
 .../rp2040/raspberrypi-pico/src/rp2040_bringup.c   |   5 +-
 .../rddrone-uavcan144/src/s32k1xx_bringup.c        |   5 +-
 .../rddrone-uavcan146/src/s32k1xx_bringup.c        |   5 +-
 .../arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c   |   5 +-
 .../arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c   |   5 +-
 .../arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c   |   5 +-
 .../arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c   |   5 +-
 boards/arm/sam34/arduino-due/src/sam_bringup.c     |   4 +-
 .../arm/sam34/flipnclick-sam3x/src/sam_bringup.c   |   4 +-
 boards/arm/sam34/sam4cmp-db/src/sam_bringup.c      |   5 +-
 boards/arm/sam34/sam4e-ek/src/sam_appinit.c        |   2 -
 boards/arm/sam34/sam4e-ek/src/sam_at25.c           |   7 +-
 .../arm/sam34/sam4s-xplained-pro/src/sam_appinit.c |  30 +--
 .../sam34/sam4s-xplained-pro/src/sam_nandflash.c   |   6 +-
 boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c  |   8 +-
 boards/arm/sama5/giant-board/src/sam_bringup.c     |  33 +--
 boards/arm/sama5/sama5d2-xult/src/sam_at25.c       |  11 +-
 boards/arm/sama5/sama5d2-xult/src/sam_bringup.c    |  53 ++---
 boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c  |   6 +-
 .../arm/sama5/sama5d3-xplained/src/sam_appinit.c   |   2 -
 boards/arm/sama5/sama5d3-xplained/src/sam_at25.c   |  11 +-
 .../arm/sama5/sama5d3-xplained/src/sam_bringup.c   |  36 ++--
 .../arm/sama5/sama5d3-xplained/src/sam_nandflash.c |  10 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c     |   5 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_at24.c        |  14 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_at25.c        |   7 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c   |  10 +-
 boards/arm/sama5/sama5d4-ek/src/at25_main.c        |  12 +-
 boards/arm/sama5/sama5d4-ek/src/sam_at25.c         |   7 +-
 boards/arm/sama5/sama5d4-ek/src/sam_bringup.c      |  36 ++--
 boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c    |  10 +-
 boards/arm/samd5e5/metro-m4/src/sam_at24.c         |   7 +-
 boards/arm/samd5e5/metro-m4/src/sam_bringup.c      |   7 +-
 boards/arm/samd5e5/metro-m4/src/sam_usbhost.c      |   1 -
 .../samd5e5/same54-xplained-pro/src/sam_bringup.c  |   5 +-
 boards/arm/samv7/same70-xplained/src/sam_bringup.c |  35 +--
 boards/arm/samv7/samv71-xult/src/sam_bringup.c     |  30 +--
 boards/arm/samv7/samv71-xult/src/sam_ili9488.c     |   2 +-
 boards/arm/stm32/axoloti/src/stm32_bringup.c       |   5 +-
 .../arm/stm32/clicker2-stm32/src/stm32_bringup.c   |  10 +-
 boards/arm/stm32/cloudctrl/src/stm32_w25.c         |  11 +-
 boards/arm/stm32/fire-stm32v2/src/stm32_w25.c      |  11 +-
 boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c |   4 +-
 boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c |   4 +-
 boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c |   5 +-
 .../stm32/nucleo-f429zi/src/stm32_appinitialize.c  |   4 +-
 boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c  |   2 +-
 .../nucleo-f429zi/src/stm32_romfs_initialize.c     |   9 +-
 .../stm32/nucleo-l152re/src/stm32_appinitialize.c  |   4 +-
 .../stm32/olimex-stm32-p407/src/stm32_bringup.c    |   4 +-
 boards/arm/stm32/omnibusf4/src/stm32_bringup.c     |   6 +-
 .../stm32/omnibusf4/src/stm32_romfs_initialize.c   |  13 +-
 boards/arm/stm32/photon/src/stm32_bringup.c        |   4 +-
 boards/arm/stm32/photon/src/stm32_rgbled.c         |  12 +-
 boards/arm/stm32/photon/src/stm32_wdt.c            |   6 +-
 boards/arm/stm32/shenzhou/src/stm32_w25.c          |  11 +-
 boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c |  11 +-
 .../arm/stm32/stm32f103-minimum/src/stm32_at24.c   |  13 +-
 .../stm32/stm32f103-minimum/src/stm32_bringup.c    |   4 +-
 boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c | 186 ++++++++--------
 .../stm32/stm32f411-minimum/src/stm32_bringup.c    |   5 +-
 .../arm/stm32/stm32f411e-disco/src/stm32_bringup.c |   9 +-
 .../arm/stm32/stm32f429i-disco/src/stm32_bringup.c |   7 +-
 .../arm/stm32/stm32f4discovery/src/stm32_bringup.c |   5 +-
 .../stm32f4discovery/src/stm32_romfs_initialize.c  |  11 +-
 .../arm/stm32/stm32ldiscovery/src/stm32_bringup.c  |   4 +-
 .../arm/stm32/stm32vldiscovery/src/stm32_bringup.c |   8 +-
 .../stm32/viewtool-stm32f107/src/stm32_bringup.c   |   4 +-
 .../stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c  |   4 +-
 .../stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c  |   8 +-
 .../stm32f051-discovery/src/stm32_bringup.c        |   5 +-
 .../stm32f072-discovery/src/stm32_bringup.c        |   5 +-
 .../stm32f7/nucleo-144/src/stm32_appinitialize.c   |   4 +-
 boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c   |   6 +-
 .../nucleo-144/src/stm32_romfs_initialize.c        |  11 +-
 .../stm32f7/stm32f746g-disco/src/stm32_bringup.c   |   8 +-
 .../arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c  |   6 +-
 .../stm32f7/stm32f769i-disco/src/stm32_bringup.c   |   5 +-
 .../arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c  |   8 +-
 .../nucleo-h743zi/src/stm32_romfs_initialize.c     |   7 +-
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |   8 +-
 .../arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c | 235 +++++++++++----------
 .../arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c  |   8 +-
 .../arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c   |  33 ++-
 boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c   |   4 +-
 .../arm/stm32l4/nucleo-l452re/src/stm32_bringup.c  |   4 +-
 .../arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c  |  31 ++-
 .../nucleo-l496zg/src/stm32_appinitialize.c        |  17 +-
 .../arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c  |   7 +-
 .../stm32l4/stm32l476vg-disco/src/stm32_appinit.c  |  11 +-
 .../arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c  |  47 +++--
 .../stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c  |  17 +-
 .../arm/tiva/launchxl-cc1310/src/cc1310_bringup.c  |   9 +-
 .../tiva/launchxl-cc1312r1/src/cc1312_bringup.c    |   9 +-
 boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c       |  12 +-
 boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c |  12 +-
 .../tms570ls31x-usb-kit/src/tms570_bringup.c       |  15 +-
 boards/mips/pic32mx/mirtoo/src/pic32_appinit.c     |  12 +-
 .../mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c   |   4 +-
 .../flipnclick-pic32mz/src/pic32mz_bringup.c       |   5 +-
 boards/or1k/mor1kx/or1k/src/or1k_bringup.c         |   5 +-
 .../renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c |   7 +-
 .../renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c   |   6 +-
 .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c |   7 +-
 .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c   |   6 +-
 boards/risc-v/bl602/bl602evb/src/bl602_bringup.c   |  11 +-
 .../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c   |   5 +-
 .../esp32c3/esp32c3-devkit/src/esp32c3_gpio.c      |   1 -
 .../risc-v/fe310/hifive1-revb/src/fe310_bringup.c  |   3 +-
 boards/risc-v/gap8/gapuino/src/gapuino_appinit.c   |   7 +-
 boards/risc-v/k210/maix-bit/src/k210_bringup.c     |   4 +-
 boards/risc-v/litex/arty_a7/src/litex_bringup.c    |   4 +-
 boards/sim/sim/sim/src/sim_bringup.c               |  14 +-
 boards/sim/sim/sim/src/sim_touchscreen.c           |   6 +-
 boards/sim/sim/sim/src/sim_zoneinfo.c              |   5 +-
 boards/x86/qemu/qemu-i486/src/qemu_appinit.c       |   4 +-
 .../x86_64/intel64/qemu-intel64/src/qemu_bringup.c |   4 +-
 .../xtensa/esp32/esp32-devkitc/src/esp32_bringup.c |   9 +-
 .../esp32/esp32-devkitc/src/esp32_spiflash.c       |  20 +-
 .../esp32/esp32-ethernet-kit/src/esp32_bringup.c   |   9 +-
 .../esp32/esp32-ethernet-kit/src/esp32_spiflash.c  |  20 +-
 .../esp32/esp32-wrover-kit/src/esp32_bringup.c     |   8 +-
 .../xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c |   1 -
 .../esp32/esp32-wrover-kit/src/esp32_spiflash.c    |  20 +-
 boards/z80/ez80/makerlisp/src/ez80_bringup.c       |   5 +-
 boards/z80/ez80/z20x/src/ez80_bringup.c            |   5 +-
 boards/z80/ez80/z20x/src/ez80_w25.c                |   2 -
 boards/z80/ez80/z20x/src/w25_main.c                |  18 +-
 drivers/audio/cxd56_src.c                          |  24 +--
 drivers/audio/vs1053.c                             |   2 +-
 drivers/audio/wm8776.c                             |   8 +-
 drivers/bch/bchdev_unregister.c                    |   4 +-
 drivers/lcd/ili9340.c                              |  12 +-
 drivers/lcd/lpm013m091a.c                          |   2 -
 drivers/loop/losetup.c                             |   2 +-
 drivers/sensors/fakesensor.c                       |   4 +-
 drivers/serial/ptmx.c                              |   2 +-
 drivers/usbdev/usbmsc.c                            |   2 +-
 fs/aio/aio_write.c                                 |   2 +-
 fs/driver/fs_findmtddriver.c                       |   1 -
 fs/hostfs/hostfs_rpmsg_server.c                    |   4 +-
 fs/mmap/fs_mmap.c                                  |   4 +-
 fs/mmap/fs_rammap.c                                |   2 +-
 fs/mount/fs_automount.c                            |  21 +-
 graphics/nxmu/nxmu_reportposition.c                |   2 +-
 graphics/nxterm/nxterm_clear.c                     |   2 +-
 graphics/nxterm/nxterm_redraw.c                    |   2 +-
 graphics/nxterm/nxterm_register.c                  |   4 +-
 graphics/nxterm/nxterm_scroll.c                    |   8 +-
 include/nuttx/fs/fs.h                              |   2 +-
 libs/libc/dlfcn/lib_dlerror.c                      |   2 +-
 libs/libc/grp/lib_find_grpfile.c                   |   7 +-
 libs/libc/misc/lib_sendfile.c                      |  34 ++-
 libs/libc/modlib/modlib_init.c                     |   4 +-
 libs/libc/modlib/modlib_read.c                     |   4 +-
 libs/libc/modlib/modlib_uninit.c                   |   2 +-
 libs/libc/netdb/lib_dnsaddserver.c                 |   8 +-
 libs/libc/netdb/lib_dnsbind.c                      |   4 +-
 libs/libc/netdb/lib_dnsforeach.c                   |   2 +-
 libs/libc/netdb/lib_dnsquery.c                     |   6 +-
 libs/libc/netdb/lib_gethostbyaddrr.c               |   2 +-
 libs/libc/netdb/lib_gethostentbynamer.c            |   2 +-
 libs/libc/netdb/lib_getnameinfo.c                  |   2 +-
 libs/libc/pwd/lib_find_pwdfile.c                   |   7 +-
 libs/libc/stdio/lib_libfwrite.c                    |  21 +-
 libs/libc/stdio/lib_perror.c                       |   5 +-
 libs/libc/stdio/lib_rawoutstream.c                 |   2 +-
 libs/libc/stdio/lib_rawsistream.c                  |   2 +-
 libs/libc/stdlib/lib_mktemp.c                      |   2 +-
 libs/libc/stdlib/lib_realpath.c                    |  14 +-
 libs/libc/unistd/lib_posix_fallocate.c             |   4 +-
 libs/libc/userfs/lib_userfs.c                      |   4 +-
 libs/libnx/nxmu/nx_connect.c                       |   4 +-
 libs/libnx/nxmu/nx_redrawreq.c                     |   2 +-
 net/local/local_fifo.c                             |  18 +-
 net/local/local_recvutils.c                        |   2 +-
 net/local/local_sendpacket.c                       |   2 +-
 sched/init/nx_bringup.c                            |   8 +-
 sched/task/task_execv.c                            |   2 +-
 sched/task/task_vfork.c                            |   2 +-
 225 files changed, 1164 insertions(+), 1155 deletions(-)


[incubator-nuttx] 02/03: Ensure the kernel component don't call userspace API

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 9473434587be2d991ec9c648a0568c229abc3f69
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 15 16:08:51 2021 +0800

    Ensure the kernel component don't call userspace API
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/cxd56xx/cxd56_gnss.c                  | 29 ++++++------
 arch/arm/src/cxd56xx/cxd56_icc.c                   |  3 +-
 arch/arm/src/lc823450/lc823450_ipl2.c              | 19 ++++----
 arch/arm/src/nrf52/nrf52_radio.c                   |  2 -
 arch/arm/src/sama5/sam_ssc.c                       |  4 +-
 arch/arm/src/samv7/sam_ssc.c                       |  4 +-
 arch/arm/src/stm32/stm32_i2s.c                     |  4 +-
 boards/arm/a1x/pcduino-a10/src/a1x_bringup.c       |  4 +-
 .../am335x/beaglebone-black/src/am335x_bringup.c   |  5 +-
 boards/arm/cxd56xx/common/src/cxd56_emmcdev.c      |  6 +--
 boards/arm/cxd56xx/common/src/cxd56_flash.c        | 10 ++--
 boards/arm/cxd56xx/common/src/cxd56_imageproc.c    | 19 ++++----
 boards/arm/cxd56xx/common/src/cxd56_spisd.c        |  6 +--
 boards/arm/cxd56xx/spresense/src/cxd56_bringup.c   | 13 +++---
 boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c    | 10 ++--
 boards/arm/eoss3/quickfeather/src/eoss3_bringup.c  |  1 -
 boards/arm/imx6/sabre-6quad/src/imx_bringup.c      |  5 +-
 boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c |  4 +-
 boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c |  4 +-
 boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c |  4 +-
 boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c    |  4 +-
 boards/arm/kinetis/freedom-k28f/src/k28_bringup.c  | 15 +++---
 .../arm/kinetis/freedom-k28f/src/k28_usbhshost.c   | 16 ++-----
 boards/arm/kinetis/freedom-k64f/src/k64_bringup.c  | 18 ++++----
 boards/arm/kinetis/freedom-k66f/src/k66_bringup.c  | 18 ++++----
 boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c  |  7 ++-
 .../lc823450/lc823450-xgevk/src/lc823450_bringup.c |  6 +--
 .../lpc4088-devkit/src/lpc17_40_bringup.c          |  4 +-
 .../lpc4088-quickstart/src/lpc17_40_bringup.c      |  4 +-
 .../arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c |  4 +-
 .../lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c    |  4 +-
 .../olimex-lpc1766stk/src/lpc17_40_bringup.c       |  4 +-
 .../lpc17xx_40xx/open1788/src/lpc17_40_bringup.c   |  4 +-
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c  | 13 +++---
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c    |  7 +--
 .../u-blox-c027/src/lpc17_40_appinit.c             |  8 ++--
 boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c  |  2 +-
 boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c     | 14 +++---
 boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c     | 14 +++---
 .../arm/lpc43xx/bambino-200e/src/lpc43_appinit.c   |  6 +--
 .../lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c    |  6 +--
 boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c |  6 +--
 .../lpcxpresso-lpc54628/src/lpc54_bringup.c        |  5 +-
 .../max326xx/max32660-evsys/src/max326_bringup.c   |  5 +-
 boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c  |  4 +-
 .../rp2040/raspberrypi-pico/src/rp2040_bringup.c   |  5 +-
 .../rddrone-uavcan144/src/s32k1xx_bringup.c        |  5 +-
 .../rddrone-uavcan146/src/s32k1xx_bringup.c        |  5 +-
 .../arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c   |  5 +-
 .../arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c   |  5 +-
 .../arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c   |  5 +-
 .../arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c   |  5 +-
 boards/arm/sam34/arduino-due/src/sam_bringup.c     |  4 +-
 .../arm/sam34/flipnclick-sam3x/src/sam_bringup.c   |  4 +-
 boards/arm/sam34/sam4cmp-db/src/sam_bringup.c      |  5 +-
 boards/arm/sam34/sam4e-ek/src/sam_appinit.c        |  2 -
 boards/arm/sam34/sam4e-ek/src/sam_at25.c           |  7 ++-
 .../arm/sam34/sam4s-xplained-pro/src/sam_appinit.c | 30 ++++--------
 .../sam34/sam4s-xplained-pro/src/sam_nandflash.c   |  6 +--
 boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c  |  8 ++--
 boards/arm/sama5/giant-board/src/sam_bringup.c     | 33 +++++++-------
 boards/arm/sama5/sama5d2-xult/src/sam_at25.c       |  7 ++-
 boards/arm/sama5/sama5d2-xult/src/sam_bringup.c    | 53 +++++++++++-----------
 boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c  |  6 +--
 .../arm/sama5/sama5d3-xplained/src/sam_appinit.c   |  2 -
 boards/arm/sama5/sama5d3-xplained/src/sam_at25.c   |  7 ++-
 .../arm/sama5/sama5d3-xplained/src/sam_bringup.c   | 34 +++++++-------
 .../arm/sama5/sama5d3-xplained/src/sam_nandflash.c |  6 +--
 boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c     |  5 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_at24.c        |  7 ++-
 boards/arm/sama5/sama5d3x-ek/src/sam_at25.c        |  7 ++-
 boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c   |  6 +--
 boards/arm/sama5/sama5d4-ek/src/at25_main.c        |  8 ++--
 boards/arm/sama5/sama5d4-ek/src/sam_at25.c         |  7 ++-
 boards/arm/sama5/sama5d4-ek/src/sam_bringup.c      | 34 +++++++-------
 boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c    |  6 +--
 boards/arm/samd5e5/metro-m4/src/sam_at24.c         |  7 ++-
 boards/arm/samd5e5/metro-m4/src/sam_bringup.c      |  7 +--
 boards/arm/samd5e5/metro-m4/src/sam_usbhost.c      |  1 -
 .../samd5e5/same54-xplained-pro/src/sam_bringup.c  |  5 +-
 boards/arm/samv7/same70-xplained/src/sam_bringup.c | 23 +++++-----
 boards/arm/samv7/samv71-xult/src/sam_bringup.c     | 28 ++++++------
 boards/arm/samv7/samv71-xult/src/sam_ili9488.c     |  2 +-
 boards/arm/stm32/axoloti/src/stm32_bringup.c       |  5 +-
 .../arm/stm32/clicker2-stm32/src/stm32_bringup.c   |  4 +-
 boards/arm/stm32/cloudctrl/src/stm32_w25.c         |  7 ++-
 boards/arm/stm32/fire-stm32v2/src/stm32_w25.c      |  7 ++-
 boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c |  1 -
 boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c |  1 -
 boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c |  5 +-
 .../stm32/nucleo-f429zi/src/stm32_appinitialize.c  |  4 +-
 boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c  |  2 +-
 .../nucleo-f429zi/src/stm32_romfs_initialize.c     |  9 ++--
 .../stm32/nucleo-l152re/src/stm32_appinitialize.c  |  4 +-
 .../stm32/olimex-stm32-p407/src/stm32_bringup.c    |  4 +-
 boards/arm/stm32/omnibusf4/src/stm32_bringup.c     |  5 +-
 .../stm32/omnibusf4/src/stm32_romfs_initialize.c   |  9 ++--
 boards/arm/stm32/photon/src/stm32_bringup.c        |  4 +-
 boards/arm/stm32/photon/src/stm32_rgbled.c         | 12 ++---
 boards/arm/stm32/photon/src/stm32_wdt.c            |  6 +--
 boards/arm/stm32/shenzhou/src/stm32_w25.c          |  7 ++-
 boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c |  4 +-
 .../arm/stm32/stm32f103-minimum/src/stm32_at24.c   |  7 ++-
 .../stm32/stm32f103-minimum/src/stm32_bringup.c    |  4 +-
 boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c |  2 -
 .../stm32/stm32f411-minimum/src/stm32_bringup.c    |  5 +-
 .../arm/stm32/stm32f411e-disco/src/stm32_bringup.c |  5 +-
 .../arm/stm32/stm32f429i-disco/src/stm32_bringup.c |  7 ++-
 .../arm/stm32/stm32f4discovery/src/stm32_bringup.c |  5 +-
 .../stm32f4discovery/src/stm32_romfs_initialize.c  |  7 +--
 .../arm/stm32/stm32ldiscovery/src/stm32_bringup.c  |  4 +-
 .../arm/stm32/stm32vldiscovery/src/stm32_bringup.c |  8 ++--
 .../stm32/viewtool-stm32f107/src/stm32_bringup.c   |  4 +-
 .../stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c  |  4 +-
 .../stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c  |  5 +-
 .../stm32f051-discovery/src/stm32_bringup.c        |  5 +-
 .../stm32f072-discovery/src/stm32_bringup.c        |  5 +-
 .../stm32f7/nucleo-144/src/stm32_appinitialize.c   |  4 +-
 boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c   |  6 +--
 .../nucleo-144/src/stm32_romfs_initialize.c        |  7 +--
 .../stm32f7/stm32f746g-disco/src/stm32_bringup.c   |  8 ++--
 .../arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c  |  6 +--
 .../stm32f7/stm32f769i-disco/src/stm32_bringup.c   |  5 +-
 .../arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c  |  8 ++--
 .../nucleo-h743zi/src/stm32_romfs_initialize.c     |  7 +--
 .../stm32h7/stm32h747i-disco/src/stm32_bringup.c   |  8 ++--
 .../arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c |  4 +-
 .../arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c  |  8 ++--
 .../arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c   |  7 ++-
 boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c   |  2 +-
 .../arm/stm32l4/nucleo-l452re/src/stm32_bringup.c  |  4 +-
 .../arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c  |  7 ++-
 .../nucleo-l496zg/src/stm32_appinitialize.c        |  4 +-
 .../arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c  |  7 ++-
 .../stm32l4/stm32l476vg-disco/src/stm32_appinit.c  | 11 ++---
 .../arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c  |  2 +-
 .../stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c  |  7 ++-
 .../arm/tiva/launchxl-cc1310/src/cc1310_bringup.c  |  5 +-
 .../tiva/launchxl-cc1312r1/src/cc1312_bringup.c    |  5 +-
 boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c       |  9 ++--
 boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c |  7 ++-
 .../tms570ls31x-usb-kit/src/tms570_bringup.c       | 15 +++---
 boards/mips/pic32mx/mirtoo/src/pic32_appinit.c     |  7 ++-
 .../mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c   |  4 +-
 .../flipnclick-pic32mz/src/pic32mz_bringup.c       |  5 +-
 boards/or1k/mor1kx/or1k/src/or1k_bringup.c         |  5 +-
 .../renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c |  7 ++-
 .../renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c   |  6 +--
 .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c |  7 ++-
 .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c   |  6 +--
 boards/risc-v/bl602/bl602evb/src/bl602_bringup.c   | 11 +++--
 .../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c   |  5 +-
 .../esp32c3/esp32c3-devkit/src/esp32c3_gpio.c      |  1 -
 .../risc-v/fe310/hifive1-revb/src/fe310_bringup.c  |  3 +-
 boards/risc-v/gap8/gapuino/src/gapuino_appinit.c   |  7 ++-
 boards/risc-v/k210/maix-bit/src/k210_bringup.c     |  4 +-
 boards/risc-v/litex/arty_a7/src/litex_bringup.c    |  4 +-
 boards/sim/sim/sim/src/sim_bringup.c               | 14 +++---
 boards/sim/sim/sim/src/sim_touchscreen.c           |  6 +--
 boards/sim/sim/sim/src/sim_zoneinfo.c              |  5 +-
 boards/x86/qemu/qemu-i486/src/qemu_appinit.c       |  4 +-
 .../x86_64/intel64/qemu-intel64/src/qemu_bringup.c |  4 +-
 .../xtensa/esp32/esp32-devkitc/src/esp32_bringup.c |  9 ++--
 .../esp32/esp32-devkitc/src/esp32_spiflash.c       | 20 ++++----
 .../esp32/esp32-ethernet-kit/src/esp32_bringup.c   |  9 ++--
 .../esp32/esp32-ethernet-kit/src/esp32_spiflash.c  | 20 ++++----
 .../esp32/esp32-wrover-kit/src/esp32_bringup.c     |  8 ++--
 .../xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c |  1 -
 .../esp32/esp32-wrover-kit/src/esp32_spiflash.c    | 20 ++++----
 boards/z80/ez80/makerlisp/src/ez80_bringup.c       |  5 +-
 boards/z80/ez80/z20x/src/ez80_bringup.c            |  5 +-
 boards/z80/ez80/z20x/src/ez80_w25.c                |  2 -
 boards/z80/ez80/z20x/src/w25_main.c                | 18 ++++----
 drivers/audio/cxd56_src.c                          | 24 +++++-----
 drivers/audio/vs1053.c                             |  2 +-
 drivers/audio/wm8776.c                             |  8 +---
 drivers/bch/bchdev_unregister.c                    |  4 +-
 drivers/lcd/ili9340.c                              |  2 -
 drivers/lcd/lpm013m091a.c                          |  2 -
 drivers/loop/losetup.c                             |  2 +-
 drivers/sensors/fakesensor.c                       |  4 +-
 drivers/serial/ptmx.c                              |  2 +-
 drivers/usbdev/usbmsc.c                            |  2 +-
 fs/aio/aio_write.c                                 |  2 +-
 fs/driver/fs_findmtddriver.c                       |  1 -
 fs/hostfs/hostfs_rpmsg_server.c                    |  4 +-
 fs/mmap/fs_mmap.c                                  |  4 +-
 fs/mmap/fs_rammap.c                                |  2 +-
 fs/mount/fs_automount.c                            | 21 +++------
 graphics/nxmu/nxmu_reportposition.c                |  2 +-
 graphics/nxterm/nxterm_clear.c                     |  2 +-
 graphics/nxterm/nxterm_redraw.c                    |  2 +-
 graphics/nxterm/nxterm_register.c                  |  4 +-
 graphics/nxterm/nxterm_scroll.c                    |  8 ++--
 libs/libc/dlfcn/lib_dlerror.c                      |  2 +-
 libs/libc/grp/lib_find_grpfile.c                   |  4 +-
 libs/libc/misc/lib_sendfile.c                      | 24 +++++++---
 libs/libc/modlib/modlib_init.c                     |  4 +-
 libs/libc/modlib/modlib_read.c                     |  4 +-
 libs/libc/modlib/modlib_uninit.c                   |  2 +-
 libs/libc/netdb/lib_dnsaddserver.c                 |  8 ++--
 libs/libc/netdb/lib_dnsbind.c                      |  4 +-
 libs/libc/netdb/lib_dnsforeach.c                   |  2 +-
 libs/libc/netdb/lib_dnsquery.c                     |  6 +--
 libs/libc/netdb/lib_gethostbyaddrr.c               |  2 +-
 libs/libc/netdb/lib_gethostentbynamer.c            |  2 +-
 libs/libc/netdb/lib_getnameinfo.c                  |  2 +-
 libs/libc/pwd/lib_find_pwdfile.c                   |  4 +-
 libs/libc/stdio/lib_libfwrite.c                    |  2 +-
 libs/libc/stdio/lib_perror.c                       |  4 +-
 libs/libc/stdio/lib_rawoutstream.c                 |  2 +-
 libs/libc/stdio/lib_rawsistream.c                  |  2 +-
 libs/libc/stdlib/lib_mktemp.c                      |  2 +-
 libs/libc/stdlib/lib_realpath.c                    | 14 +++---
 libs/libc/unistd/lib_posix_fallocate.c             |  4 +-
 libs/libc/userfs/lib_userfs.c                      |  4 +-
 libs/libnx/nxmu/nx_connect.c                       |  4 +-
 libs/libnx/nxmu/nx_redrawreq.c                     |  2 +-
 net/local/local_fifo.c                             | 18 +++-----
 net/local/local_recvutils.c                        |  2 +-
 net/local/local_sendpacket.c                       |  2 +-
 sched/init/nx_bringup.c                            |  8 ++--
 sched/task/task_execv.c                            |  2 +-
 sched/task/task_vfork.c                            |  2 +-
 224 files changed, 768 insertions(+), 808 deletions(-)

diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c
index de267ff..0cbe789 100644
--- a/arch/arm/src/cxd56xx/cxd56_gnss.c
+++ b/arch/arm/src/cxd56xx/cxd56_gnss.c
@@ -891,7 +891,7 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
                                        unsigned long    arg)
 {
   FAR char *buf;
-  int       fd;
+  struct file file;
   int       n = 0;
   int32_t   offset = 0;
 
@@ -901,30 +901,30 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
       return -ENOMEM;
     }
 
-  fd = nx_open(CONFIG_CXD56_GNSS_BACKUP_FILENAME,
-               O_WRONLY | O_CREAT | O_TRUNC);
-  if (fd < 0)
+  n = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME,
+                O_WRONLY | O_CREAT | O_TRUNC);
+  if (n < 0)
     {
       kmm_free(buf);
-      return fd;
+      return n;
     }
 
   do
     {
       n = fw_gd_readbuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf,
-                        CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
+                           CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
       if (n <= 0)
         {
           break;
         }
 
-      n = nx_write(fd, buf, n);
+      n = file_write(&file, buf, n);
       offset += n;
     }
   while (n == CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
 
   kmm_free(buf);
-  nx_close(fd);
+  file_close(&file);
 
   return n < 0 ? n : 0;
 }
@@ -948,7 +948,7 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
 static int cxd56_gnss_erase_backup_data(FAR struct file *filep,
                                         unsigned long    arg)
 {
-  return unlink(CONFIG_CXD56_GNSS_BACKUP_FILENAME);
+  return nx_unlink(CONFIG_CXD56_GNSS_BACKUP_FILENAME);
 }
 
 /****************************************************************************
@@ -2208,7 +2208,7 @@ cxd56_gnss_read_cep_file(FAR struct file *fp, int32_t offset,
 static void cxd56_gnss_read_backup_file(FAR int *retval)
 {
   FAR char *  buf;
-  int         fd;
+  struct file file;
   int32_t     offset = 0;
   size_t      n;
   int         ret = 0;
@@ -2220,17 +2220,16 @@ static void cxd56_gnss_read_backup_file(FAR int *retval)
       goto _err;
     }
 
-  fd = nx_open(CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_RDONLY);
-  if (fd < 0)
+  ret = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_RDONLY);
+  if (ret < 0)
     {
       kmm_free(buf);
-      ret = fd;
       goto _err;
     }
 
   do
     {
-      n = nx_read(fd, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
+      n = file_read(&file, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
       if (n <= 0)
         {
           ret = n;
@@ -2247,7 +2246,7 @@ static void cxd56_gnss_read_backup_file(FAR int *retval)
     }
   while (n > 0);
 
-  nx_close(fd);
+  file_close(&file);
   kmm_free(buf);
 
   /* Notify the termination of backup sequence by write zero length data */
diff --git a/arch/arm/src/cxd56xx/cxd56_icc.c b/arch/arm/src/cxd56xx/cxd56_icc.c
index a926e00..66c8c1c 100644
--- a/arch/arm/src/cxd56xx/cxd56_icc.c
+++ b/arch/arm/src/cxd56xx/cxd56_icc.c
@@ -151,7 +151,7 @@ static int icc_semtake(sem_t *semid)
 
 static int icc_semtrytake(sem_t *semid)
 {
-  return sem_trywait(semid);
+  return nxsem_trywait(semid);
 }
 
 static void icc_semgive(sem_t *semid)
@@ -312,7 +312,6 @@ static int icc_recv(FAR struct iccdev_s *priv, FAR iccmsg_t *msg, int32_t ms)
       ret = icc_semtrytake(&priv->rxwait);
       if (ret < 0)
         {
-          ret = -get_errno();
           return ret;
         }
     }
diff --git a/arch/arm/src/lc823450/lc823450_ipl2.c b/arch/arm/src/lc823450/lc823450_ipl2.c
index 92da2dc..5a6a0c3 100644
--- a/arch/arm/src/lc823450/lc823450_ipl2.c
+++ b/arch/arm/src/lc823450/lc823450_ipl2.c
@@ -26,7 +26,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <debug.h>
 #include <string.h>
@@ -39,6 +38,8 @@
 #include <nuttx/arch.h>
 #include <nuttx/signal.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_FS_EVFAT
 #  include <nuttx/fs/mkevfatfs.h>
 #endif
@@ -176,7 +177,7 @@ static int blk_write(const void *buf, int len, const char *path, int offset)
 
 static int install_recovery(const char *srcpath)
 {
-  int rfd;
+  struct file rfile;
   int i;
   int len;
   int rem;
@@ -188,9 +189,9 @@ static int install_recovery(const char *srcpath)
       return -1;
     }
 
-  rfd = open(srcpath, O_RDONLY, 0444);
+  ret = file_open(&rfile, srcpath, O_RDONLY, 0444);
 
-  if (read(rfd, &upg_image, sizeof(upg_image)) != sizeof(upg_image))
+  if (file_read(&rfile, &upg_image, sizeof(upg_image)) != sizeof(upg_image))
     {
       _info("read head");
       ret = -EIO;
@@ -228,7 +229,7 @@ static int install_recovery(const char *srcpath)
       goto err;
     }
 
-  lseek(rfd, upg_image.chunk[i].offset +
+  file_seek(&rfile, upg_image.chunk[i].offset +
         ((void *)&upg_image.chunk[upg_image.chunknum] - (void *)&upg_image),
         SEEK_SET);
 
@@ -236,7 +237,7 @@ static int install_recovery(const char *srcpath)
 
   while (rem > 0)
     {
-      len = read(rfd, copybuf, rem > 512 ? 512 : rem);
+      len = file_read(&rfile, copybuf, rem > 512 ? 512 : rem);
 
       if (len < 0)
         {
@@ -255,7 +256,7 @@ err:
       bchlib_teardown(handle);
     }
 
-  close(rfd);
+  file_close(&rfile);
   _info("DONE\n");
   return ret;
 }
@@ -585,7 +586,7 @@ static int msc_enable(int forced)
 
   /* check recovery kernel update */
 
-  mount(CONFIG_MTD_CP_DEVPATH, "/mnt/sd0", "evfat", 0, NULL);
+  nx_mount(CONFIG_MTD_CP_DEVPATH, "/mnt/sd0", "evfat", 0, NULL);
   nxsig_usleep(10000);
 
   /* recovery kernel install from UPG.img */
@@ -677,7 +678,7 @@ int ipl2_main(int argc, char *argv[])
     {
       /* check recovery kernel update */
 
-      mount(CONFIG_MTD_CP_DEVPATH, "/mnt/sd0", "evfat", 0, NULL);
+      nx_mount(CONFIG_MTD_CP_DEVPATH, "/mnt/sd0", "evfat", 0, NULL);
       nxsig_usleep(10000);
 
       /* recovery kernel install from UPG.img */
diff --git a/arch/arm/src/nrf52/nrf52_radio.c b/arch/arm/src/nrf52/nrf52_radio.c
index bd9609c..fc51d27 100644
--- a/arch/arm/src/nrf52/nrf52_radio.c
+++ b/arch/arm/src/nrf52/nrf52_radio.c
@@ -1183,7 +1183,6 @@ nrf52_radio_initialize(int intf, FAR struct nrf52_radio_board_s *board)
   if (ret < 0)
     {
       wlerr("ERROR: failed to reset radio interface %d\n", ret);
-      errno = ret;
       goto errout;
     }
 
@@ -1193,7 +1192,6 @@ nrf52_radio_initialize(int intf, FAR struct nrf52_radio_board_s *board)
   if (ret < 0)
     {
       wlerr("ERROR: failed to setup radio interface %d\n", ret);
-      errno = ret;
       goto errout;
     }
 
diff --git a/arch/arm/src/sama5/sam_ssc.c b/arch/arm/src/sama5/sam_ssc.c
index 220723c..4cb9dc8 100644
--- a/arch/arm/src/sama5/sam_ssc.c
+++ b/arch/arm/src/sama5/sam_ssc.c
@@ -1355,7 +1355,7 @@ static int ssc_rxdma_setup(struct sam_ssc_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
@@ -1771,7 +1771,7 @@ static int ssc_txdma_setup(struct sam_ssc_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
diff --git a/arch/arm/src/samv7/sam_ssc.c b/arch/arm/src/samv7/sam_ssc.c
index 58e1560..19874bd 100644
--- a/arch/arm/src/samv7/sam_ssc.c
+++ b/arch/arm/src/samv7/sam_ssc.c
@@ -1331,7 +1331,7 @@ static int ssc_rxdma_setup(struct sam_ssc_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
@@ -1751,7 +1751,7 @@ static int ssc_txdma_setup(struct sam_ssc_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
diff --git a/arch/arm/src/stm32/stm32_i2s.c b/arch/arm/src/stm32/stm32_i2s.c
index f9d3760..28cdc9c 100644
--- a/arch/arm/src/stm32/stm32_i2s.c
+++ b/arch/arm/src/stm32/stm32_i2s.c
@@ -1106,7 +1106,7 @@ static int i2s_rxdma_setup(struct stm32_i2s_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
@@ -1505,7 +1505,7 @@ static int i2s_txdma_setup(struct stm32_i2s_s *priv)
 
       if (ret < 0)
         {
-          i2serr("ERROR: wd_start failed: %d\n", errno);
+          i2serr("ERROR: wd_start failed: %d\n", ret);
         }
     }
 
diff --git a/boards/arm/a1x/pcduino-a10/src/a1x_bringup.c b/boards/arm/a1x/pcduino-a10/src/a1x_bringup.c
index 1329501..0ed7b78 100644
--- a/boards/arm/a1x/pcduino-a10/src/a1x_bringup.c
+++ b/boards/arm/a1x/pcduino-a10/src/a1x_bringup.c
@@ -40,7 +40,7 @@
 #include <nuttx/config.h>
 
 #ifdef CONFIG_FS_PROCFS
-#  include <sys/mount.h>
+#  include <nuttx/fs/fs.h>
 #endif
 
 #include <syslog.h>
@@ -100,7 +100,7 @@ int a1x_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/am335x/beaglebone-black/src/am335x_bringup.c b/boards/arm/am335x/beaglebone-black/src/am335x_bringup.c
index ebfea39..6e32fe7 100644
--- a/boards/arm/am335x/beaglebone-black/src/am335x_bringup.c
+++ b/boards/arm/am335x/beaglebone-black/src/am335x_bringup.c
@@ -39,9 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USERLED
 #  include <nuttx/leds/userled.h>
 #endif
@@ -160,7 +161,7 @@ int am335x_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c
index 05ee4b2..1f18751 100644
--- a/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c
+++ b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c
@@ -27,8 +27,8 @@
 #include <stdio.h>
 #include <errno.h>
 #include <debug.h>
-#include <sys/mount.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <arch/board/board.h>
 #include "cxd56_emmc.h"
 
@@ -76,10 +76,10 @@ int board_emmc_initialize(void)
 
   /* Mount the eMMC deivce */
 
-  ret = mount("/dev/emmc0", "/mnt/emmc", "vfat", 0, NULL);
+  ret = nx_mount("/dev/emmc0", "/mnt/emmc", "vfat", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the eMMC. %d\n", errno);
+      ferr("ERROR: Failed to mount the eMMC. %d\n", ret);
     }
 
   return ret;
diff --git a/boards/arm/cxd56xx/common/src/cxd56_flash.c b/boards/arm/cxd56xx/common/src/cxd56_flash.c
index ff6bf3b..c3fee29 100644
--- a/boards/arm/cxd56xx/common/src/cxd56_flash.c
+++ b/boards/arm/cxd56xx/common/src/cxd56_flash.c
@@ -27,8 +27,8 @@
 #include <stdio.h>
 #include <errno.h>
 #include <debug.h>
-#include <sys/mount.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <arch/board/board.h>
 #include <nuttx/mtd/mtd.h>
 
@@ -89,10 +89,10 @@ int board_flash_initialize(void)
       return ret;
     }
 
-  ret = mount("/dev/smart0d1", "/mnt/spif", "smartfs", 0, NULL);
+  ret = nx_mount("/dev/smart0d1", "/mnt/spif", "smartfs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the SmartFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the SmartFS volume: %d\n", ret);
       return ret;
     }
 
@@ -106,10 +106,10 @@ int board_flash_initialize(void)
       return ret;
     }
 
-  ret = mount(NULL, "/mnt/spif", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/spif", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/cxd56xx/common/src/cxd56_imageproc.c b/boards/arm/cxd56xx/common/src/cxd56_imageproc.c
index 87cdc21..ba2ef3f 100644
--- a/boards/arm/cxd56xx/common/src/cxd56_imageproc.c
+++ b/boards/arm/cxd56xx/common/src/cxd56_imageproc.c
@@ -208,7 +208,7 @@ static sem_t g_rotexc;
 static sem_t g_geexc;
 static sem_t g_abexc;
 
-static int g_gfd = -1;
+static struct file g_gfile;
 static char g_gcmdbuf[256] __attribute__ ((aligned(16)));
 
 /****************************************************************************
@@ -534,7 +534,7 @@ void imageproc_initialize(void)
 
   cxd56_ge2dinitialize(GEDEVNAME);
 
-  g_gfd = open(GEDEVNAME, O_RDWR);
+  file_open(&g_gfile, GEDEVNAME, O_RDWR);
 
   putreg32(1, ROT_INTR_CLEAR);
   putreg32(0, ROT_INTR_ENABLE);
@@ -549,10 +549,9 @@ void imageproc_finalize(void)
   up_disable_irq(CXD56_IRQ_ROT);
   irq_detach(CXD56_IRQ_ROT);
 
-  if (g_gfd > 0)
+  if (g_gfile.f_inode)
     {
-      close(g_gfd);
-      g_gfd = -1;
+      file_close(&g_gfile);
     }
 
   cxd56_ge2duninitialize(GEDEVNAME);
@@ -605,7 +604,7 @@ int imageproc_resize(uint8_t * ibuf,
   size_t len;
   int ret;
 
-  if (g_gfd <= 0)
+  if (g_gfile.f_inode == NULL)
     {
       return -ENODEV;
     }
@@ -663,7 +662,7 @@ int imageproc_resize(uint8_t * ibuf,
   /* Process resize */
 
   len = (uintptr_t) cmd - (uintptr_t) g_gcmdbuf;
-  ret = write(g_gfd, g_gcmdbuf, len);
+  ret = file_write(&g_gfile, g_gcmdbuf, len);
   if (ret < 0)
     {
       ip_semgive(&g_geexc);
@@ -691,7 +690,7 @@ int imageproc_clip_and_resize(uint8_t * ibuf,
   uint16_t clip_width = 0;
   uint16_t clip_height = 0;
 
-  if (g_gfd <= 0)
+  if (g_gfile.f_inode == NULL)
     {
       return -ENODEV;
     }
@@ -782,7 +781,7 @@ int imageproc_clip_and_resize(uint8_t * ibuf,
   /* Process resize */
 
   len = (uintptr_t) cmd - (uintptr_t) g_gcmdbuf;
-  ret = write(g_gfd, g_gcmdbuf, len);
+  ret = file_write(&g_gfile, g_gcmdbuf, len);
   if (ret < 0)
     {
       ip_semgive(&g_geexc);
@@ -973,7 +972,7 @@ int imageproc_alpha_blend(imageproc_imginfo_t *dst,
   /* Process alpha blending */
 
   len = (uintptr_t)cmd - (uintptr_t)g_gcmdbuf;
-  ret = write(g_gfd, g_gcmdbuf, len);
+  ret = file_write(&g_gfile, g_gcmdbuf, len);
   if (ret < 0)
     {
       ip_semgive(&g_abexc);
diff --git a/boards/arm/cxd56xx/common/src/cxd56_spisd.c b/boards/arm/cxd56xx/common/src/cxd56_spisd.c
index b6d7d45..1ebbcd7 100644
--- a/boards/arm/cxd56xx/common/src/cxd56_spisd.c
+++ b/boards/arm/cxd56xx/common/src/cxd56_spisd.c
@@ -25,9 +25,9 @@
 #include <nuttx/config.h>
 
 #include <debug.h>
-#include <sys/mount.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include "cxd56_spi.h"
 #include "cxd56_gpio.h"
 
@@ -91,10 +91,10 @@ int board_spisd_initialize(int minor, int bus)
 
   /* Mount filesystem */
 
-  ret = mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL);
+  ret = nx_mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL);
   if (ret < 0)
     {
-      _err("ERROR: Failed to mount the SDCARD. %d\n", errno);
+      _err("ERROR: Failed to mount the SDCARD. %d\n", ret);
     }
 
   return OK;
diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c
index b2b8b55..12976b1 100644
--- a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c
+++ b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c
@@ -25,14 +25,13 @@
 #include <nuttx/config.h>
 
 #include <stdio.h>
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
-#include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <arch/board/board.h>
 
 #ifdef CONFIG_RNDIS
@@ -325,10 +324,10 @@ int cxd56_bringup(void)
     }
 #endif
 
-  ret = mount(NULL, CXD56_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CXD56_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
-      _err("ERROR: Failed to mount the procfs: %d\n", errno);
+      _err("ERROR: Failed to mount the procfs: %d\n", ret);
     }
 #endif
 
@@ -360,7 +359,7 @@ int cxd56_bringup(void)
   ret = board_flash_initialize();
   if (ret < 0)
     {
-      _err("ERROR: Failed to initialize SPI-Flash. %d\n", errno);
+      _err("ERROR: Failed to initialize SPI-Flash. %d\n", ret);
     }
 #endif
 
@@ -376,13 +375,13 @@ int cxd56_bringup(void)
   ret = board_isx012_initialize(IMAGER_I2C);
   if (ret < 0)
     {
-      _err("ERROR: Failed to initialize ISX012 board. %d\n", errno);
+      _err("ERROR: Failed to initialize ISX012 board. %d\n", ret);
     }
 
   devops  = isx012_initialize();
   if (devops == NULL)
     {
-      _err("ERROR: Failed to populate ISX012 devops. %d\n", errno);
+      _err("ERROR: Failed to populate ISX012 devops. %d\n", ret);
       ret = ERROR;
     }
 #endif /* CONFIG_VIDEO_ISX012 */
diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c
index 48b291d..7c59437 100644
--- a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c
+++ b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c
@@ -24,7 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <stdint.h>
@@ -34,6 +33,7 @@
 #include <debug.h>
 
 #include <nuttx/arch.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/sdio.h>
 #include <nuttx/wqueue.h>
@@ -148,7 +148,7 @@ static void board_sdcard_enable(FAR void *arg)
         {
           if (S_ISBLK(stat_sdio.st_mode))
             {
-              ret = mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL);
+              ret = nx_mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL);
               if (ret == 0)
                 {
                   finfo(
@@ -156,7 +156,7 @@ static void board_sdcard_enable(FAR void *arg)
                 }
               else
                 {
-                  _err("ERROR: Failed to mount the SDCARD. %d\n", errno);
+                  _err("ERROR: Failed to mount the SDCARD. %d\n", ret);
                   cxd56_sdio_resetstatus(g_sdhci.sdhci);
                   goto release_frequency_lock;
                 }
@@ -189,10 +189,10 @@ static void board_sdcard_disable(FAR void *arg)
     {
       /* un-mount */
 
-      ret = umount("/mnt/sd0");
+      ret = nx_umount2("/mnt/sd0", 0);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to unmount the SD Card: %d\n", errno);
+          ferr("ERROR: Failed to unmount the SD Card: %d\n", ret);
         }
 
       /* Report the new state to the SDIO driver */
diff --git a/boards/arm/eoss3/quickfeather/src/eoss3_bringup.c b/boards/arm/eoss3/quickfeather/src/eoss3_bringup.c
index cfc49bb..013c174 100644
--- a/boards/arm/eoss3/quickfeather/src/eoss3_bringup.c
+++ b/boards/arm/eoss3/quickfeather/src/eoss3_bringup.c
@@ -23,7 +23,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
diff --git a/boards/arm/imx6/sabre-6quad/src/imx_bringup.c b/boards/arm/imx6/sabre-6quad/src/imx_bringup.c
index ca1ba7b..b4e13a7 100644
--- a/boards/arm/imx6/sabre-6quad/src/imx_bringup.c
+++ b/boards/arm/imx6/sabre-6quad/src/imx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "sabre-6quad.h"
 
 /****************************************************************************
@@ -64,7 +65,7 @@ int imx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c
index ef5745b..b7b6e04 100644
--- a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c
+++ b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_bringup.c
@@ -40,11 +40,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <syslog.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/wireless/bluetooth/bt_uart.h>
 
@@ -178,7 +178,7 @@ int imxrt_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
index b1d1ca3..a99ad80 100644
--- a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
+++ b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
@@ -39,11 +39,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
 #include <syslog.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/video/fb.h>
 #include <imxrt_lpi2c.h>
@@ -151,7 +151,7 @@ int imxrt_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c
index e9c0c77..558a427 100644
--- a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c
+++ b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c
@@ -40,11 +40,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
 #include <syslog.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/video/fb.h>
 #include <imxrt_lpi2c.h>
@@ -165,7 +165,7 @@ int imxrt_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c b/boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c
index 5819e62..6c84308 100644
--- a/boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c
+++ b/boards/arm/imxrt/teensy-4.x/src/imxrt_bringup.c
@@ -24,11 +24,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
 #include <syslog.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/video/fb.h>
 #include <imxrt_lpi2c.h>
@@ -127,7 +127,7 @@ int imxrt_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/kinetis/freedom-k28f/src/k28_bringup.c b/boards/arm/kinetis/freedom-k28f/src/k28_bringup.c
index f55d398..744266d 100644
--- a/boards/arm/kinetis/freedom-k28f/src/k28_bringup.c
+++ b/boards/arm/kinetis/freedom-k28f/src/k28_bringup.c
@@ -24,7 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
@@ -32,6 +31,8 @@
 
 #include "freedom-k28f.h"
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_PL2303
 #  include <nuttx/usb/pl2303.h>
 #endif
@@ -66,7 +67,7 @@ int k28_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
@@ -103,15 +104,15 @@ int k28_bringup(void)
     {
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_FRDMK28F_SDHC_MOUNT_BLKDEV,
-                  CONFIG_FRDMK28F_SDHC_MOUNT_MOUNTPOINT,
-                  CONFIG_FRDMK28F_SDHC_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_FRDMK28F_SDHC_MOUNT_BLKDEV,
+                     CONFIG_FRDMK28F_SDHC_MOUNT_MOUNTPOINT,
+                     CONFIG_FRDMK28F_SDHC_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
-                 CONFIG_FRDMK28F_SDHC_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_FRDMK28F_SDHC_MOUNT_MOUNTPOINT, ret);
         }
     }
 
diff --git a/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c b/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c
index f5c47c6..5a4e0e3 100644
--- a/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c
+++ b/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c
@@ -48,6 +48,7 @@
 #include <assert.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/irq.h>
 #include <nuttx/kthread.h>
 #include <nuttx/usb/usbdev.h>
@@ -288,15 +289,11 @@ static void usb_msc_connect(FAR void *arg)
 
   /* Mount */
 
-  ret = mount((FAR const char *)blkdev, (FAR const char *)mntpnt,
+  ret = nx_mount((FAR const char *)blkdev, (FAR const char *)mntpnt,
       CONFIG_FRDMK28F_USB_AUTOMOUNT_FSTYPE, 0, NULL);
   if (ret < 0)
     {
-      int errcode = get_errno();
-      DEBUGASSERT(errcode > 0);
-
-      ferr("ERROR: Mount failed: %d\n", errcode);
-      UNUSED(errcode);
+      ferr("ERROR: Mount failed: %d\n", ret);
     }
 }
 
@@ -364,18 +361,15 @@ static void usb_msc_disconnect(FAR void *arg)
 
   /* Unmount */
 
-  ret = umount2((FAR const char *)mntpnt, MNT_FORCE);
+  ret = nx_umount2((FAR const char *)mntpnt, MNT_FORCE);
   if (ret < 0)
     {
-      int errcode = get_errno();
-      DEBUGASSERT(errcode > 0);
-
       /* We expect the error to be EBUSY meaning that the volume could
        * not be unmounted because there are currently reference via open
        * files or directories.
        */
 
-      if (errcode == EBUSY)
+      if (ret == -EBUSY)
         {
           finfo("WARNING: Volume is busy, try again later\n");
 
diff --git a/boards/arm/kinetis/freedom-k64f/src/k64_bringup.c b/boards/arm/kinetis/freedom-k64f/src/k64_bringup.c
index aadb0cf..a3d6288 100644
--- a/boards/arm/kinetis/freedom-k64f/src/k64_bringup.c
+++ b/boards/arm/kinetis/freedom-k64f/src/k64_bringup.c
@@ -40,11 +40,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef HAVE_RTC_DRIVER
 #  include <nuttx/timers/rtc.h>
 #  include "kinetis_alarm.h"
@@ -78,12 +79,11 @@ int k64_bringup(void)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n",  ret);
       return ret;
     }
 #endif
@@ -108,15 +108,15 @@ int k64_bringup(void)
     {
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_FRDMK64F_SDHC_MOUNT_BLKDEV,
-                  CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT,
-                  CONFIG_FRDMK64F_SDHC_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_FRDMK64F_SDHC_MOUNT_BLKDEV,
+                     CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT,
+                     CONFIG_FRDMK64F_SDHC_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
-                 CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_FRDMK64F_SDHC_MOUNT_MOUNTPOINT, ret);
         }
     }
 
diff --git a/boards/arm/kinetis/freedom-k66f/src/k66_bringup.c b/boards/arm/kinetis/freedom-k66f/src/k66_bringup.c
index b399408..19a8ffe 100644
--- a/boards/arm/kinetis/freedom-k66f/src/k66_bringup.c
+++ b/boards/arm/kinetis/freedom-k66f/src/k66_bringup.c
@@ -41,11 +41,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 #include <debug.h>
+
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/input/buttons.h>
@@ -79,12 +80,11 @@ int k66_bringup(void)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
@@ -103,15 +103,15 @@ int k66_bringup(void)
     {
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_FRDMK66F_SDHC_MOUNT_BLKDEV,
-                  CONFIG_FRDMK66F_SDHC_MOUNT_MOUNTPOINT,
-                  CONFIG_FRDMK66F_SDHC_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_FRDMK66F_SDHC_MOUNT_BLKDEV,
+                     CONFIG_FRDMK66F_SDHC_MOUNT_MOUNTPOINT,
+                     CONFIG_FRDMK66F_SDHC_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
-                 CONFIG_FRDMK66F_SDHC_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_FRDMK66F_SDHC_MOUNT_MOUNTPOINT, ret);
         }
     }
 
diff --git a/boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c b/boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c
index f29ceb6..3ecf2eb 100644
--- a/boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c
+++ b/boards/arm/kinetis/twr-k64f120m/src/k64_appinit.c
@@ -43,9 +43,9 @@
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
-#include <sys/mount.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #ifdef CONFIG_KINETIS_SDHC
 #  include <nuttx/sdio.h>
@@ -93,12 +93,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n",  ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/lc823450/lc823450-xgevk/src/lc823450_bringup.c b/boards/arm/lc823450/lc823450-xgevk/src/lc823450_bringup.c
index ce19482..45a9ca8 100644
--- a/boards/arm/lc823450/lc823450-xgevk/src/lc823450_bringup.c
+++ b/boards/arm/lc823450/lc823450-xgevk/src/lc823450_bringup.c
@@ -25,7 +25,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 
 #include <stdbool.h>
 #include <syslog.h>
@@ -34,6 +33,7 @@
 #  include <sched.h>
 #endif
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/sched.h>
 
 #ifdef CONFIG_RNDIS
@@ -78,7 +78,7 @@ int lc823450_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
@@ -86,7 +86,7 @@ int lc823450_bringup(void)
 #endif
 
 #ifdef CONFIG_FS_FAT
-  ret = mount("/dev/mtdblock0p10", "/mnt/sd0", "vfat", 0, NULL);
+  ret = nx_mount("/dev/mtdblock0p10", "/mnt/sd0", "vfat", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount vfat at /mnt/sd0: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c
index 8c0d993..a657826 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -49,6 +48,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/video/fb.h>
@@ -354,7 +354,7 @@ int lpc4088_devkit_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system at the default location, /proc */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
index 89723bc..d43cfa5 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -49,6 +48,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/video/fb.h>
@@ -390,7 +390,7 @@ int lpc4088_quickstart_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system at the default location, /proc */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
index d975e32..2884bfe 100644
--- a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
@@ -44,11 +44,11 @@
 #include <syslog.h>
 #include <errno.h>
 #include <assert.h>
-#include <sys/mount.h>
 
 #include <nuttx/arch.h>
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/video/fb.h>
@@ -390,7 +390,7 @@ int lx_cpu_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system at the default location, /proc */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c
index 2574198..4a2dedf 100644
--- a/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -47,6 +46,7 @@
 
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/spi/spi.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/usb/usbhost.h>
@@ -373,7 +373,7 @@ int mcb1700_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c
index 810a18f..0376256 100644
--- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c
@@ -39,12 +39,12 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/kthread.h>
 #include <nuttx/spi/spi.h>
 #include <nuttx/mmcsd.h>
@@ -392,7 +392,7 @@ int lpc17_40_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
index 4b83b23..b107057 100644
--- a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -49,6 +48,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/video/fb.h>
@@ -389,7 +389,7 @@ int open1788_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system at the default location, /proc */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret);
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
index 46b2fbd..a1bde89 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
@@ -42,9 +42,9 @@
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
-#include <sys/mount.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/spi/spi.h>
 #include <nuttx/binfmt/elf.h>
 #include <nuttx/binfmt/nxflat.h>
@@ -120,21 +120,20 @@ int pnev5180b_bringup(void)
   int ret = OK;
 
 #ifdef CONFIG_FS_PROCFS
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+      syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d\n",
+             ret);
       goto done;
     }
 #endif
 
 #ifdef CONFIG_FS_BINFS
-  ret = mount(NULL, "/bin", "binfs", 0, NULL);
+  ret = nx_mount(NULL, "/bin", "binfs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the BIN filesystem: %d (%d)\n",
-             ret, errno);
+      syslog(LOG_ERR, "ERROR: Failed to mount the BIN filesystem: %d\n", ret);
       goto done;
     }
 #endif
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
index bf24016..41636d1 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
@@ -51,6 +51,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "lpc17_40_romfs.h"
 
@@ -146,12 +147,12 @@ int lpc17_40_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_LPC17_40_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_LPC17_40_ROMFS_MOUNTPOINT,
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_LPC17_40_ROMFS_MOUNTPOINT,
               "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_LPC17_40_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_LPC17_40_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/lpc17xx_40xx/u-blox-c027/src/lpc17_40_appinit.c b/boards/arm/lpc17xx_40xx/u-blox-c027/src/lpc17_40_appinit.c
index 704b1e4..0e9311d 100644
--- a/boards/arm/lpc17xx_40xx/u-blox-c027/src/lpc17_40_appinit.c
+++ b/boards/arm/lpc17xx_40xx/u-blox-c027/src/lpc17_40_appinit.c
@@ -44,11 +44,10 @@
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/spi/spi.h>
 #include <nuttx/mmcsd.h>
 
-#include <sys/mount.h>
-
 #include "lpc17_40_ssp.h"
 
 /****************************************************************************
@@ -156,12 +155,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c b/boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c
index c26eda2..3c1465c 100644
--- a/boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c
+++ b/boards/arm/lpc214x/zp214xpa/src/lpc2148_appinit.c
@@ -84,7 +84,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c b/boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c
index 85e565e..2ba4998 100644
--- a/boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c
+++ b/boards/arm/lpc31xx/ea3131/src/lpc31_fillpage.c
@@ -183,7 +183,7 @@
 struct pg_source_s
 {
   bool initialized;  /* TRUE: we are initialized */
-  int  fd;           /* File descriptor of the nuttx.bin file */
+  struct file file;  /* File descriptor of the nuttx.bin file */
 };
 #endif
 
@@ -272,16 +272,16 @@ static inline void lpc31_initsrc(void)
       /* Now mount the file system */
 
       snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_EA3131_PAGING_MINOR);
-      ret = mount(devname, CONFIG_EA3131_PAGING_MOUNTPT, "vfat", MS_RDONLY,
-                  NULL);
+      ret = nx_mount(devname, CONFIG_EA3131_PAGING_MOUNTPT, "vfat",
+                     MS_RDONLY, NULL);
       DEBUGASSERT(ret == OK);
 
 #endif /* CONFIG_EA3131_PAGING_SDSLOT */
 
       /* Open the selected path for read-only access */
 
-      g_pgsrc.fd = nx_open(CONFIG_PAGING_BINPATH, O_RDONLY);
-      DEBUGASSERT(g_pgsrc.fd >= 0);
+      file_open(&g_pgsrc.file, CONFIG_PAGING_BINPATH, O_RDONLY);
+      DEBUGASSERT(g_pgsrc.file.f_inode != NULL);
 
       /* Then we are initialized */
 
@@ -443,12 +443,12 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage)
 
   /* Seek to that position */
 
-  pos = nx_seek(g_pgsrc.fd, offset, SEEK_SET);
+  pos = file_seek(&g_pgsrc.file, offset, SEEK_SET);
   DEBUGASSERT(pos != (off_t)-1);
 
   /* And read the page data from that offset */
 
-  nbytes = nx_read(g_pgsrc.fd, vpage, PAGESIZE);
+  nbytes = file_read(&g_pgsrc.file, vpage, PAGESIZE);
   DEBUGASSERT(nbytes == PAGESIZE);
   return OK;
 
diff --git a/boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c b/boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c
index eb9d75d..98f99e8 100644
--- a/boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c
+++ b/boards/arm/lpc31xx/ea3152/src/lpc31_fillpage.c
@@ -182,7 +182,7 @@
 struct pg_source_s
 {
   bool initialized;  /* TRUE: we are initialized */
-  int  fd;           /* File descriptor of the nuttx.bin file */
+  struct file file;  /* File descriptor of the nuttx.bin file */
 };
 #endif
 
@@ -272,16 +272,16 @@ static inline void lpc31_initsrc(void)
       /* Now mount the file system */
 
       snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_EA3152_PAGING_MINOR);
-      ret = mount(devname, CONFIG_EA3152_PAGING_MOUNTPT, "vfat", MS_RDONLY,
-                  NULL);
+      ret = nx_mount(devname, CONFIG_EA3152_PAGING_MOUNTPT, "vfat",
+                     MS_RDONLY, NULL);
       DEBUGASSERT(ret == OK);
 
 #endif /* CONFIG_EA3152_PAGING_SDSLOT */
 
       /* Open the selected path for read-only access */
 
-      g_pgsrc.fd = nx_open(CONFIG_PAGING_BINPATH, O_RDONLY);
-      DEBUGASSERT(g_pgsrc.fd >= 0);
+      file_open(&g_pgsrc.file, CONFIG_PAGING_BINPATH, O_RDONLY);
+      DEBUGASSERT(g_pgsrc.file.f_inode != NULL);
 
       /* Then we are initialized */
 
@@ -444,12 +444,12 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage)
 
   /* Seek to that position */
 
-  pos = nx_seek(g_pgsrc.fd, offset, SEEK_SET);
+  pos = file_seek(&g_pgsrc.file, offset, SEEK_SET);
   DEBUGASSERT(pos != (off_t)-1);
 
   /* And read the page data from that offset */
 
-  nbytes = nx_read(g_pgsrc.fd, vpage, PAGESIZE);
+  nbytes = file_read(&g_pgsrc.file, vpage, PAGESIZE);
   DEBUGASSERT(nbytes == PAGESIZE);
   return OK;
 
diff --git a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
index fabd18e..14a57ec 100644
--- a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
@@ -53,7 +53,7 @@
 #  include "lpc43_spifi.h"
 
 #  ifdef CONFIG_SPFI_NXFFS
-#    include <sys/mount.h>
+#    include <nuttx/fs/fs.h>
 #    include <nuttx/fs/nxffs.h>
 #  endif
 #endif
@@ -125,10 +125,10 @@ static int nsh_spifi_initialize(void)
 
   /* Mount the file system at /mnt/spifi */
 
-  ret = mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
index 5a3975d..46b7471 100644
--- a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
@@ -52,7 +52,7 @@
 #  include "lpc43_spifi.h"
 
 #  ifdef CONFIG_SPFI_NXFFS
-#    include <sys/mount.h>
+#    include <nuttx/fs/fs.h>
 #    include <nuttx/fs/nxffs.h>
 #  endif
 #endif
@@ -116,10 +116,10 @@ static int nsh_spifi_initialize(void)
 
   /* Mount the file system at /mnt/spifi */
 
-  ret = mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
index 977e594..5598495 100644
--- a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
@@ -52,7 +52,7 @@
 #  include "lpc43_spifi.h"
 
 #  ifdef CONFIG_SPFI_NXFFS
-#    include <sys/mount.h>
+#    include <nuttx/fs/fs.h>
 #    include <nuttx/fs/nxffs.h>
 #  endif
 #endif
@@ -116,10 +116,10 @@ static int nsh_spifi_initialize(void)
 
   /* Mount the file system at /mnt/spifi */
 
-  ret = mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/spifi", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/src/lpc54_bringup.c b/boards/arm/lpc54xx/lpcxpresso-lpc54628/src/lpc54_bringup.c
index 107a449..52a1b45 100644
--- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/src/lpc54_bringup.c
+++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/src/lpc54_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_VIDEO_FB
 #  include <nuttx/video/fb.h>
 #endif
@@ -95,7 +96,7 @@ int lpc54_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/max326xx/max32660-evsys/src/max326_bringup.c b/boards/arm/max326xx/max32660-evsys/src/max326_bringup.c
index 9d4f87f..d4dea0d 100644
--- a/boards/arm/max326xx/max32660-evsys/src/max326_bringup.c
+++ b/boards/arm/max326xx/max32660-evsys/src/max326_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "max32660-evsys.h"
 
 /****************************************************************************
@@ -87,7 +88,7 @@ int max326_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c
index 1421ebb..fcfa59e 100644
--- a/boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c
+++ b/boards/arm/nrf52/nrf52832-mdk/src/nrf52_bringup.c
@@ -28,7 +28,7 @@
 #include <syslog.h>
 
 #ifdef CONFIG_FS_PROCFS
-#include <sys/mount.h>
+#include <nuttx/fs/fs.h>
 #endif
 
 #ifdef CONFIG_NRF52_WDT
@@ -66,7 +66,7 @@ int nrf52_bringup(void)
   int ret;
 
 #ifdef CONFIG_FS_PROCFS
-  mount(NULL, "/proc", "procfs", 0, NULL);
+  nx_mount(NULL, "/proc", "procfs", 0, NULL);
 #endif
 
 #ifdef CONFIG_NRF52_WDT
diff --git a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c
index 5f25f7f..0f1002d 100644
--- a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c
+++ b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c
@@ -26,7 +26,8 @@
 
 #include <debug.h>
 #include <stddef.h>
-#include <sys/mount.h>
+
+#include <nuttx/fs/fs.h>
 
 #include "rp2040_pico.h"
 
@@ -45,7 +46,7 @@ int rp2040_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/arm/s32k1xx/rddrone-uavcan144/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/rddrone-uavcan144/src/s32k1xx_bringup.c
index f6c137a..00b83eb 100644
--- a/boards/arm/s32k1xx/rddrone-uavcan144/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/rddrone-uavcan144/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -108,7 +109,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c
index 47cdb36..012d240 100644
--- a/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -108,7 +109,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c
index ccb5900..09ec8ef 100644
--- a/boards/arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/s32k118evb/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -102,7 +103,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c
index daedd84..10b8eb5 100644
--- a/boards/arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/s32k144evb/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -107,7 +108,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c
index f650a34..d2434a9 100644
--- a/boards/arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/s32k146evb/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -107,7 +108,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c
index 39a1060..a038be0 100644
--- a/boards/arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c
+++ b/boards/arm/s32k1xx/s32k148evb/src/s32k1xx_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -106,7 +107,7 @@ int s32k1xx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/sam34/arduino-due/src/sam_bringup.c b/boards/arm/sam34/arduino-due/src/sam_bringup.c
index 23d29af..6268519 100644
--- a/boards/arm/sam34/arduino-due/src/sam_bringup.c
+++ b/boards/arm/sam34/arduino-due/src/sam_bringup.c
@@ -39,11 +39,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include "arduino-due.h"
 
@@ -97,7 +97,7 @@ int sam_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n",
diff --git a/boards/arm/sam34/flipnclick-sam3x/src/sam_bringup.c b/boards/arm/sam34/flipnclick-sam3x/src/sam_bringup.c
index 4b3c9bd..18c9d22 100644
--- a/boards/arm/sam34/flipnclick-sam3x/src/sam_bringup.c
+++ b/boards/arm/sam34/flipnclick-sam3x/src/sam_bringup.c
@@ -39,11 +39,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include "flipnclick-sam3x.h"
 
@@ -76,7 +76,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n",
diff --git a/boards/arm/sam34/sam4cmp-db/src/sam_bringup.c b/boards/arm/sam34/sam4cmp-db/src/sam_bringup.c
index 4e33ca9..da96e63 100644
--- a/boards/arm/sam34/sam4cmp-db/src/sam_bringup.c
+++ b/boards/arm/sam34/sam4cmp-db/src/sam_bringup.c
@@ -40,11 +40,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 
 #include <stdbool.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -64,7 +65,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/sam34/sam4e-ek/src/sam_appinit.c b/boards/arm/sam34/sam4e-ek/src/sam_appinit.c
index 61e2d0f..24bf51e 100644
--- a/boards/arm/sam34/sam4e-ek/src/sam_appinit.c
+++ b/boards/arm/sam34/sam4e-ek/src/sam_appinit.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/boards/arm/sam34/sam4e-ek/src/sam_at25.c b/boards/arm/sam34/sam4e-ek/src/sam_at25.c
index a13dda3..3d6a924 100644
--- a/boards/arm/sam34/sam4e-ek/src/sam_at25.c
+++ b/boards/arm/sam34/sam4e-ek/src/sam_at25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "sam_spi.h"
@@ -125,10 +124,10 @@ int sam_at25_automount(int minor)
 
       /* Mount the file system at /mnt/at25 */
 
-      ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sam34/sam4s-xplained-pro/src/sam_appinit.c b/boards/arm/sam34/sam4s-xplained-pro/src/sam_appinit.c
index 031590c..ad86614 100644
--- a/boards/arm/sam34/sam4s-xplained-pro/src/sam_appinit.c
+++ b/boards/arm/sam34/sam4s-xplained-pro/src/sam_appinit.c
@@ -40,8 +40,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -50,6 +48,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #ifdef CONFIG_CDCACM
 #  include <nuttx/usb/cdcacm.h>
@@ -108,8 +107,7 @@ int board_app_initialize(uintptr_t arg)
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to create the CDC/ACM serial device: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to create the CDC/ACM serial device: %d\n", ret);
       return ret;
     }
 #endif
@@ -118,9 +116,7 @@ int board_app_initialize(uintptr_t arg)
   ret = sam_nand_automount(SAM_SMC_CS0);
   if (ret < 0)
     {
-      syslog(LOG_ERR,
-             "ERROR: Failed to initialize the NAND: %d (%d)\n",
-             ret, errno);
+      syslog(LOG_ERR, "ERROR: Failed to initialize the NAND: %d\n", ret);
       return ret;
     }
 #endif
@@ -133,9 +129,7 @@ int board_app_initialize(uintptr_t arg)
   ret = sam_hsmci_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR,
-             "ERROR: sam_hsmci_initialize() failed: %d (%d)\n",
-             ret, errno);
+      syslog(LOG_ERR, "ERROR: sam_hsmci_initialize() failed: %d\n", ret);
       return ret;
     }
 #endif
@@ -145,12 +139,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
@@ -158,12 +151,11 @@ int board_app_initialize(uintptr_t arg)
 #if HAVE_HSMCI
   syslog(LOG_INFO, "Mounting /dev/mmcsd0 to /fat\n");
 
-  ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL);
+  ret = nx_mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the FAT filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the FAT filesystem: %d\n", ret);
       return ret;
     }
 #endif
@@ -174,8 +166,7 @@ int board_app_initialize(uintptr_t arg)
   ret = sam_sdinitialize(0, 0);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to initialize MMC/SD slot: %d\n",
-             ret);
+      syslog(LOG_ERR, "ERROR: Failed to initialize MMC/SD slot: %d\n", ret);
       return ret;
     }
 #endif
@@ -187,8 +178,7 @@ int board_app_initialize(uintptr_t arg)
   ret = usbmonitor_start();
   if (ret != OK)
     {
-      syslog(LOG_ERR,
-             "ERROR: Failed to start USB monitor: %d (%d)\n", ret, errno);
+      syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c b/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c
index 0374369..74f55f8 100644
--- a/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c
+++ b/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c
@@ -24,13 +24,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 #include <arch/board/board.h>
 
@@ -226,10 +226,10 @@ int sam_nand_automount(int minor)
 
       /* Mount the file system at /mnt/nand */
 
-      ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c b/boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c
index d980e94..ebb0c89 100644
--- a/boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c
+++ b/boards/arm/sam34/sam4s-xplained-pro/src/sam_wdt.c
@@ -114,7 +114,7 @@ static int wdog_daemon(int argc, char *argv[])
   ret = file_ioctl(&filestruct, WDIOC_START, 0);
   if (ret < 0)
     {
-      wderr("ERROR: ioctl(WDIOC_START) failed: %d\n", errno);
+      wderr("ERROR: file_ioctl(WDIOC_START) failed: %d\n", ret);
       goto errout_with_dev;
     }
 
@@ -127,7 +127,7 @@ static int wdog_daemon(int argc, char *argv[])
       ret = file_ioctl(&filestruct, WDIOC_KEEPALIVE, 0);
       if (ret < 0)
         {
-          wderr("ERROR: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno);
+          wderr("ERROR: file_ioctl(WDIOC_KEEPALIVE) failed: %d\n", ret);
           goto errout_with_dev;
         }
     }
@@ -180,7 +180,7 @@ int sam_watchdog_initialize(void)
                    (unsigned long)CONFIG_WDT_TIMEOUT);
   if (ret < 0)
     {
-      wderr("ERROR: ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno);
+      wderr("ERROR: file_ioctl(WDIOC_SETTIMEOUT) failed: %d\n", ret);
       goto errout_with_dev;
     }
 
@@ -191,7 +191,7 @@ int sam_watchdog_initialize(void)
                    (unsigned long)CONFIG_WDT_MINTIME);
   if (ret < 0)
     {
-      wderr("ERROR: ioctl(WDIOC_MINTIME) failed: %d\n", errno);
+      wderr("ERROR: file_ioctl(WDIOC_MINTIME) failed: %d\n", ret);
       goto errout_with_dev;
     }
 
diff --git a/boards/arm/sama5/giant-board/src/sam_bringup.c b/boards/arm/sama5/giant-board/src/sam_bringup.c
index b12f5c6..0726384 100644
--- a/boards/arm/sama5/giant-board/src/sam_bringup.c
+++ b/boards/arm/sama5/giant-board/src/sam_bringup.c
@@ -30,6 +30,7 @@
 #include <debug.h>
 #include <string.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/irq.h>
 #include <nuttx/kthread.h>
 #include <nuttx/usb/usbdev.h>
@@ -171,15 +172,15 @@ static int nsh_sdmmc_initialize(void)
 #ifdef CONFIG_SAMA5D27_SDMMC0_MOUNT
   /* Mount the volume on SDMMC0 */
 
-  ret = mount(CONFIG_SAMA5D27_SDMMC0_MOUNT_BLKDEV,
-              CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT,
-              CONFIG_SAMA5D27_SDMMC0_MOUNT_FSTYPE,
-              0, NULL);
+  ret = nx_mount(CONFIG_SAMA5D27_SDMMC0_MOUNT_BLKDEV,
+                 CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT,
+                 CONFIG_SAMA5D27_SDMMC0_MOUNT_FSTYPE,
+                 0, NULL);
 
   if (ret < 0)
     {
       mcerr("ERROR: Failed to mount %s: %d\n",
-           CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT, errno);
+           CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT, ret);
     }
 #endif
 #endif
@@ -207,15 +208,15 @@ static int nsh_sdmmc_initialize(void)
 #ifdef CONFIG_SAMA5D27_SDMMC1_MOUNT
   /* Mount the volume on SDMMC1 */
 
-  ret = mount(CONFIG_SAMA5D27_SDMMC1_MOUNT_BLKDEV,
-              CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT,
-              CONFIG_SAMA5D27_SDMMC1_MOUNT_FSTYPE,
-              0, NULL);
+  ret = nx_mount(CONFIG_SAMA5D27_SDMMC1_MOUNT_BLKDEV,
+                 CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT,
+                 CONFIG_SAMA5D27_SDMMC1_MOUNT_FSTYPE,
+                 0, NULL);
 
   if (ret < 0)
     {
       mcerr("ERROR: Failed to mount %s: %d\n",
-           CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT, errno);
+           CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT, ret);
     }
 #endif
 #endif
@@ -274,14 +275,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_GIANT_BOARD_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_GIANT_BOARD_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_GIANT_BOARD_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_GIANT_BOARD_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          fserr("ERROR: mount(%s,%s,romfs) failed: %d\n",
+          fserr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                CONFIG_GIANT_BOARD_ROMFS_ROMDISK_DEVNAME,
-               CONFIG_GIANT_BOARD_ROMFS_MOUNT_MOUNTPOINT, errno);
+               CONFIG_GIANT_BOARD_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -361,7 +362,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
index 4827b69..d839b72 100644
--- a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -33,6 +31,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "sam_spi.h"
@@ -109,10 +108,10 @@ int sam_at25_automount(int minor)
 
       /* Mount the file system at /mnt/at25 */
 
-      ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c
index ae0ea3f..c9fc04c 100644
--- a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c
+++ b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c
@@ -30,6 +30,7 @@
 #include <debug.h>
 #include <string.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/irq.h>
 #include <nuttx/kthread.h>
 #include <nuttx/usb/usbdev.h>
@@ -172,15 +173,15 @@ static int nsh_sdmmc_initialize(void)
 #ifdef CONFIG_SAMA5D27_SDMMC0_MOUNT
   /* Mount the volume on SDMMC0 */
 
-  ret = mount(CONFIG_SAMA5D27_SDMMC0_MOUNT_BLKDEV,
-              CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT,
-              CONFIG_SAMA5D27_SDMMC0_MOUNT_FSTYPE,
-              0, NULL);
+  ret = nx_mount(CONFIG_SAMA5D27_SDMMC0_MOUNT_BLKDEV,
+                 CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT,
+                 CONFIG_SAMA5D27_SDMMC0_MOUNT_FSTYPE,
+                 0, NULL);
 
   if (ret < 0)
     {
       _err("ERROR: Failed to mount %s: %d\n",
-           CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT, errno);
+           CONFIG_SAMA5D27_SDMMC0_MOUNT_MOUNTPOINT, ret);
     }
 #endif
 #endif
@@ -208,15 +209,15 @@ static int nsh_sdmmc_initialize(void)
 #ifdef CONFIG_SAMA5D27_SDMMC1_MOUNT
   /* Mount the volume on SDMMC1 */
 
-  ret = mount(CONFIG_SAMA5D27_SDMMC1_MOUNT_BLKDEV,
-              CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT,
-              CONFIG_SAMA5D27_SDMMC1_MOUNT_FSTYPE,
-              0, NULL);
+  ret = nx_mount(CONFIG_SAMA5D27_SDMMC1_MOUNT_BLKDEV,
+                 CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT,
+                 CONFIG_SAMA5D27_SDMMC1_MOUNT_FSTYPE,
+                 0, NULL);
 
   if (ret < 0)
     {
       _err("ERROR: Failed to mount %s: %d\n",
-           CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT, errno);
+           CONFIG_SAMA5D27_SDMMC1_MOUNT_MOUNTPOINT, ret);
     }
 #endif
 #endif
@@ -275,15 +276,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -306,15 +307,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI1 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -341,14 +342,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          _err("ERROR: mount(%s,%s,romfs) failed: %d\n",
+          _err("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -428,7 +429,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       _err("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c b/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c
index 81e64b4..3047138 100644
--- a/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c
@@ -24,13 +24,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "arm_arch.h"
@@ -192,10 +192,10 @@ int sam_nand_automount(int minor)
 
       /* Mount the file system at /mnt/nand */
 
-      ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_appinit.c b/boards/arm/sama5/sama5d3-xplained/src/sam_appinit.c
index 65389f7..c3797a2 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_appinit.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_appinit.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
index c0b7518..e31c7aa 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "sam_spi.h"
@@ -124,10 +123,10 @@ int sam_at25_automount(int minor)
 
       /* Mount the file system at /mnt/at25 */
 
-      ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c b/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
index d4332ae..47013cc 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
@@ -46,6 +46,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -176,15 +178,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -207,15 +209,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI1 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -242,14 +244,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          _err("ERROR: mount(%s,%s,romfs) failed: %d\n",
+          _err("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -329,7 +331,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       _err("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
index 1ab6a0e..38e86cc 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
@@ -46,13 +46,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "arm_arch.h"
@@ -213,10 +213,10 @@ int sam_nand_automount(int minor)
 
       /* Mount the file system at /mnt/nand */
 
-      ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c b/boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c
index 350d6ae..0857c12 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_appinit.c
@@ -39,14 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
@@ -227,7 +226,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
index 07052a6..7ad8e71 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
@@ -57,8 +57,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -66,6 +64,7 @@
 
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "sam_twi.h"
@@ -147,10 +146,10 @@ int sam_at24_automount(int minor)
       /* Mount the file system at /mnt/at24 */
 
       finfo("Mount the NXFFS file system at /dev/at24\n");
-      ret = mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c b/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c
index 80abece..4e0b39f 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "sam_spi.h"
@@ -125,10 +124,10 @@ int sam_at25_automount(int minor)
 
       /* Mount the file system at /mnt/at25 */
 
-      ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
index a02732a..52f4d0a 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
@@ -46,13 +46,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "arm_arch.h"
@@ -213,10 +213,10 @@ int sam_nand_automount(int minor)
 
       /* Mount the file system at /mnt/nand */
 
-      ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/sama5/sama5d4-ek/src/at25_main.c b/boards/arm/sama5/sama5d4-ek/src/at25_main.c
index f1a53f6..10af0ec 100644
--- a/boards/arm/sama5/sama5d4-ek/src/at25_main.c
+++ b/boards/arm/sama5/sama5d4-ek/src/at25_main.c
@@ -145,7 +145,7 @@ int at25_main(int argc, char *argv)
   fd = open(g_at25dev, O_WRONLY);
   if (fd < 0)
     {
-      int errcode = get_errno();
+      int errcode = errno;
       fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode);
       return EXIT_FAILURE;
     }
@@ -206,7 +206,7 @@ int at25_main(int argc, char *argv)
       nwritten = write(fd, src, memoutstream.public.nput);
       if (nwritten <= 0)
         {
-          int errcode = get_errno();
+          int errcode = errno;
           if (errno != EINTR)
             {
               fprintf(stderr, "ERROR: Write failed: %d\n", errcode);
@@ -236,7 +236,7 @@ int at25_main(int argc, char *argv)
   fd = open(g_at25dev, O_RDONLY);
   if (fd < 0)
     {
-      int errcode = get_errno();
+      int errcode = errno;
       fprintf(stderr, "ERROR: Failed to open %s: %d\n", g_at25dev, errcode);
       return EXIT_FAILURE;
     }
@@ -255,7 +255,7 @@ int at25_main(int argc, char *argv)
       nread = read(fd, g_iobuffer, rdsize);
       if (nread <= 0)
         {
-          int errcode = get_errno();
+          int errcode = errno;
           if (errno != EINTR)
             {
               fprintf(stderr, "ERROR: Read failed: %d\n", errcode);
diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_at25.c b/boards/arm/sama5/sama5d4-ek/src/sam_at25.c
index 7456e5b..362f525 100644
--- a/boards/arm/sama5/sama5d4-ek/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d4-ek/src/sam_at25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 #include <nuttx/drivers/drivers.h>
 
@@ -154,10 +153,10 @@ int sam_at25_automount(int minor)
 
       /* Mount the file system at /mnt/at25 */
 
-      ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at25", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 
diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c b/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
index d5617d1..f4ae399 100644
--- a/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
+++ b/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
@@ -46,6 +46,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -191,15 +193,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -222,15 +224,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI1 */
 
-      ret = mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           _err("ERROR: Failed to mount %s: %d\n",
-               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -257,14 +259,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          _err("ERROR: mount(%s,%s,romfs) failed: %d\n",
+          _err("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                CONFIG_SAMA5D4EK_ROMFS_ROMDISK_DEVNAME,
-               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, errno);
+               CONFIG_SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -344,7 +346,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMA5_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       _err("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
index 5e644d1..ccfa04c 100644
--- a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
@@ -46,13 +46,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "arm_arch.h"
@@ -213,10 +213,10 @@ int sam_nand_automount(int minor)
 
       /* Mount the file system at /mnt/nand */
 
-      ret = mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nand", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/samd5e5/metro-m4/src/sam_at24.c b/boards/arm/samd5e5/metro-m4/src/sam_at24.c
index 21f9608..278fc00 100644
--- a/boards/arm/samd5e5/metro-m4/src/sam_at24.c
+++ b/boards/arm/samd5e5/metro-m4/src/sam_at24.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -33,6 +31,7 @@
 
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "metro-m4.h"
@@ -106,11 +105,11 @@ int sam_at24_automount(int minor)
       /* Mount the file system at /mnt/at24 */
 
       finfo("Mount the NXFFS file system at /dev/at24\n");
-      ret = mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
       if (ret < 0)
         {
           ferr("ERROR: Failed to mount the NXFFS volume: %d\n",
-                errno);
+                ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/samd5e5/metro-m4/src/sam_bringup.c b/boards/arm/samd5e5/metro-m4/src/sam_bringup.c
index 8e86759..b469163 100644
--- a/boards/arm/samd5e5/metro-m4/src/sam_bringup.c
+++ b/boards/arm/samd5e5/metro-m4/src/sam_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
@@ -51,6 +50,8 @@
   #include "sam_wdt.h"
 #endif
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_SAMD5E5_SERCOM5_ISI2C
   #include <nuttx/i2c/i2c_master.h>
   #include "hardware/sam_i2c_master.h"
@@ -100,7 +101,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
@@ -154,7 +155,7 @@ int sam_bringup(void)
 
   /* Mount the file system at /mnt/nvm */
 
-  ret = mount("/dev/smart0", "/mnt/nvm", "smartfs", 0, NULL);
+  ret = nx_mount("/dev/smart0", "/mnt/nvm", "smartfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount the SmartFS volume: %d\n",
diff --git a/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c b/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c
index 033edf8..ea10239 100644
--- a/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c
+++ b/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c
@@ -29,7 +29,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <sched.h>
diff --git a/boards/arm/samd5e5/same54-xplained-pro/src/sam_bringup.c b/boards/arm/samd5e5/same54-xplained-pro/src/sam_bringup.c
index b2ea8a3..edde78f 100644
--- a/boards/arm/samd5e5/same54-xplained-pro/src/sam_bringup.c
+++ b/boards/arm/samd5e5/same54-xplained-pro/src/sam_bringup.c
@@ -39,12 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "same54-xplained-pro.h"
 
 /****************************************************************************
@@ -78,7 +79,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslot(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/samv7/same70-xplained/src/sam_bringup.c b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
index 0ab84fa..4fd09de 100644
--- a/boards/arm/samv7/same70-xplained/src/sam_bringup.c
+++ b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
@@ -53,6 +53,7 @@
 
 #include <nuttx/drivers/drivers.h>
 #include <nuttx/drivers/ramdisk.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 #include <nuttx/i2c/i2c_master.h>
 
@@ -177,7 +178,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAME70_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAME70_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
@@ -214,15 +215,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_BLKDEV,
-                  CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT,
-                  CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_BLKDEV,
+                     CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT,
+                     CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
-                 CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_SAME70XPLAINED_HSMCI0_MOUNT_MOUNTPOINT, ret);
         }
     }
 
@@ -249,14 +250,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          syslog(LOG_ERR, "ERROR: mount(%s,%s,romfs) failed: %d\n",
+          syslog(LOG_ERR, "ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                  CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_DEVNAME,
-                 CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_SAME70XPLAINED_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
diff --git a/boards/arm/samv7/samv71-xult/src/sam_bringup.c b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
index 62eaa1a..379be84 100644
--- a/boards/arm/samv7/samv71-xult/src/sam_bringup.c
+++ b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
@@ -47,6 +47,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -285,7 +287,7 @@ int sam_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SAMV71_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SAMV71_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
@@ -322,15 +324,15 @@ int sam_bringup(void)
 
       /* Mount the volume on HSMCI0 */
 
-      ret = mount(CONFIG_SAMV71XULT_HSMCI0_MOUNT_BLKDEV,
-                  CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT,
-                  CONFIG_SAMV71XULT_HSMCI0_MOUNT_FSTYPE,
-                  0, NULL);
+      ret = nx_mount(CONFIG_SAMV71XULT_HSMCI0_MOUNT_BLKDEV,
+                     CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT,
+                     CONFIG_SAMV71XULT_HSMCI0_MOUNT_FSTYPE,
+                     0, NULL);
 
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n",
-                 CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_SAMV71XULT_HSMCI0_MOUNT_MOUNTPOINT, ret);
         }
     }
 
@@ -357,14 +359,14 @@ int sam_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount(CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME,
-                  CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT,
-                  "romfs", MS_RDONLY, NULL);
+      ret = nx_mount(CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME,
+                     CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT,
+                     "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          syslog(LOG_ERR, "ERROR: mount(%s,%s,romfs) failed: %d\n",
+          syslog(LOG_ERR, "ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                  CONFIG_SAMV71XULT_ROMFS_ROMDISK_DEVNAME,
-                 CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, errno);
+                 CONFIG_SAMV71XULT_ROMFS_MOUNT_MOUNTPOINT, ret);
         }
     }
 #endif
@@ -409,11 +411,11 @@ int sam_bringup(void)
 
       /* Mount the file system at /mnt/s25fl1 */
 
-      ret = mount(NULL, "/mnt/s25fl1", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/s25fl1", "nxffs", 0, NULL);
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount the NXFFS volume: %d\n",
-                 errno);
+                 ret);
           return ret;
         }
 
diff --git a/boards/arm/samv7/samv71-xult/src/sam_ili9488.c b/boards/arm/samv7/samv71-xult/src/sam_ili9488.c
index 1c15d43..eccbecb 100644
--- a/boards/arm/samv7/samv71-xult/src/sam_ili9488.c
+++ b/boards/arm/samv7/samv71-xult/src/sam_ili9488.c
@@ -990,7 +990,7 @@ static int sam_lcd_dmawait(FAR struct sam_dev_s *priv, uint32_t timeout)
                  sam_lcd_dmatimeout, (wdparm_t)priv);
   if (ret < 0)
     {
-      lcderr("ERROR: wd_start failed: %d\n", errno);
+      lcderr("ERROR: wd_start failed: %d\n", ret);
     }
 
   /* Loop until the event (or the timeout occurs). */
diff --git a/boards/arm/stm32/axoloti/src/stm32_bringup.c b/boards/arm/stm32/axoloti/src/stm32_bringup.c
index 2826ed0..2d7be19 100644
--- a/boards/arm/stm32/axoloti/src/stm32_bringup.c
+++ b/boards/arm/stm32/axoloti/src/stm32_bringup.c
@@ -39,12 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -179,7 +180,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "failed to mount procfs at %s %d\n",
diff --git a/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c b/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
index bad47d4..36105ab 100644
--- a/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
+++ b/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/input/buttons.h>
 
 #ifdef CONFIG_USBMONITOR
@@ -95,7 +95,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/cloudctrl/src/stm32_w25.c b/boards/arm/stm32/cloudctrl/src/stm32_w25.c
index 21323ca..09c24b1 100644
--- a/boards/arm/stm32/cloudctrl/src/stm32_w25.c
+++ b/boards/arm/stm32/cloudctrl/src/stm32_w25.c
@@ -40,8 +40,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -50,6 +48,7 @@
 #ifdef CONFIG_STM32_SPI1
 #  include <nuttx/spi/spi.h>
 #  include <nuttx/mtd/mtd.h>
+#  include <nuttx/fs/fs.h>
 #  include <nuttx/fs/nxffs.h>
 #endif
 
@@ -142,10 +141,10 @@ int stm32_w25initialize(int minor)
   /* Mount the file system at /mnt/w25 */
 
   snprintf(devname, 12, "/mnt/w25%c", 'a' + minor);
-  ret = mount(NULL, devname, "nxffs", 0, NULL);
+  ret = nx_mount(NULL, devname, "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
index 65cd257..95e129d 100644
--- a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
+++ b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -49,6 +47,7 @@
 #ifdef CONFIG_STM32_SPI1
 #  include <nuttx/spi/spi.h>
 #  include <nuttx/mtd/mtd.h>
+#  include <nuttx/fs/fs.h>
 #  include <nuttx/fs/nxffs.h>
 #endif
 
@@ -141,10 +140,10 @@ int stm32_w25initialize(int minor)
   /* Mount the file system at /mnt/w25 */
 
   snprintf(devname, 12, "/mnt/w25%c", 'a' + minor);
-  ret = mount(NULL, devname, "nxffs", 0, NULL);
+  ret = nx_mount(NULL, devname, "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
index 5ada3ad..6f9fb84 100644
--- a/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
diff --git a/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
index 5cbcc7c..8b0d9db 100644
--- a/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
diff --git a/boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c
index 439d4c5..d777a83 100644
--- a/boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f412zg/src/stm32_bringup.c
@@ -39,9 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32.h"
 #include "nucleo-f412zg.h"
 
@@ -87,7 +88,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_appinitialize.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_appinitialize.c
index d4984e1..d8efe09 100644
--- a/boards/arm/stm32/nucleo-f429zi/src/stm32_appinitialize.c
+++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_appinitialize.c
@@ -25,11 +25,11 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <debug.h>
 #include <syslog.h>
 
 #include "nucleo-144.h"
+#include <nuttx/fs/fs.h>
 #include <nuttx/leds/userled.h>
 #ifdef CONFIG_STM32_ROMFS
 #include "stm32_romfs.h"
@@ -71,7 +71,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c
index 6c8c324..3d75188 100644
--- a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c
+++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c
@@ -361,7 +361,7 @@ int stm32_bbsram_int(void)
           syslog(LOG_INFO, "Fault Logged on %s - Valid\n", buf);
         }
 
-      rv = unlink(HARDFAULT_PATH);
+      rv = nx_unlink(HARDFAULT_PATH);
       if (rv < 0)
         {
           syslog(LOG_INFO, "stm32 bbsram: Failed to unlink Fault Log file"
diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_romfs_initialize.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_romfs_initialize.c
index ef7c63c..722fa04 100644
--- a/boards/arm/stm32/nucleo-f429zi/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_romfs_initialize.c
@@ -31,6 +31,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "stm32_romfs.h"
 
@@ -126,12 +127,12 @@ int stm32_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
-              "romfs", MS_RDONLY, NULL);
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
+                 "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32/nucleo-l152re/src/stm32_appinitialize.c b/boards/arm/stm32/nucleo-l152re/src/stm32_appinitialize.c
index 785ee7f..6b146d5 100644
--- a/boards/arm/stm32/nucleo-l152re/src/stm32_appinitialize.c
+++ b/boards/arm/stm32/nucleo-l152re/src/stm32_appinitialize.c
@@ -26,9 +26,9 @@
 
 #include <sys/types.h>
 #include <syslog.h>
-#include <sys/mount.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/leds/userled.h>
 
 #include "nucleo-l152re.h"
@@ -95,7 +95,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(0, STM32_PROCFS_MOUNTPOINT, "procfs", 0, 0);
+  ret = nx_mount(0, STM32_PROCFS_MOUNTPOINT, "procfs", 0, 0);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
index 9be0369..373eb9d 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
+++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/input/buttons.h>
 
@@ -106,7 +106,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/omnibusf4/src/stm32_bringup.c b/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
index 0957344..e8ec765 100644
--- a/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
+++ b/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
@@ -41,12 +41,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -271,7 +272,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c b/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
index d26ca27..5c98f55 100644
--- a/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
@@ -46,6 +46,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "stm32_romfs.h"
 
@@ -141,12 +142,12 @@ int stm32_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
-              "romfs", MS_RDONLY, NULL);
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
+                 "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32/photon/src/stm32_bringup.c b/boards/arm/stm32/photon/src/stm32_bringup.c
index 5ac7f90..87acb1f 100644
--- a/boards/arm/stm32/photon/src/stm32_bringup.c
+++ b/boards/arm/stm32/photon/src/stm32_bringup.c
@@ -40,12 +40,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
 #include <nuttx/input/buttons.h>
 #include <nuttx/leds/userled.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <arch/board/board.h>
 
@@ -78,7 +78,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/photon/src/stm32_rgbled.c b/boards/arm/stm32/photon/src/stm32_rgbled.c
index 4127082..af52725 100644
--- a/boards/arm/stm32/photon/src/stm32_rgbled.c
+++ b/boards/arm/stm32/photon/src/stm32_rgbled.c
@@ -110,8 +110,8 @@ int stm32_rgbled_setup(void)
   struct pwm_lowerhalf_s    *ledr;
   struct pwm_lowerhalf_s    *ledg;
   struct pwm_lowerhalf_s    *ledb;
+  struct file file;
   int ret;
-  int fd;
 
   /* Have we already initialized? */
 
@@ -165,17 +165,17 @@ int stm32_rgbled_setup(void)
           return ret;
         }
 
-      fd = nx_open("/dev/rgbled0", O_WRONLY);
-      if (fd < 0)
+      ret = file_open(&file, "/dev/rgbled0", O_WRONLY);
+      if (ret < 0)
         {
-          lederr("ERROR: open failed: %d\n", fd);
+          lederr("ERROR: open failed: %d\n", ret);
           return ret;
         }
 
       /* Initialize led off */
 
-      nx_write(fd, "#000000", 8);
-      nx_close(fd);
+      file_write(&file, "#000000", 8);
+      file_close(&file);
 
       /* Now we are initialized */
 
diff --git a/boards/arm/stm32/photon/src/stm32_wdt.c b/boards/arm/stm32/photon/src/stm32_wdt.c
index 3c3c146..134bd90 100644
--- a/boards/arm/stm32/photon/src/stm32_wdt.c
+++ b/boards/arm/stm32/photon/src/stm32_wdt.c
@@ -82,7 +82,7 @@ static int wdog_daemon(int argc, char *argv[])
   ret = file_ioctl(&filestruct, WDIOC_START, 0);
   if (ret < 0)
     {
-      wderr("ERROR: ioctl(WDIOC_START) failed: %d\n", errno);
+      wderr("ERROR: file_ioctl(WDIOC_START) failed: %d\n", ret);
       goto exit_close_dev;
     }
 
@@ -95,7 +95,7 @@ static int wdog_daemon(int argc, char *argv[])
       ret = file_ioctl(&filestruct, WDIOC_KEEPALIVE, 0);
       if (ret < 0)
         {
-          wderr("ERROR: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno);
+          wderr("ERROR: file_ioctl(WDIOC_KEEPALIVE) failed: %d\n", ret);
           break;
         }
     }
@@ -150,7 +150,7 @@ int photon_watchdog_initialize(void)
 
   if (ret < 0)
     {
-      wderr("ERROR: watchdog configuration failed: %d\n", errno);
+      wderr("ERROR: watchdog configuration failed: %d\n", ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32/shenzhou/src/stm32_w25.c b/boards/arm/stm32/shenzhou/src/stm32_w25.c
index 3d5d472..846b5c7 100644
--- a/boards/arm/stm32/shenzhou/src/stm32_w25.c
+++ b/boards/arm/stm32/shenzhou/src/stm32_w25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -49,6 +47,7 @@
 #ifdef CONFIG_STM32_SPI1
 #  include <nuttx/spi/spi.h>
 #  include <nuttx/mtd/mtd.h>
+#  include <nuttx/fs/fs.h>
 #  include <nuttx/fs/nxffs.h>
 
 #  include "stm32_spi.h"
@@ -142,10 +141,10 @@ int stm32_w25initialize(int minor)
   /* Mount the file system at /mnt/w25 */
 
   snprintf(devname, 12, "/mnt/w25%c", 'a' + minor);
-  ret = mount(NULL, devname, "nxffs", 0, NULL);
+  ret = nx_mount(NULL, devname, "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c b/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
index ecb7010..a721fe6 100644
--- a/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 
 #ifdef CONFIG_STM32_SPI1
@@ -329,7 +329,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
index d3caece..6b8a731 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "stm32_i2c.h"
@@ -128,10 +127,10 @@ int stm32_at24_automount(int minor)
       /* Mount the file system at /mnt/at24 */
 
       finfo("Mount the NXFFS file system at /dev/at24\n");
-      ret = mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
index c0b39b3..c0729ef 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
@@ -47,6 +46,7 @@
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/timers/oneshot.h>
 
 #ifdef CONFIG_USBMONITOR
@@ -278,7 +278,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
index 6e9d127..173710c 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/boards/arm/stm32/stm32f411-minimum/src/stm32_bringup.c b/boards/arm/stm32/stm32f411-minimum/src/stm32_bringup.c
index 36fe949..d3af59f 100644
--- a/boards/arm/stm32/stm32f411-minimum/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f411-minimum/src/stm32_bringup.c
@@ -24,9 +24,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32.h"
 
 #ifdef CONFIG_STM32_OTGFS
@@ -73,7 +74,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c b/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
index 6e3009c..60a2cf5 100644
--- a/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
@@ -39,9 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32.h"
 
 #ifdef CONFIG_STM32_OTGFS
@@ -88,7 +89,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c b/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
index 919c224..0fdfd62 100644
--- a/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/kmalloc.h>
 
 #ifdef CONFIG_STM32_SPI4
@@ -120,12 +120,11 @@ int stm32_bringup(void)
 #ifdef HAVE_PROC
   /* mount the proc filesystem */
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
index 0992baa..224c352 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
@@ -39,12 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #  include <nuttx/usb/usbmonitor.h>
 #endif
@@ -457,7 +458,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c b/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
index bcca7bd..bfb925e 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
@@ -46,6 +46,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "stm32_romfs.h"
 
@@ -142,12 +143,12 @@ int stm32_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
               "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c b/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c
index 13ce8c9..6c1b6fb 100644
--- a/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c
@@ -40,12 +40,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
 #include <nuttx/input/buttons.h>
 #include <nuttx/leds/userled.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <arch/board/board.h>
 
@@ -80,7 +80,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/stm32vldiscovery/src/stm32_bringup.c b/boards/arm/stm32/stm32vldiscovery/src/stm32_bringup.c
index d35cf44..719df76 100644
--- a/boards/arm/stm32/stm32vldiscovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32vldiscovery/src/stm32_bringup.c
@@ -39,12 +39,12 @@
 
 #include <nuttx/config.h>
 
+#include <syslog.h>
+
 #ifdef CONFIG_FS_PROCFS
-#  include <sys/mount.h>
+#  include <nuttx/fs/fs.h>
 #endif
 
-#include <syslog.h>
-
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -101,7 +101,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c b/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
index 00ea71e..1e79d17 100644
--- a/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
+++ b/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
@@ -40,12 +40,12 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #ifdef CONFIG_RTC_DRIVER
 #  include <nuttx/timers/rtc.h>
@@ -154,7 +154,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c
index 120c0bc..7904677 100644
--- a/boards/arm/stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/nucleo-f072rb/src/stm32_bringup.c
@@ -39,10 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/i2c/i2c_master.h>
 
 #include "stm32_i2c.h"
@@ -85,7 +85,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
index e0e898f..741378e 100644
--- a/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
@@ -39,10 +39,11 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "nucleo-f091rc.h"
 
 /****************************************************************************
@@ -70,7 +71,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32f0l0g0/stm32f051-discovery/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/stm32f051-discovery/src/stm32_bringup.c
index a960fbe..8612b3a 100644
--- a/boards/arm/stm32f0l0g0/stm32f051-discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/stm32f051-discovery/src/stm32_bringup.c
@@ -39,9 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32f051-discovery.h"
 
 /****************************************************************************
@@ -69,7 +70,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
index 7f63332..84cf5ca 100644
--- a/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/stm32f072-discovery/src/stm32_bringup.c
@@ -39,9 +39,10 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32f072-discovery.h"
 
 /****************************************************************************
@@ -69,7 +70,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_appinitialize.c b/boards/arm/stm32f7/nucleo-144/src/stm32_appinitialize.c
index 0a05935..e275285 100644
--- a/boards/arm/stm32f7/nucleo-144/src/stm32_appinitialize.c
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_appinitialize.c
@@ -42,11 +42,11 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <debug.h>
 #include <syslog.h>
 
 #include "nucleo-144.h"
+#include <nuttx/fs/fs.h>
 #include <nuttx/leds/userled.h>
 #ifdef CONFIG_STM32_ROMFS
 #include "stm32_romfs.h"
@@ -88,7 +88,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c
index 783cf09..5e03d6d 100644
--- a/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c
@@ -376,11 +376,11 @@ int stm32_bbsram_int(void)
           syslog(LOG_INFO, "Fault Logged on %s - Valid\n", buf);
         }
 
-      rv = unlink(HARDFAULT_PATH);
+      rv = nx_unlink(HARDFAULT_PATH);
       if (rv < 0)
         {
-          syslog(LOG_INFO, "stm32 bbsram: Failed to unlink Fault Log file "
-                 "[%s] (%d)\n", HARDFAULT_PATH, rv);
+          syslog(LOG_INFO, "stm32 bbsram: Failed to unlink Fault Log file"
+                 " [%s] (%d)\n", HARDFAULT_PATH, rv);
         }
     }
 #endif /* CONFIG_STM32F7_SAVE_CRASHDUMP */
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c b/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
index 82d1786..68e9ce2 100644
--- a/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
@@ -46,6 +46,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "stm32_romfs.h"
 
@@ -141,12 +142,12 @@ int stm32_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
               "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
index 8ace173..f1f02c7 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
@@ -40,12 +40,13 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include "stm32f746g-disco.h"
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -88,12 +89,11 @@ int stm32_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c
index 73f958e..568ae5e 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_n25q.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
@@ -50,6 +49,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <arch/board/board.h>
 
@@ -119,10 +119,10 @@ int stm32_n25qxxx_setup(void)
       return ret;
     }
 
-  ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      _err("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      _err("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32f7/stm32f769i-disco/src/stm32_bringup.c b/boards/arm/stm32f7/stm32f769i-disco/src/stm32_bringup.c
index e9c70f3..107c931 100644
--- a/boards/arm/stm32f7/stm32f769i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32f7/stm32f769i-disco/src/stm32_bringup.c
@@ -40,12 +40,13 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "stm32f769i-disco.h"
 
 /****************************************************************************
@@ -81,7 +82,7 @@ int stm32_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
index f49d3d0..67ad101 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
@@ -40,10 +40,11 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_USBMONITOR
 #include <nuttx/usb/usbmonitor.h>
 #endif
@@ -174,12 +175,11 @@ int stm32_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n",  ret);
     }
 #endif /* CONFIG_FS_PROCFS */
 
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_romfs_initialize.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_romfs_initialize.c
index 6619377..9103d8f 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_romfs_initialize.c
@@ -31,6 +31,7 @@
 #include <debug.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include "stm32_romfs.h"
 
@@ -126,12 +127,12 @@ int stm32_romfs_initialize(void)
   finfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
         CONFIG_STM32_ROMFS_MOUNTPOINT, MOUNT_DEVNAME);
 
-  ret = mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
+  ret = nx_mount(MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT,
               "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: mount(%s,%s,romfs) failed: %d\n",
-           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, errno);
+      ferr("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
+           MOUNT_DEVNAME, CONFIG_STM32_ROMFS_MOUNTPOINT, ret);
       return ret;
     }
 
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
index 11b615e..6f56b2c 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_bringup.c
@@ -40,12 +40,13 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include "stm32h747i-disco.h"
 
+#include <nuttx/fs/fs.h>
+
 #ifdef CONFIG_BUTTONS
 #  include <nuttx/input/buttons.h>
 #endif
@@ -160,12 +161,11 @@ int stm32_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
     }
 #endif /* CONFIG_FS_PROCFS */
 
diff --git a/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c b/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
index f36942d..d2fe1bc 100644
--- a/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
+++ b/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
@@ -42,10 +42,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/input/buttons.h>
 #include <nuttx/leds/userled.h>
 #include <nuttx/spi/qspi.h>
@@ -79,7 +79,7 @@ int stm32l4_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c
index dbefb07..1767c80 100644
--- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_appinit.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
@@ -49,6 +48,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/leds/userled.h>
@@ -140,12 +140,12 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n",
+             ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
index c1454bd..45d6da6 100644
--- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
+++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
@@ -39,8 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -48,6 +46,7 @@
 
 #include <nuttx/spi/spi.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "stm32l4_spi.h"
@@ -121,10 +120,10 @@ int stm32_at45dbinitialize(int minor)
       /* Mount the file system at /mnt/at45db */
 
       finfo("Mount the NXFFS file system at /dev/at45db\n");
-      ret = mount(NULL, "/mnt/at45db", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at45db", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c b/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
index 477d4f0..36f7c30 100644
--- a/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
+++ b/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
@@ -199,7 +199,7 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat,
     {
       if (nbytes != -EINTR)
         {
-          aerr("ERROR: nx_read() failed: %d\n", nbytes);
+          aerr("ERROR: file_read() failed: %d\n", nbytes);
           ret = (int)nbytes;
           goto out_close;
         }
diff --git a/boards/arm/stm32l4/nucleo-l452re/src/stm32_bringup.c b/boards/arm/stm32l4/nucleo-l452re/src/stm32_bringup.c
index 3d4d6ee..b939407 100644
--- a/boards/arm/stm32l4/nucleo-l452re/src/stm32_bringup.c
+++ b/boards/arm/stm32l4/nucleo-l452re/src/stm32_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <sys/types.h>
 #include <debug.h>
 
@@ -47,6 +46,7 @@
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/leds/userled.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include "stm32l4_i2c.h"
 #include "nucleo-l452re.h"
@@ -90,7 +90,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c b/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
index 3f33e88..3ab5e72 100644
--- a/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
@@ -49,6 +48,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/sdio.h>
 #include <nuttx/mmcsd.h>
 
@@ -181,12 +181,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
index 903b97c..bfa3342 100644
--- a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
+++ b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
@@ -42,11 +42,11 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <debug.h>
 #include <syslog.h>
 
 #include "nucleo-144.h"
+#include <nuttx/fs/fs.h>
 #include <nuttx/leds/userled.h>
 
 #include "stm32l4_i2c.h"
@@ -104,7 +104,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
diff --git a/boards/arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c b/boards/arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c
index 74dde72..9e7b68c 100644
--- a/boards/arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c
+++ b/boards/arm/stm32l4/stm32l476-mdk/src/stm32_bringup.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
@@ -50,6 +49,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/drivers.h>
 
 #include <arch/board/board.h>
@@ -114,12 +114,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_appinit.c b/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_appinit.c
index d7e013b..9506124 100644
--- a/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_appinit.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
@@ -50,6 +49,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <stm32l4.h>
 #include <stm32l4_uart.h>
@@ -142,12 +142,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
@@ -248,10 +247,10 @@ int board_app_initialize(uintptr_t arg)
 
       /* Mount the file system at /mnt/nxffs */
 
-      ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL);
       if (ret < 0)
         {
-          _err("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+          _err("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
           return ret;
         }
 
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
index 91b5819..17e74e2 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
@@ -191,7 +191,7 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *ve
     {
       if (nbytes != -EINTR)
         {
-          aerr("ERROR: nx_read() failed: %d\n", nbytes);
+          aerr("ERROR: file_read() failed: %d\n", nbytes);
           ret = (int)nbytes;
           goto out_close;
         }
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
index 1dd28d5..56d93a7 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
@@ -40,7 +40,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
@@ -50,6 +49,7 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include <stm32l4.h>
 #include <stm32l4_uart.h>
@@ -129,12 +129,11 @@ int board_app_initialize(uintptr_t arg)
 
   syslog(LOG_INFO, "Mounting procfs to /proc\n");
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c b/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
index db2e72d..3b3e7f4 100644
--- a/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
+++ b/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "launchxl-cc1310.h"
 
 /****************************************************************************
@@ -79,7 +80,7 @@ int cc1310_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c b/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
index e9f2eaa..497798b 100644
--- a/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
+++ b/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "launchxl-cc1312r1.h"
 
 /****************************************************************************
@@ -79,7 +80,7 @@ int cc1312_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
index 696c9ce..ead4a83 100644
--- a/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
+++ b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
@@ -28,12 +28,13 @@
 #include <nuttx/spi/spi.h>
 #include <nuttx/mmcsd.h>
 
-#include <sys/mount.h>
 #include <debug.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "lm3s6965-ek.h"
 #include "tiva_ssi.h"
 
@@ -130,7 +131,7 @@ int lm_bringup(void)
 #ifdef CONFIG_FS_BINFS
   /* Mount the binfs file system */
 
-  ret = mount(NULL, "/bin", "binfs", 0, NULL);
+  ret = nx_mount(NULL, "/bin", "binfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount binfs at /bin: %d\n", ret);
@@ -140,7 +141,7 @@ int lm_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, LM_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, LM_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
@@ -151,7 +152,7 @@ int lm_bringup(void)
 #ifdef CONFIG_FS_TMPFS
   /* Mount the tmpfs file system */
 
-  ret = mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n",
diff --git a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
index 3a6300e..0f06feb 100644
--- a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
+++ b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
@@ -54,8 +54,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
@@ -63,6 +61,7 @@
 
 #include <nuttx/i2c/i2c_master.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 
 #include "tiva_i2c.h"
@@ -142,11 +141,11 @@ int tm4c_at24_automount(int minor)
 
       /* Mount the file system at /mnt/at24 */
 
-      ret = mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
+      ret = nx_mount(NULL, "/mnt/at24", "nxffs", 0, NULL);
       if (ret < 0)
         {
           syslog(LOG_ERR, "ERROR: Failed to mount the NXFFS volume: %d\n",
-                 errno);
+                 ret);
           return ret;
         }
 #endif
diff --git a/boards/arm/tms570/tms570ls31x-usb-kit/src/tms570_bringup.c b/boards/arm/tms570/tms570ls31x-usb-kit/src/tms570_bringup.c
index 0a1312f..83c4d88 100644
--- a/boards/arm/tms570/tms570ls31x-usb-kit/src/tms570_bringup.c
+++ b/boards/arm/tms570/tms570ls31x-usb-kit/src/tms570_bringup.c
@@ -37,16 +37,15 @@
  * Included Files
  ****************************************************************************/
 
- #include <nuttx/config.h>
+#include <nuttx/config.h>
 
- #include <sys/mount.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <syslog.h>
- #include <debug.h>
- #include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <debug.h>
+#include <errno.h>
 
- #include <nuttx/board.h>
+#include <nuttx/board.h>
 #include "tms570ls31x_usb_kit.h"
 
 /****************************************************************************
diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
index c2cfd34..23540c3 100644
--- a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
+++ b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
@@ -39,14 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #ifdef CONFIG_PIC32MX_SPI2
 #  include <nuttx/spi/spi.h>
@@ -160,10 +159,10 @@ int board_app_initialize(uintptr_t arg)
 
   /* Mount the file system at /mnt/sst25 */
 
-  ret = mount(NULL, "/mnt/sst25", "nxffs", 0, NULL);
+  ret = nx_mount(NULL, "/mnt/sst25", "nxffs", 0, NULL);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
+      ferr("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c
index d7f505f..b888fce 100644
--- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c
+++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -48,6 +47,7 @@
 
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/spi/spi.h>
 #include <nuttx/mmcsd.h>
 #include <nuttx/usb/usbhost.h>
@@ -389,7 +389,7 @@ int pic32mx_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_bringup.c b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_bringup.c
index 0389e9b..1db682f 100644
--- a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_bringup.c
+++ b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "flipnclick-pic32mz.h"
 
 /****************************************************************************
@@ -64,7 +65,7 @@ int pic32mz_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n",
diff --git a/boards/or1k/mor1kx/or1k/src/or1k_bringup.c b/boards/or1k/mor1kx/or1k/src/or1k_bringup.c
index 25b3662..faada66 100644
--- a/boards/or1k/mor1kx/or1k/src/or1k_bringup.c
+++ b/boards/or1k/mor1kx/or1k/src/or1k_bringup.c
@@ -40,10 +40,9 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
-#include <sys/mount.h>
+#include <nuttx/fs/fs.h>
 
 /****************************************************************************
  * Public Functions
@@ -70,7 +69,7 @@ int or1k_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c
index ff94fab..cf8b074 100644
--- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c
+++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c
@@ -27,7 +27,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 #include <debug.h>
@@ -35,6 +34,7 @@
 #include <nuttx/kthread.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/usb/usbhost.h>
 
 #include "rx65n_usbhost.h"
@@ -370,12 +370,11 @@ int rx65n_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
     }
 
 #endif
diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c
index 80d1d89..780cf55 100644
--- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c
+++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c
@@ -313,11 +313,11 @@ int rx65n_sbram_int(void)
           syslog(LOG_INFO, "Fault Logged on %s - Valid\n", buf);
         }
 
-      rv = unlink(HARDFAULT_PATH);
+      rv = nx_unlink(HARDFAULT_PATH);
       if (rv < 0)
         {
-          syslog(LOG_INFO, "rx65n sbram: Failed to unlink Fault Log file [%s"
-                 "] (%d)\n", HARDFAULT_PATH, rv);
+          syslog(LOG_INFO, "rx65n sbram: Failed to unlink Fault Log file"
+                 " [%s] (%d)\n", HARDFAULT_PATH, rv);
         }
     }
 
diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c
index 7e5fee5..72f668f 100644
--- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c
+++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c
@@ -27,13 +27,13 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <errno.h>
 #include <debug.h>
 
 #include <nuttx/kthread.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/usb/usbhost.h>
 
 #include "rx65n_usbhost.h"
@@ -365,12 +365,11 @@ int rx65n_bringup(void)
 
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
     }
 
 #endif
diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c
index 98f03d6..8a2e896 100644
--- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c
+++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c
@@ -311,11 +311,11 @@ int rx65n_sbram_int(void)
           syslog(LOG_INFO, "Fault Logged on %s - Valid\n", buf);
         }
 
-      rv = unlink(HARDFAULT_PATH);
+      rv = nx_unlink(HARDFAULT_PATH);
       if (rv < 0)
         {
-          syslog(LOG_INFO, "rx65n sbram: Failed to unlink Fault Log file [%s"
-                 "] (%d)\n", HARDFAULT_PATH, rv);
+          syslog(LOG_INFO, "rx65n sbram: Failed to unlink Fault Log file"
+                 " [%s] (%d)\n", HARDFAULT_PATH, rv);
         }
     }
 
diff --git a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
index 0c11c5e..f47d102 100644
--- a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
+++ b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/input/buttons.h>
 #include <bl602_tim_lowerhalf.h>
 #include <bl602_oneshot_lowerhalf.h>
@@ -88,7 +89,7 @@ int bl602_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_DEBUG,
@@ -210,7 +211,7 @@ int bl602_bringup(void)
   /* Mount the SPIFFS file system */
 
 #ifdef CONFIG_FS_LITTLEFS
-  ret = mount(path, "/mnt/lfs", "littlefs", 0, "autoformat");
+  ret = nx_mount(path, "/mnt/lfs", "littlefs", 0, "autoformat");
   if (ret < 0)
     {
       syslog(LOG_DEBUG,
@@ -235,14 +236,14 @@ int bl602_bringup(void)
     {
       /* Mount the file system */
 
-      ret = mount("/dev/ram0",
+      ret = nx_mount("/dev/ram0",
                   "/sbin",
                   "romfs", MS_RDONLY, NULL);
       if (ret < 0)
         {
-          _err("ERROR: mount(%s,%s,romfs) failed: %d\n",
+          _err("ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
                "dev/ram0",
-               "/sbin", errno);
+               "/sbin", ret);
         }
     }
 #endif /* CONFIG_FS_ROMFS */
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
index 7976845..513c712 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
@@ -31,12 +31,11 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <debug.h>
 #include <stdio.h>
 
-#include <syslog.h>
+#include <nuttx/fs/fs.h>
 
 #include "esp32c3-devkit.h"
 
@@ -69,7 +68,7 @@ int esp32c3_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c
index e4e5a7b..ebf5149 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c
@@ -25,7 +25,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <assert.h>
 #include <debug.h>
diff --git a/boards/risc-v/fe310/hifive1-revb/src/fe310_bringup.c b/boards/risc-v/fe310/hifive1-revb/src/fe310_bringup.c
index 74ba423..aada0c4 100644
--- a/boards/risc-v/fe310/hifive1-revb/src/fe310_bringup.c
+++ b/boards/risc-v/fe310/hifive1-revb/src/fe310_bringup.c
@@ -39,7 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
@@ -65,7 +64,7 @@ int fe310_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/risc-v/gap8/gapuino/src/gapuino_appinit.c b/boards/risc-v/gap8/gapuino/src/gapuino_appinit.c
index 6113adc..963b404 100644
--- a/boards/risc-v/gap8/gapuino/src/gapuino_appinit.c
+++ b/boards/risc-v/gap8/gapuino/src/gapuino_appinit.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 /****************************************************************************
  * Public Functions
@@ -81,12 +81,11 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the proc filesystem */
 
-  ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR,
-             "ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
-             ret, errno);
+             "ERROR: Failed to mount the PROC filesystem: %d\n", ret);
       return ret;
     }
 #endif
diff --git a/boards/risc-v/k210/maix-bit/src/k210_bringup.c b/boards/risc-v/k210/maix-bit/src/k210_bringup.c
index e822a61..09af032 100644
--- a/boards/risc-v/k210/maix-bit/src/k210_bringup.c
+++ b/boards/risc-v/k210/maix-bit/src/k210_bringup.c
@@ -39,13 +39,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
 #include "k210.h"
 
@@ -64,7 +64,7 @@ int k210_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/risc-v/litex/arty_a7/src/litex_bringup.c b/boards/risc-v/litex/arty_a7/src/litex_bringup.c
index 9b8e14f..a8abf06 100644
--- a/boards/risc-v/litex/arty_a7/src/litex_bringup.c
+++ b/boards/risc-v/litex/arty_a7/src/litex_bringup.c
@@ -24,13 +24,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/input/buttons.h>
 
 #include "litex.h"
@@ -50,7 +50,7 @@ int litex_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/sim/sim/sim/src/sim_bringup.c b/boards/sim/sim/sim/src/sim_bringup.c
index 56f6b84..2c8c201 100644
--- a/boards/sim/sim/sim/src/sim_bringup.c
+++ b/boards/sim/sim/sim/src/sim_bringup.c
@@ -26,13 +26,13 @@
 #include <nuttx/compiler.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <debug.h>
 
 #include <nuttx/board.h>
 #include <nuttx/clock.h>
 #include <nuttx/kmalloc.h>
 #include <nuttx/mtd/mtd.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/fs/nxffs.h>
 #include <nuttx/video/fb.h>
 #include <nuttx/timers/oneshot.h>
@@ -86,7 +86,7 @@ int sim_bringup(void)
 #ifdef CONFIG_FS_BINFS
   /* Mount the binfs file system */
 
-  ret = mount(NULL, "/bin", "binfs", 0, NULL);
+  ret = nx_mount(NULL, "/bin", "binfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount binfs at /bin: %d\n", ret);
@@ -96,7 +96,7 @@ int sim_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, SIM_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
+  ret = nx_mount(NULL, SIM_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
@@ -107,7 +107,7 @@ int sim_bringup(void)
 #ifdef CONFIG_FS_TMPFS
   /* Mount the tmpfs file system */
 
-  ret = mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL);
+  ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n",
@@ -176,7 +176,7 @@ int sim_bringup(void)
 
           /* Mount the SPIFFS file system */
 
-          ret = mount("/dev/rammtd", "/mnt/spiffs", "spiffs", 0, NULL);
+          ret = nx_mount("/dev/rammtd", "/mnt/spiffs", "spiffs", 0, NULL);
           if (ret < 0)
             {
               syslog(LOG_ERR,
@@ -198,8 +198,8 @@ int sim_bringup(void)
 
           /* Mount the LittleFS file system */
 
-          ret = mount("/dev/rammtd", "/mnt/lfs", "littlefs", 0,
-                      "forceformat");
+          ret = nx_mount("/dev/rammtd", "/mnt/lfs", "littlefs", 0,
+                         "forceformat");
           if (ret < 0)
             {
               syslog(LOG_ERR,
diff --git a/boards/sim/sim/sim/src/sim_touchscreen.c b/boards/sim/sim/sim/src/sim_touchscreen.c
index eca5847..33aff53 100644
--- a/boards/sim/sim/sim/src/sim_touchscreen.c
+++ b/boards/sim/sim/sim/src/sim_touchscreen.c
@@ -111,7 +111,7 @@ static FAR void *sim_listener(FAR void *arg)
            * the server.
            */
 
-          fwarn("WARNING: Lost server connection: %d\n", errno);
+          fwarn("WARNING: Lost server connection: %d\n", ret);
           break;
         }
 
@@ -171,7 +171,7 @@ int sim_tsc_setup(int minor)
   ret = boardctl(BOARDIOC_NX_START, 0);
   if (ret < 0)
     {
-      gerr("ERROR: Failed to start the NX server: %d\n", errno);
+      gerr("ERROR: Failed to start the NX server: %d\n", ret);
       return ret;
     }
 
@@ -226,7 +226,7 @@ int sim_tsc_setup(int minor)
     }
   else
     {
-      gerr("ERROR: nx_connect failed: %d\n", errno);
+      gerr("ERROR: nx_connect failed: %d\n", ret);
       return ERROR;
     }
 
diff --git a/boards/sim/sim/sim/src/sim_zoneinfo.c b/boards/sim/sim/sim/src/sim_zoneinfo.c
index bf5f2bd..16059a7 100644
--- a/boards/sim/sim/sim/src/sim_zoneinfo.c
+++ b/boards/sim/sim/sim/src/sim_zoneinfo.c
@@ -44,6 +44,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/drivers/ramdisk.h>
 #include <nuttx/zoneinfo.h>
 
@@ -138,10 +139,10 @@ int sim_zoneinfo(int minor)
   printf("Mounting ROMFS filesystem at target=%s with source=%s\n",
          CONFIG_LIBC_TZDIR, devname);
 
-  ret = mount(devname, CONFIG_LIBC_TZDIR, "romfs", MS_RDONLY, NULL);
+  ret = nx_mount(devname, CONFIG_LIBC_TZDIR, "romfs", MS_RDONLY, NULL);
   if (ret < 0)
     {
-      printf("ERROR: Mount failed: %d\n", errno);
+      printf("ERROR: Mount failed: %d\n", ret);
       return ret;
     }
 
diff --git a/boards/x86/qemu/qemu-i486/src/qemu_appinit.c b/boards/x86/qemu/qemu-i486/src/qemu_appinit.c
index 8af9350..abb46dc 100644
--- a/boards/x86/qemu/qemu-i486/src/qemu_appinit.c
+++ b/boards/x86/qemu/qemu-i486/src/qemu_appinit.c
@@ -39,8 +39,8 @@
 
 #include <nuttx/config.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 
-#include <sys/mount.h>
 #include <stdio.h>
 
 #include "up_internal.h"
@@ -82,7 +82,7 @@ int board_app_initialize(uintptr_t arg)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the proc filesystem */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/x86_64/intel64/qemu-intel64/src/qemu_bringup.c b/boards/x86_64/intel64/qemu-intel64/src/qemu_bringup.c
index e9e7f0f..23433e0 100644
--- a/boards/x86_64/intel64/qemu-intel64/src/qemu_bringup.c
+++ b/boards/x86_64/intel64/qemu-intel64/src/qemu_bringup.c
@@ -24,13 +24,13 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/input/buttons.h>
 
 #include "qemu_intel64.h"
@@ -50,7 +50,7 @@ int qemu_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
index f0479d8..8131da6 100644
--- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c
@@ -46,13 +46,12 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <debug.h>
 #include <stdio.h>
 
-#include <syslog.h>
 #include <sys/errno.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/himem/himem.h>
 
 #include "esp32_wlan.h"
@@ -120,10 +119,10 @@ static int esp32_init_wifi_storage(void)
       return -1;
     }
 
-  ret = mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
+  ret = nx_mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", errno);
+      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", ret);
       return ret;
     }
 
@@ -164,7 +163,7 @@ int esp32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c
index 588121b..a9deca2 100644
--- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c
+++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_spiflash.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -135,7 +133,7 @@ void esp32_spiflash_encrypt_test(void)
                   (unsigned long)(uintptr_t)&geo);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to get GEO errno =%d\n", ret);
+      ferr("ERROR: Failed to get GEO ret = %d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -167,14 +165,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase block errno=%d\n", ret);
+      ferr("ERROR: Failed to erase block ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(enc_mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to encrypt write errno=%d\n", ret);
+      ferr("ERROR: Failed to encrypt write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -182,7 +180,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -196,7 +194,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -214,14 +212,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase errno=%d\n", ret);
+      ferr("ERROR: Failed to erase ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to write errno=%d\n", ret);
+      ferr("ERROR: Failed to write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -229,7 +227,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -243,7 +241,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
index 4a03c2b..29230a6 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
@@ -31,13 +31,12 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <debug.h>
 #include <stdio.h>
 
-#include <syslog.h>
 #include <sys/errno.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/himem/himem.h>
 
 #include "esp32_wlan.h"
@@ -101,10 +100,10 @@ static int esp32_init_wifi_storage(void)
       return -1;
     }
 
-  ret = mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
+  ret = nx_mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", errno);
+      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", ret);
       return ret;
     }
 
@@ -128,7 +127,7 @@ int esp32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c
index 9306109..d21109d 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -135,7 +133,7 @@ void esp32_spiflash_encrypt_test(void)
                   (unsigned long)(uintptr_t)&geo);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to get GEO errno =%d\n", ret);
+      ferr("ERROR: Failed to get GEO ret = %d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -167,14 +165,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase block errno=%d\n", ret);
+      ferr("ERROR: Failed to erase block ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(enc_mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to encrypt write errno=%d\n", ret);
+      ferr("ERROR: Failed to encrypt write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -182,7 +180,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -196,7 +194,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -214,14 +212,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase errno=%d\n", ret);
+      ferr("ERROR: Failed to erase ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to write errno=%d\n", ret);
+      ferr("ERROR: Failed to write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -229,7 +227,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -243,7 +241,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
index 36f280d..ec91db9 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c
@@ -31,13 +31,13 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <debug.h>
 #include <stdio.h>
 
 #include <syslog.h>
 #include <sys/errno.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/himem/himem.h>
 
 #include "esp32_wlan.h"
@@ -109,10 +109,10 @@ static int esp32_init_wifi_storage(void)
       return -1;
     }
 
-  ret = mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
+  ret = nx_mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", errno);
+      syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", ret);
       return ret;
     }
 
@@ -136,7 +136,7 @@ int esp32_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c
index 4fa9d95..41091a8 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c
@@ -25,7 +25,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 #include <nuttx/irq.h>
 #include <arch/irq.h>
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c
index bad6a0f..25ac83e 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_spiflash.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -135,7 +133,7 @@ void esp32_spiflash_encrypt_test(void)
                   (unsigned long)(uintptr_t)&geo);
   if (ret < 0)
     {
-      ferr("ERROR: Failed to get GEO errno =%d\n", ret);
+      ferr("ERROR: Failed to get GEO ret = %d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -167,14 +165,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase block errno=%d\n", ret);
+      ferr("ERROR: Failed to erase block ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(enc_mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to encrypt write errno=%d\n", ret);
+      ferr("ERROR: Failed to encrypt write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -182,7 +180,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -196,7 +194,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -214,14 +212,14 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
   if (ret != erase_nblocks)
     {
-      ferr("ERROR: Failed to erase errno=%d\n", ret);
+      ferr("ERROR: Failed to erase ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
   ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to write errno=%d\n", ret);
+      ferr("ERROR: Failed to write ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -229,7 +227,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
+      ferr("ERROR: Failed to decrypt read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
@@ -243,7 +241,7 @@ void esp32_spiflash_encrypt_test(void)
   ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
   if (ret != rw_nblocks)
     {
-      ferr("ERROR: Failed to read errno=%d\n", ret);
+      ferr("ERROR: Failed to read ret=%d\n", ret);
       DEBUGASSERT(0);
     }
 
diff --git a/boards/z80/ez80/makerlisp/src/ez80_bringup.c b/boards/z80/ez80/makerlisp/src/ez80_bringup.c
index a8710b7..e11a8d6 100644
--- a/boards/z80/ez80/makerlisp/src/ez80_bringup.c
+++ b/boards/z80/ez80/makerlisp/src/ez80_bringup.c
@@ -40,9 +40,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <syslog.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "makerlisp.h"
 
 /****************************************************************************
@@ -70,7 +71,7 @@ int ez80_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/z80/ez80/z20x/src/ez80_bringup.c b/boards/z80/ez80/z20x/src/ez80_bringup.c
index efbb37d..dbd2a6f 100644
--- a/boards/z80/ez80/z20x/src/ez80_bringup.c
+++ b/boards/z80/ez80/z20x/src/ez80_bringup.c
@@ -25,9 +25,10 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <debug.h>
 
+#include <nuttx/fs/fs.h>
+
 #include "z20x.h"
 
 /****************************************************************************
@@ -55,7 +56,7 @@ int ez80_bringup(void)
 #ifdef CONFIG_FS_PROCFS
   /* Mount the procfs file system */
 
-  ret = mount(NULL, "/proc", "procfs", 0, NULL);
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
   if (ret < 0)
     {
       ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
diff --git a/boards/z80/ez80/z20x/src/ez80_w25.c b/boards/z80/ez80/z20x/src/ez80_w25.c
index ccc4a7a..c6dbf2b 100644
--- a/boards/z80/ez80/z20x/src/ez80_w25.c
+++ b/boards/z80/ez80/z20x/src/ez80_w25.c
@@ -24,8 +24,6 @@
 
 #include <nuttx/config.h>
 
-#include <sys/mount.h>
-
 #include <stdbool.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/boards/z80/ez80/z20x/src/w25_main.c b/boards/z80/ez80/z20x/src/w25_main.c
index 77dfcb0..71c3c4f 100644
--- a/boards/z80/ez80/z20x/src/w25_main.c
+++ b/boards/z80/ez80/z20x/src/w25_main.c
@@ -104,7 +104,7 @@ static int w25_read_hex(FAR uint24_t *len)
   fd = open(W25_CHARDEV, O_WRONLY);
   if (fd < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       fprintf(stderr, "ERROR: Failed to open %s: %d\n", W25_CHARDEV, ret);
       return ret;
     }
@@ -170,7 +170,7 @@ static int w25_write(int fd, FAR const void *src, size_t len)
       nwritten = write(fd, src, remaining);
       if (nwritten <= 0)
         {
-          int errcode = get_errno();
+          int errcode = errno;
           if (errno != EINTR)
             {
               fprintf(stderr, "ERROR: Write failed: %d\n", errcode);
@@ -207,7 +207,7 @@ static int w25_write_binary(FAR const struct prog_header_s *hdr)
   fd = open(W25_CHARDEV, O_WRONLY);
   if (fd < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       fprintf(stderr, "ERROR: Failed to open %s: %d\n", W25_CHARDEV, ret);
       return ret;
     }
@@ -255,7 +255,7 @@ static int w25_read(int fd, FAR void *dest, size_t len)
       nread = read(fd, dest, remaining);
       if (nread <= 0)
         {
-          int errcode = get_errno();
+          int errcode = errno;
           if (errno != EINTR)
             {
               fprintf(stderr, "ERROR: Read failed: %d\n", errcode);
@@ -291,7 +291,7 @@ static int w25_read_binary(FAR struct prog_header_s *hdr)
   fd = open(W25_CHARDEV, O_RDONLY);
   if (fd < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       return ret;
     }
 
@@ -553,7 +553,7 @@ static int w25_boot_program(void)
   ret = tcdrain(1);
   if (ret < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       fprintf(stderr, "ERROR: tcdrain() failed: %d\n", ret);
       return ret;
     }
@@ -590,7 +590,7 @@ static int w25_wait_keypress(FAR char *keyset, int nseconds)
   fd = dup(0);
   if (fd < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       fprintf(stderr, "ERROR: Failed to dup stdin: %d\n", ret);
       return ret;
     }
@@ -605,7 +605,7 @@ static int w25_wait_keypress(FAR char *keyset, int nseconds)
 
   if (ret < 0)
     {
-      ret = -get_errno();
+      ret = -errno;
       fprintf(stderr, "ERROR: fcnt() failed: %d\n", ret);
       close(fd) ;
       return ret;
@@ -635,7 +635,7 @@ static int w25_wait_keypress(FAR char *keyset, int nseconds)
 
               if (nread < 0)
                 {
-                  int errcode = get_errno();
+                  int errcode = errno;
 
                   /* If is not an error if a signal occurred or if there is
                    * no key pressed.
diff --git a/drivers/audio/cxd56_src.c b/drivers/audio/cxd56_src.c
index 2c3f14a..8f1e8d5 100644
--- a/drivers/audio/cxd56_src.c
+++ b/drivers/audio/cxd56_src.c
@@ -97,8 +97,8 @@ static struct cxd56_srcdata_s g_src;
 #ifdef DUMP_DATA
 static char *dump_name_pre  = "/mnt/sd0/dump/nx_player_dump_pre.pcm";
 static char *dump_name_post = "/mnt/sd0/dump/nx_player_dump_post.pcm";
-int dump_file_pre = -1;
-int dump_file_post = -1;
+static struct file dump_file_pre;
+static struct file dump_file_post;
 #endif
 
 /****************************************************************************
@@ -166,7 +166,7 @@ static int cxd56_src_process(FAR struct ap_buffer_s *apb)
   /* audinfo("SRC: Process (size = %d)\n", apb->nbytes); */
 
 #ifdef DUMP_DATA
-  write(dump_file_pre,
+  file_write(&dump_file_pre,
         (char *) (apb->samp + apb->curbyte),
         apb->nbytes - apb->curbyte);
 #endif
@@ -295,7 +295,7 @@ static int cxd56_src_process(FAR struct ap_buffer_s *apb)
               spin_unlock_irqrestore(NULL, flags);
 
 #ifdef DUMP_DATA
-              write(dump_file_post, src_apb->samp, src_apb->nbytes);
+              file_write(&dump_file_post, src_apb->samp, src_apb->nbytes);
 #endif
 
               /* Fetch the next APB to fill up */
@@ -446,10 +446,10 @@ int cxd56_src_init(FAR struct cxd56_dev_s *dev,
     }
 
 #ifdef DUMP_DATA
-  unlink(dump_name_pre);
-  unlink(dump_name_post);
-  dump_file_pre = open(dump_name_pre, O_WRONLY | O_CREAT | O_APPEND);
-  dump_file_post = open(dump_name_post, O_WRONLY | O_CREAT | O_APPEND);
+  nx_unlink(dump_name_pre);
+  nx_unlink(dump_name_post);
+  file_open(&dump_file_pre, dump_name_pre, O_WRONLY | O_CREAT | O_APPEND);
+  file_open(&dump_file_post, dump_name_post, O_WRONLY | O_CREAT | O_APPEND);
 #endif
 
   /* Join any old worker threads to prevent memory leaks */
@@ -523,11 +523,11 @@ int cxd56_src_deinit(void)
   src_delete(g_src.src_state);
 
 #ifdef DUMP_DATA
-  if (dump_file_pre)
-    close(dump_file_pre);
+  if (dump_file_pre.f_inode)
+    file_close(&dump_file_pre);
 
-  if (dump_file_post)
-    close(dump_file_post);
+  if (dump_file_post.f_inode)
+    file_close(&dump_file_post);
 #endif
 
   return OK;
diff --git a/drivers/audio/vs1053.c b/drivers/audio/vs1053.c
index 131dcc6..ea7d2bf 100644
--- a/drivers/audio/vs1053.c
+++ b/drivers/audio/vs1053.c
@@ -1536,7 +1536,7 @@ static int vs1053_start(FAR struct audio_lowerhalf_s *lower)
       (pthread_addr_t) dev);
   if (ret != OK)
     {
-      auderr("ERROR: Can't create worker thread, errno=%d\n", errno);
+      auderr("ERROR: Can't create worker thread, ret=%d\n", ret);
     }
   else
     {
diff --git a/drivers/audio/wm8776.c b/drivers/audio/wm8776.c
index 5b97766..2216715 100644
--- a/drivers/audio/wm8776.c
+++ b/drivers/audio/wm8776.c
@@ -576,7 +576,7 @@ static void  wm8776_senddone(FAR struct i2s_dev_s *i2s,
                      CONFIG_WM8776_MSG_PRIO);
   if (ret < 0)
     {
-      auderr("ERROR: file_mq_send failed: %d\n", get_errno());
+      auderr("ERROR: file_mq_send failed: %d\n", ret);
     }
 }
 
@@ -939,11 +939,7 @@ static int wm8776_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
                          sizeof(term_msg), CONFIG_WM8776_MSG_PRIO);
       if (ret < 0)
         {
-          int errcode = get_errno();
-          DEBUGASSERT(errcode > 0);
-
-          auderr("ERROR: file_mq_send failed: %d\n", errcode);
-          UNUSED(errcode);
+          auderr("ERROR: file_mq_send failed: %d\n", ret);
         }
     }
 
diff --git a/drivers/bch/bchdev_unregister.c b/drivers/bch/bchdev_unregister.c
index 8a507d2..4286ac9 100644
--- a/drivers/bch/bchdev_unregister.c
+++ b/drivers/bch/bchdev_unregister.c
@@ -103,8 +103,8 @@ int bchdev_unregister(FAR const char *chardev)
 
   if (ret < 0)
     {
-      _err("ERROR: ioctl failed: %d\n", errno);
-      return -errno;
+      _err("ERROR: ioctl failed: %d\n", ret);
+      return ret;
     }
 
   /* Lock out context switches.  If there are no other references
diff --git a/drivers/lcd/ili9340.c b/drivers/lcd/ili9340.c
index 41b9202..24e462f 100644
--- a/drivers/lcd/ili9340.c
+++ b/drivers/lcd/ili9340.c
@@ -1170,8 +1170,6 @@ FAR struct lcd_dev_s *ili9340_initialize(
             {
               return &priv->dev;
             }
-
-          errno = EINVAL;
         }
     }
 
diff --git a/drivers/lcd/lpm013m091a.c b/drivers/lcd/lpm013m091a.c
index 8ea3373..4501c1a 100644
--- a/drivers/lcd/lpm013m091a.c
+++ b/drivers/lcd/lpm013m091a.c
@@ -606,8 +606,6 @@ FAR struct lcd_dev_s *
             {
               return &priv->dev;
             }
-
-          errno = EINVAL;
         }
     }
 
diff --git a/drivers/loop/losetup.c b/drivers/loop/losetup.c
index b2a48b7..bf7c5c7 100644
--- a/drivers/loop/losetup.c
+++ b/drivers/loop/losetup.c
@@ -275,7 +275,7 @@ static ssize_t loop_write(FAR struct inode *inode,
                                  nsectors * dev->sectsize);
       if (nbyteswritten < 0 && nbyteswritten != -EINTR)
         {
-          ferr("ERROR: nx_write failed: %zd\n", nbyteswritten);
+          ferr("ERROR: file_write failed: %zd\n", nbyteswritten);
           return nbyteswritten;
         }
     }
diff --git a/drivers/sensors/fakesensor.c b/drivers/sensors/fakesensor.c
index 76f077d..065e04f 100644
--- a/drivers/sensors/fakesensor.c
+++ b/drivers/sensors/fakesensor.c
@@ -141,7 +141,7 @@ static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower, bool sw)
 
       /* Wake up the thread */
 
-      sem_post(&sensor->run);
+      nxsem_post(&sensor->run);
     }
   else
     {
@@ -234,7 +234,7 @@ static int fakesensor_thread(int argc, char** argv)
         {
           /* Waiting to be woken up */
 
-          sem_wait(&sensor->run);
+          nxsem_wait(&sensor->run);
         }
     }
 }
diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c
index 9bc7502..8d96792 100644
--- a/drivers/serial/ptmx.c
+++ b/drivers/serial/ptmx.c
@@ -220,7 +220,7 @@ static int ptmx_open(FAR struct file *filep)
    */
 
   ret = nx_unlink(devname);
-  DEBUGASSERT(ret >= 0);  /* unlink() should never fail */
+  DEBUGASSERT(ret >= 0);  /* nx_unlink() should never fail */
 
   nxsem_post(&g_ptmx.px_exclsem);
   return OK;
diff --git a/drivers/usbdev/usbmsc.c b/drivers/usbdev/usbmsc.c
index 6454e0c..4f0f6e5 100644
--- a/drivers/usbdev/usbmsc.c
+++ b/drivers/usbdev/usbmsc.c
@@ -1693,7 +1693,7 @@ int usbmsc_exportluns(FAR void *handle)
   if (priv->thpid <= 0)
     {
       usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_THREADCREATE),
-               (uint16_t)errno);
+               (uint16_t)priv->thpid);
       goto errout_with_lock;
     }
 
diff --git a/fs/aio/aio_write.c b/fs/aio/aio_write.c
index 352d7e1..40c26f5 100644
--- a/fs/aio/aio_write.c
+++ b/fs/aio/aio_write.c
@@ -84,7 +84,7 @@ static void aio_write_worker(FAR void *arg)
   if (aiocbp->aio_fildes < CONFIG_NFILE_DESCRIPTORS)
 #endif
     {
-      /* Call fcntl(F_GETFL) to get the file open mode. */
+      /* Call file_fcntl(F_GETFL) to get the file open mode. */
 
       oflags = file_fcntl(aioc->u.aioc_filep, F_GETFL);
       if (oflags < 0)
diff --git a/fs/driver/fs_findmtddriver.c b/fs/driver/fs_findmtddriver.c
index d6d52e9..7dc4a83 100644
--- a/fs/driver/fs_findmtddriver.c
+++ b/fs/driver/fs_findmtddriver.c
@@ -25,7 +25,6 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
-#include <sys/mount.h>
 #include <stdbool.h>
 #include <assert.h>
 #include <errno.h>
diff --git a/fs/hostfs/hostfs_rpmsg_server.c b/fs/hostfs/hostfs_rpmsg_server.c
index 5415f17..c659378 100644
--- a/fs/hostfs/hostfs_rpmsg_server.c
+++ b/fs/hostfs/hostfs_rpmsg_server.c
@@ -504,10 +504,8 @@ static int hostfs_rpmsg_unlink_handler(FAR struct rpmsg_endpoint *ept,
                                        uint32_t src, FAR void *priv)
 {
   FAR struct hostfs_rpmsg_unlink_s *msg = data;
-  int ret;
 
-  ret = unlink(msg->pathname);
-  msg->header.result = ret ? -get_errno() : 0;
+  msg->header.result = nx_unlink(msg->pathname);
   return rpmsg_send(ept, msg, sizeof(*msg));
 }
 
diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c
index effb34a..259a06f 100644
--- a/fs/mmap/fs_mmap.c
+++ b/fs/mmap/fs_mmap.c
@@ -193,9 +193,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
 
       return rammap(fd, length, offset);
 #else
-      /* Error out.  The errno value was already set by ioctl() */
-
-      ferr("ERROR: ioctl(FIOC_MMAP) failed: %d\n", ret);
+      ferr("ERROR: nx_ioctl(FIOC_MMAP) failed: %d\n", ret);
       goto errout;
 #endif
     }
diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c
index 136ff92..0c38b36 100644
--- a/fs/mmap/fs_rammap.c
+++ b/fs/mmap/fs_rammap.c
@@ -170,7 +170,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
             {
               /* All other read errors are bad. */
 
-              ferr("ERROR: Read failed: offset=%d errno=%d\n",
+              ferr("ERROR: Read failed: offset=%d ret=%d\n",
                    (int)offset, (int)nread);
 
               ret = nread;
diff --git a/fs/mount/fs_automount.c b/fs/mount/fs_automount.c
index 8da1f42..d1d09a5 100644
--- a/fs/mount/fs_automount.c
+++ b/fs/mount/fs_automount.c
@@ -218,15 +218,11 @@ static void automount_mount(FAR struct automounter_state_s *priv)
 
        /* Mount the file system */
 
-      ret = mount(lower->blockdev, lower->mountpoint, lower->fstype,
-                  0, NULL);
+      ret = nx_mount(lower->blockdev, lower->mountpoint, lower->fstype,
+                     0, NULL);
       if (ret < 0)
         {
-          int errcode = get_errno();
-          DEBUGASSERT(errcode > 0);
-
-          ferr("ERROR: Mount failed: %d\n", errcode);
-          UNUSED(errcode);
+          ferr("ERROR: Mount failed: %d\n", ret);
           return;
         }
 
@@ -276,18 +272,15 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
 
       /* Un-mount the volume */
 
-      ret = umount2(lower->mountpoint, MNT_FORCE);
+      ret = nx_umount2(lower->mountpoint, MNT_FORCE);
       if (ret < 0)
         {
-          int errcode = get_errno();
-          DEBUGASSERT(errcode > 0);
-
           /* We expect the error to be EBUSY meaning that the volume could
            * not be unmounted because there are currently reference via open
            * files or directories.
            */
 
-          if (errcode == EBUSY)
+          if (ret == -EBUSY)
             {
               finfo("WARNING: Volume is busy, try again later\n");
 
@@ -306,8 +299,8 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
 
           else
             {
-              ferr("ERROR: umount2 failed: %d\n", errcode);
-              return -errcode;
+              ferr("ERROR: umount2 failed: %d\n", ret);
+              return ret;
             }
         }
 
diff --git a/graphics/nxmu/nxmu_reportposition.c b/graphics/nxmu/nxmu_reportposition.c
index 07ed7f2..40886a0 100644
--- a/graphics/nxmu/nxmu_reportposition.c
+++ b/graphics/nxmu/nxmu_reportposition.c
@@ -70,6 +70,6 @@ void nxmu_reportposition(FAR struct nxbe_window_s *wnd)
                               sizeof(struct nxclimsg_newposition_s));
   if (ret < 0)
     {
-      gerr("ERROR: nxmu_sendclient failed: %d\n", errno);
+      gerr("ERROR: nxmu_sendclient failed: %d\n", get_errno());
     }
 }
diff --git a/graphics/nxterm/nxterm_clear.c b/graphics/nxterm/nxterm_clear.c
index 8fb84af..1aa5c9f 100644
--- a/graphics/nxterm/nxterm_clear.c
+++ b/graphics/nxterm/nxterm_clear.c
@@ -55,6 +55,6 @@ void nxterm_clear(FAR struct nxterm_state_s *priv)
   ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
   if (ret < 0)
     {
-      gerr("ERROR: Fill failed: %d\n", errno);
+      gerr("ERROR: Fill failed: %d\n", get_errno());
     }
 }
diff --git a/graphics/nxterm/nxterm_redraw.c b/graphics/nxterm/nxterm_redraw.c
index 4750617..66a922f 100644
--- a/graphics/nxterm/nxterm_redraw.c
+++ b/graphics/nxterm/nxterm_redraw.c
@@ -88,7 +88,7 @@ void nxterm_redraw(NXTERM handle,
   ret = priv->ops->fill(priv, rect, priv->wndo.wcolor);
   if (ret < 0)
     {
-      gerr("ERROR: fill failed: %d\n", errno);
+      gerr("ERROR: fill failed: %d\n", get_errno());
     }
 
   /* Then redraw each character on the display (Only the characters within
diff --git a/graphics/nxterm/nxterm_register.c b/graphics/nxterm/nxterm_register.c
index 644b6ef..3e2b4b6 100644
--- a/graphics/nxterm/nxterm_register.c
+++ b/graphics/nxterm/nxterm_register.c
@@ -96,7 +96,7 @@ FAR struct nxterm_state_s *
   if (priv->fcache == NULL)
     {
       gerr("ERROR: Failed to connect to font cache for font ID %d: %d\n",
-           wndo->fontid, errno);
+           wndo->fontid, get_errno());
       goto errout;
     }
 
@@ -106,7 +106,7 @@ FAR struct nxterm_state_s *
   if (hfont == NULL)
     {
       gerr("ERROR: Failed to get handlr for font ID %d: %d\n",
-           wndo->fontid, errno);
+           wndo->fontid, get_errno());
       goto errout;
     }
 
diff --git a/graphics/nxterm/nxterm_scroll.c b/graphics/nxterm/nxterm_scroll.c
index ca96a3b..9d02ba9 100644
--- a/graphics/nxterm/nxterm_scroll.c
+++ b/graphics/nxterm/nxterm_scroll.c
@@ -83,7 +83,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
       ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
       if (ret < 0)
         {
-          gerr("ERROR: Fill failed: %d\n", errno);
+          gerr("ERROR: Fill failed: %d\n", get_errno());
         }
 
       /* Fill each character that might lie within in the bounding box */
@@ -107,7 +107,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
   ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
   if (ret < 0)
     {
-      gerr("ERROR: Fill failed: %d\n", errno);
+      gerr("ERROR: Fill failed: %d\n", get_errno());
     }
 }
 #else
@@ -143,7 +143,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
   ret = priv->ops->move(priv, &rect, &offset);
   if (ret < 0)
     {
-      gerr("ERROR: Move failed: %d\n", errno);
+      gerr("ERROR: Move failed: %d\n", get_errno());
     }
 
   /* Finally, clear the vacated bottom part of the display */
@@ -153,7 +153,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
   ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
   if (ret < 0)
     {
-      gerr("ERROR: Fill failed: %d\n", errno);
+      gerr("ERROR: Fill failed: %d\n", get_errno());
     }
 }
 #endif
diff --git a/libs/libc/dlfcn/lib_dlerror.c b/libs/libc/dlfcn/lib_dlerror.c
index cdb4745..3857d18 100644
--- a/libs/libc/dlfcn/lib_dlerror.c
+++ b/libs/libc/dlfcn/lib_dlerror.c
@@ -70,5 +70,5 @@
 
 FAR char *dlerror(void)
 {
-  return (FAR char *)strerror(errno);
+  return (FAR char *)strerror(get_errno());
 }
diff --git a/libs/libc/grp/lib_find_grpfile.c b/libs/libc/grp/lib_find_grpfile.c
index de70591..6f9886e 100644
--- a/libs/libc/grp/lib_find_grpfile.c
+++ b/libs/libc/grp/lib_find_grpfile.c
@@ -141,8 +141,8 @@ static int grp_foreach(grp_foreach_match_t match, uintptr_t arg,
   stream = fopen(CONFIG_LIBC_GROUP_FILEPATH, "r");
   if (stream == NULL)
     {
-      int errcode = errno;
-      DEBUGASSERT(errno > 0);
+      int errcode = get_errno();
+      DEBUGASSERT(errcode > 0);
       return -errcode;
     }
 
diff --git a/libs/libc/misc/lib_sendfile.c b/libs/libc/misc/lib_sendfile.c
index 44dbcc6..dd33355 100644
--- a/libs/libc/misc/lib_sendfile.c
+++ b/libs/libc/misc/lib_sendfile.c
@@ -115,18 +115,25 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
 
   if (offset)
     {
+      off_t newpos;
+
       /* Use lseek to get the current file position */
 
-      startpos = lseek(infd, 0, SEEK_CUR);
-      if (startpos == (off_t)-1)
+      startpos = _NX_SEEK(infd, 0, SEEK_CUR);
+      if (startpos < 0)
         {
+          int errcode = _NX_GETERRNO(startpos);
+          _NX_SETERRNO(errcode);
           return ERROR;
         }
 
       /* Use lseek again to set the new file position */
 
-      if (lseek(infd, *offset, SEEK_SET) == (off_t)-1)
+      newpos = _NX_SEEK(infd, *offset, SEEK_SET);
+      if (newpos < 0)
         {
+          int errcode = _NX_GETERRNO(newpos);
+          _NX_SETERRNO(errcode);
           return ERROR;
         }
     }
@@ -263,9 +270,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
     {
       /* Use lseek to get the current file position */
 
-      off_t curpos = lseek(infd, 0, SEEK_CUR);
-      if (curpos == (off_t)-1)
+      off_t curpos = _NX_SEEK(infd, 0, SEEK_CUR);
+      if (curpos < 0)
         {
+          int errcode = _NX_GETERRNO(curpos);
+          _NX_SETERRNO(errcode);
           return ERROR;
         }
 
@@ -275,8 +284,11 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
 
       /* Use lseek again to restore the original file position */
 
-      if (lseek(infd, startpos, SEEK_SET) == (off_t)-1)
+      startpos = _NX_SEEK(infd, startpos, SEEK_SET);
+      if (startpos < 0)
         {
+          int errcode = _NX_GETERRNO(startpos);
+          _NX_SETERRNO(errcode);
           return ERROR;
         }
     }
diff --git a/libs/libc/modlib/modlib_init.c b/libs/libc/modlib/modlib_init.c
index aa1b0f6..1588c42 100644
--- a/libs/libc/modlib/modlib_init.c
+++ b/libs/libc/modlib/modlib_init.c
@@ -79,10 +79,10 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo,
 
   /* Get the file stats */
 
-  ret = stat(filename, &buf);
+  ret = _NX_STAT(filename, &buf);
   if (ret < 0)
     {
-      int errval = get_errno();
+      int errval = _NX_GETERRNO(ret);
       berr("ERROR: Failed to stat file: %d\n", errval);
       return -errval;
     }
diff --git a/libs/libc/modlib/modlib_read.c b/libs/libc/modlib/modlib_read.c
index abc4c8b..0084c48 100644
--- a/libs/libc/modlib/modlib_read.c
+++ b/libs/libc/modlib/modlib_read.c
@@ -101,10 +101,10 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
     {
       /* Seek to the next read position */
 
-      rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
+      rpos = _NX_SEEK(loadinfo->filfd, offset, SEEK_SET);
       if (rpos != offset)
         {
-          int errval = get_errno();
+          int errval = _NX_GETERRNO(rpos);
           berr("ERROR: Failed to seek to position %lu: %d\n",
                (unsigned long)offset, errval);
           return -errval;
diff --git a/libs/libc/modlib/modlib_uninit.c b/libs/libc/modlib/modlib_uninit.c
index e7a70fd..b5f586d 100644
--- a/libs/libc/modlib/modlib_uninit.c
+++ b/libs/libc/modlib/modlib_uninit.c
@@ -60,7 +60,7 @@ int modlib_uninitialize(struct mod_loadinfo_s *loadinfo)
 
   if (loadinfo->filfd >= 0)
     {
-      close(loadinfo->filfd);
+      _NX_CLOSE(loadinfo->filfd);
     }
 
   return OK;
diff --git a/libs/libc/netdb/lib_dnsaddserver.c b/libs/libc/netdb/lib_dnsaddserver.c
index 9b768a1..bcbc7ab 100644
--- a/libs/libc/netdb/lib_dnsaddserver.c
+++ b/libs/libc/netdb/lib_dnsaddserver.c
@@ -74,7 +74,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
   stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "a+");
   if (stream == NULL)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: Failed to open %s: %d\n",
            CONFIG_NETDB_RESOLVCONF_PATH, ret);
       DEBUGASSERT(ret < 0);
@@ -98,7 +98,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
           if (inet_ntop(AF_INET, &in4->sin_addr, addrstr,
                         DNS_MAX_ADDRSTR) == NULL)
             {
-              ret = -errno;
+              ret = -get_errno();
               nerr("ERROR: inet_ntop failed: %d\n", ret);
               DEBUGASSERT(ret < 0);
               goto errout;
@@ -131,7 +131,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
           if (inet_ntop(AF_INET6, &in6->sin6_addr, addrstr,
                         DNS_MAX_ADDRSTR) == NULL)
             {
-              ret = -errno;
+              ret = -get_errno();
               nerr("ERROR: inet_ntop failed: %d\n", ret);
               DEBUGASSERT(ret < 0);
               goto errout;
@@ -177,7 +177,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
 
   if (ret < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: fprintf failed: %d\n", ret);
       DEBUGASSERT(ret < 0);
       goto errout;
diff --git a/libs/libc/netdb/lib_dnsbind.c b/libs/libc/netdb/lib_dnsbind.c
index a1b7d04..7445b17 100644
--- a/libs/libc/netdb/lib_dnsbind.c
+++ b/libs/libc/netdb/lib_dnsbind.c
@@ -96,7 +96,7 @@ int dns_bind(void)
   sd = socket(PF_INET, SOCK_DGRAM, 0);
   if (sd < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: socket() failed: %d\n", ret);
       return ret;
     }
@@ -109,7 +109,7 @@ int dns_bind(void)
   ret = setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
   if (ret < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: setsockopt() failed: %d\n", ret);
       close(sd);
       return ret;
diff --git a/libs/libc/netdb/lib_dnsforeach.c b/libs/libc/netdb/lib_dnsforeach.c
index 0772dd6..2d8291a 100644
--- a/libs/libc/netdb/lib_dnsforeach.c
+++ b/libs/libc/netdb/lib_dnsforeach.c
@@ -104,7 +104,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg)
   stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "r");
   if (stream == NULL)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: Failed to open %s: %d\n",
         CONFIG_NETDB_RESOLVCONF_PATH, ret);
       DEBUGASSERT(ret < 0);
diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c
index a42bcb8..b24d4a1 100644
--- a/libs/libc/netdb/lib_dnsquery.c
+++ b/libs/libc/netdb/lib_dnsquery.c
@@ -296,7 +296,7 @@ static int dns_send_query(int sd, FAR const char *name,
   ret = connect(sd, &uaddr->addr, addrlen);
   if (ret < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: connect failed: %d\n", ret);
       return ret;
     }
@@ -304,7 +304,7 @@ static int dns_send_query(int sd, FAR const char *name,
   ret = send(sd, buffer, dest - buffer, 0);
   if (ret < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: sendto failed: %d\n", ret);
       return ret;
     }
@@ -349,7 +349,7 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
   ret = recv(sd, buffer, RECV_BUFFER_SIZE, 0);
   if (ret < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       nerr("ERROR: recv failed: %d\n", ret);
       return ret;
     }
diff --git a/libs/libc/netdb/lib_gethostbyaddrr.c b/libs/libc/netdb/lib_gethostbyaddrr.c
index aeb8251..f863803 100644
--- a/libs/libc/netdb/lib_gethostbyaddrr.c
+++ b/libs/libc/netdb/lib_gethostbyaddrr.c
@@ -267,7 +267,7 @@ int lib_hostfile_lookup(FAR const void *addr, socklen_t len, int type,
   stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r");
   if (stream == NULL)
     {
-      int errcode = -errno;
+      int errcode = -get_errno();
 
       nerr("ERROR:  Failed to open the hosts file %s: %d\n",
            CONFIG_NETDB_HOSTCONF_PATH, errcode);
diff --git a/libs/libc/netdb/lib_gethostentbynamer.c b/libs/libc/netdb/lib_gethostentbynamer.c
index 9eec05d..ea1dd5f 100644
--- a/libs/libc/netdb/lib_gethostentbynamer.c
+++ b/libs/libc/netdb/lib_gethostentbynamer.c
@@ -602,7 +602,7 @@ static int lib_hostfile_lookup(FAR const char *name,
   stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r");
   if (stream == NULL)
     {
-      int errcode = -errno;
+      int errcode = -get_errno();
 
       nerr("ERROR:  Failed to open the hosts file %s: %d\n",
            CONFIG_NETDB_HOSTCONF_PATH, errcode);
diff --git a/libs/libc/netdb/lib_getnameinfo.c b/libs/libc/netdb/lib_getnameinfo.c
index 2a9614e..cb43f4d 100644
--- a/libs/libc/netdb/lib_getnameinfo.c
+++ b/libs/libc/netdb/lib_getnameinfo.c
@@ -163,7 +163,7 @@ int getnameinfo(FAR const struct sockaddr *addr, socklen_t addrlen,
     {
       if (!inet_ntop(addr->sa_family, saddr, host, hostlen))
         {
-          switch (errno)
+          switch (get_errno())
             {
               case ENOSPC:
                 return EAI_OVERFLOW;
diff --git a/libs/libc/pwd/lib_find_pwdfile.c b/libs/libc/pwd/lib_find_pwdfile.c
index 669f11a..f9f109b 100644
--- a/libs/libc/pwd/lib_find_pwdfile.c
+++ b/libs/libc/pwd/lib_find_pwdfile.c
@@ -138,8 +138,8 @@ static int pwd_foreach(pwd_foreach_match_t match, uintptr_t arg,
   stream = fopen(CONFIG_LIBC_PASSWD_FILEPATH, "r");
   if (stream == NULL)
     {
-      int errcode = errno;
-      DEBUGASSERT(errno > 0);
+      int errcode = get_errno();
+      DEBUGASSERT(errcode > 0);
       return -errcode;
     }
 
diff --git a/libs/libc/stdio/lib_libfwrite.c b/libs/libc/stdio/lib_libfwrite.c
index 1ceb52a..220a274 100644
--- a/libs/libc/stdio/lib_libfwrite.c
+++ b/libs/libc/stdio/lib_libfwrite.c
@@ -90,7 +90,7 @@ ssize_t lib_fwrite(FAR const void *ptr, size_t count, FAR FILE *stream)
 #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
      if (ret < 0)
        {
-         _NX_SETERRNO((int)-ret);
+         _NX_SETERRNO(ret);
          ret = ERROR;
        }
 #endif
diff --git a/libs/libc/stdio/lib_perror.c b/libs/libc/stdio/lib_perror.c
index 1df8660..c37fb75 100644
--- a/libs/libc/stdio/lib_perror.c
+++ b/libs/libc/stdio/lib_perror.c
@@ -72,8 +72,8 @@ void perror(FAR const char *s)
   /* If strerror() is not enabled, then just print the error number */
 
 #ifdef CONFIG_LIBC_STRERROR
-  fprintf(PERROR_STREAM, "%s: %s\n", s, strerror(errno));
+  fprintf(PERROR_STREAM, "%s: %s\n", s, strerror(get_errno()));
 #else
-  fprintf(PERROR_STREAM, "%s: Error %d\n", s, errno);
+  fprintf(PERROR_STREAM, "%s: Error %d\n", s, get_errno());
 #endif
 }
diff --git a/libs/libc/stdio/lib_rawoutstream.c b/libs/libc/stdio/lib_rawoutstream.c
index a09f200..4803660 100644
--- a/libs/libc/stdio/lib_rawoutstream.c
+++ b/libs/libc/stdio/lib_rawoutstream.c
@@ -98,7 +98,7 @@ static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset,
   FAR struct lib_rawsostream_s *mthis = (FAR struct lib_rawsostream_s *)this;
 
   DEBUGASSERT(this);
-  return lseek(mthis->fd, offset, whence);
+  return _NX_SEEK(mthis->fd, offset, whence);
 }
 
 /****************************************************************************
diff --git a/libs/libc/stdio/lib_rawsistream.c b/libs/libc/stdio/lib_rawsistream.c
index 9a51fb8..f152ab6 100644
--- a/libs/libc/stdio/lib_rawsistream.c
+++ b/libs/libc/stdio/lib_rawsistream.c
@@ -76,7 +76,7 @@ static off_t rawsistream_seek(FAR struct lib_sistream_s *this, off_t offset,
   FAR struct lib_rawsistream_s *mthis = (FAR struct lib_rawsistream_s *)this;
 
   DEBUGASSERT(this);
-  return lseek(mthis->fd, offset, whence);
+  return _NX_SEEK(mthis->fd, offset, whence);
 }
 
 /****************************************************************************
diff --git a/libs/libc/stdlib/lib_mktemp.c b/libs/libc/stdlib/lib_mktemp.c
index eb3c438..40114bc 100644
--- a/libs/libc/stdlib/lib_mktemp.c
+++ b/libs/libc/stdlib/lib_mktemp.c
@@ -240,7 +240,7 @@ FAR char *mktemp(FAR char *path_template)
       /* Attempt to stat the candidate file */
 
       ret = stat(path_template, &buf);
-      if (ret < 0 && errno == ENOENT)
+      if (ret < 0 && get_errno() == ENOENT)
         {
           /* We have it... Clear the errno and return the template */
 
diff --git a/libs/libc/stdlib/lib_realpath.c b/libs/libc/stdlib/lib_realpath.c
index c6581ed..466432a 100644
--- a/libs/libc/stdlib/lib_realpath.c
+++ b/libs/libc/stdlib/lib_realpath.c
@@ -52,13 +52,13 @@ FAR char *realpath(FAR const char *path, FAR char *resolved)
 
   if (path == NULL)
     {
-      errno = EINVAL;
+      set_errno(EINVAL);
       return NULL;
     }
 
   if (*path == '\0')
     {
-      errno = ENOENT;
+      set_errno(ENOENT);
       return NULL;
     }
 
@@ -159,7 +159,7 @@ loop:
 
   if (p - resolved + 1 + q - path + 1 > PATH_MAX)
     {
-      errno = ENAMETOOLONG;
+      set_errno(ENAMETOOLONG);
       goto out;
     }
 
@@ -181,7 +181,7 @@ loop:
     {
       if (nlnk++ >= SYMLOOP_MAX)
         {
-          errno = ELOOP;
+          set_errno(ELOOP);
           goto out;
         }
 
@@ -190,7 +190,7 @@ loop:
         {
           if (n == 0)
             {
-              errno = ENOENT;
+              set_errno(ENOENT);
             }
 
           goto out;
@@ -200,7 +200,7 @@ loop:
 
       if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0]))
         {
-          errno = ENAMETOOLONG;
+          set_errno(ENAMETOOLONG);
           goto out;
         }
 
@@ -221,7 +221,7 @@ loop:
 
   if (*q == '/' && !S_ISDIR(sb.st_mode))
     {
-      errno = ENOTDIR;
+      set_errno(ENOTDIR);
       goto out;
     }
 
diff --git a/libs/libc/unistd/lib_posix_fallocate.c b/libs/libc/unistd/lib_posix_fallocate.c
index d432f49..e3bf307 100644
--- a/libs/libc/unistd/lib_posix_fallocate.c
+++ b/libs/libc/unistd/lib_posix_fallocate.c
@@ -79,14 +79,14 @@ int posix_fallocate(int fd, off_t offset, off_t len)
 
   if (fstat(fd, &st) != 0)
     {
-      return errno;
+      return get_errno();
     }
 
   if (st.st_size < len)
     {
       if (ftruncate(fd, len) != 0)
         {
-          return errno;
+          return get_errno();
         }
     }
 
diff --git a/libs/libc/userfs/lib_userfs.c b/libs/libc/userfs/lib_userfs.c
index 349877a..ab471b7 100644
--- a/libs/libc/userfs/lib_userfs.c
+++ b/libs/libc/userfs/lib_userfs.c
@@ -167,7 +167,7 @@ static inline int userfs_open_dispatch(FAR struct userfs_info_s *info,
                      sizeof(struct sockaddr_in));
   if (nsent < 0)
     {
-      ret = -errno;
+      ret = -get_errno();
       ferr("ERROR: Send open response failed: %d\n", ret);
       return ret;
     }
@@ -865,7 +865,7 @@ static inline int userfs_destroy_dispatch(FAR struct userfs_info_s *info,
                      sizeof(struct sockaddr_in));
   if (nsent < 0)
     {
-      int ret = -errno;
+      int ret = -get_errno();
       ferr("ERROR: sendto failed: %d\n", ret);
       return ret;
     }
diff --git a/libs/libnx/nxmu/nx_connect.c b/libs/libnx/nxmu/nx_connect.c
index 465131b..59f2edd 100644
--- a/libs/libnx/nxmu/nx_connect.c
+++ b/libs/libnx/nxmu/nx_connect.c
@@ -160,7 +160,7 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname)
   ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
   if (ret < 0)
     {
-      gerr("ERROR: nxmu_sendserver failed: %d\n", errno);
+      gerr("ERROR: nxmu_sendserver failed: %d\n", get_errno());
       goto errout_with_wmq;
     }
 
@@ -176,7 +176,7 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname)
       ret = nx_eventhandler((NXHANDLE)conn);
       if (ret < 0)
         {
-          gerr("ERROR: nx_message failed: %d\n", errno);
+          gerr("ERROR: nx_message failed: %d\n", get_errno());
           goto errout_with_wmq;
         }
 
diff --git a/libs/libnx/nxmu/nx_redrawreq.c b/libs/libnx/nxmu/nx_redrawreq.c
index 692313d..56f3375 100644
--- a/libs/libnx/nxmu/nx_redrawreq.c
+++ b/libs/libnx/nxmu/nx_redrawreq.c
@@ -71,6 +71,6 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect)
   ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_redrawreq_s));
   if (ret < 0)
     {
-      gerr("ERROR: nxmu_sendwindow failed: %d\n", errno);
+      gerr("ERROR: nxmu_sendwindow failed: %d\n", get_errno());
     }
 }
diff --git a/net/local/local_fifo.c b/net/local/local_fifo.c
index a8b2599..1dc66a1 100644
--- a/net/local/local_fifo.c
+++ b/net/local/local_fifo.c
@@ -174,14 +174,11 @@ static int local_create_fifo(FAR const char *path)
 
   if (!local_fifo_exists(path))
     {
-      ret = mkfifo(path, 0644);
+      ret = nx_mkfifo(path, 0644, CONFIG_DEV_FIFO_SIZE);
       if (ret < 0)
         {
-          int errcode = get_errno();
-          DEBUGASSERT(errcode > 0);
-
-          nerr("ERROR: Failed to create FIFO %s: %d\n", path, errcode);
-          return -errcode;
+          nerr("ERROR: Failed to create FIFO %s: %d\n", path, ret);
+          return ret;
         }
     }
 
@@ -215,14 +212,11 @@ static int local_release_fifo(FAR const char *path)
        * by the device instance will also be freed.
        */
 
-      ret = unlink(path);
+      ret = nx_unlink(path);
       if (ret < 0)
         {
-          int errcode = get_errno();
-          DEBUGASSERT(errcode > 0);
-
-          nerr("ERROR: Failed to unlink FIFO %s: %d\n", path, errcode);
-          return -errcode;
+          nerr("ERROR: Failed to unlink FIFO %s: %d\n", path, ret);
+          return ret;
         }
     }
 
diff --git a/net/local/local_recvutils.c b/net/local/local_recvutils.c
index 67b31a8..0cd7451 100644
--- a/net/local/local_recvutils.c
+++ b/net/local/local_recvutils.c
@@ -79,7 +79,7 @@ int local_fifo_read(FAR struct file *filep, FAR uint8_t *buf, size_t *len)
           if (nread != -EINTR)
             {
               ret = (int)nread;
-              nerr("ERROR: nx_read() failed: %d\n", ret);
+              nerr("ERROR: file_read() failed: %d\n", ret);
               goto errout;
             }
 
diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c
index e12c5eb..500786f 100644
--- a/net/local/local_sendpacket.c
+++ b/net/local/local_sendpacket.c
@@ -87,7 +87,7 @@ static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf,
         {
           if (nwritten != -EINTR)
             {
-              nerr("ERROR: nx_write failed: %zd\n", nwritten);
+              nerr("ERROR: file_write failed: %zd\n", nwritten);
               return (int)nwritten;
             }
 
diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c
index 04d9ed8..4f010d0 100644
--- a/sched/init/nx_bringup.c
+++ b/sched/init/nx_bringup.c
@@ -28,10 +28,10 @@
 #include <stdlib.h>
 #include <string.h>
 #include <debug.h>
-#include <sys/mount.h>
 
 #include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
 #include <nuttx/init.h>
 #include <nuttx/symtab.h>
 #include <nuttx/wqueue.h>
@@ -269,9 +269,9 @@ static inline void nx_start_application(void)
 #ifdef CONFIG_INIT_MOUNT
   /* Mount the file system containing the init program. */
 
-  ret = mount(CONFIG_INIT_MOUNT_SOURCE, CONFIG_INIT_MOUNT_TARGET,
-              CONFIG_INIT_MOUNT_FSTYPE, CONFIG_INIT_MOUNT_FLAGS,
-              CONFIG_INIT_MOUNT_DATA);
+  ret = nx_mount(CONFIG_INIT_MOUNT_SOURCE, CONFIG_INIT_MOUNT_TARGET,
+                 CONFIG_INIT_MOUNT_FSTYPE, CONFIG_INIT_MOUNT_FLAGS,
+                 CONFIG_INIT_MOUNT_DATA);
   DEBUGASSERT(ret >= 0);
 #endif
 
diff --git a/sched/task/task_execv.c b/sched/task/task_execv.c
index 212f942..326874e 100644
--- a/sched/task/task_execv.c
+++ b/sched/task/task_execv.c
@@ -122,7 +122,7 @@ int execv(FAR const char *path, FAR char * const argv[])
   ret = exec(path, (FAR char * const *)argv, symtab, nsymbols);
   if (ret < 0)
     {
-      serr("ERROR: exec failed: %d\n", errno);
+      serr("ERROR: exec failed: %d\n", get_errno());
       return ERROR;
     }
 
diff --git a/sched/task/task_vfork.c b/sched/task/task_vfork.c
index ec0a565..6df5eea 100644
--- a/sched/task/task_vfork.c
+++ b/sched/task/task_vfork.c
@@ -459,7 +459,7 @@ pid_t nxtask_start_vfork(FAR struct task_tcb_s *child)
   ret = waitpid(pid, &rc, 0);
   if (ret < 0)
     {
-      serr("ERROR: waitpid failed: %d\n", errno);
+      serr("ERROR: waitpid failed: %d\n", get_errno());
     }
 #else
   waitpid(pid, &rc, 0);


[incubator-nuttx] 03/03: Fix nxstyle warning

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 151cf495621bd09177e94e7c3c3d415c52af6f0f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 15 16:36:03 2021 +0800

    Fix nxstyle warning
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c |   1 +
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c  |  24 ++-
 .../lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c    |   4 +-
 .../arm/lpc43xx/bambino-200e/src/lpc43_appinit.c   |   2 +-
 .../lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c    |   2 +-
 boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c |   2 +-
 boards/arm/sama5/sama5d2-xult/src/sam_at25.c       |   4 +-
 boards/arm/sama5/sama5d3-xplained/src/sam_at25.c   |   4 +-
 .../arm/sama5/sama5d3-xplained/src/sam_bringup.c   |   2 +-
 .../arm/sama5/sama5d3-xplained/src/sam_nandflash.c |   4 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_at24.c        |   7 +-
 boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c   |   4 +-
 boards/arm/sama5/sama5d4-ek/src/at25_main.c        |   4 +-
 boards/arm/sama5/sama5d4-ek/src/sam_bringup.c      |   2 +-
 boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c    |   4 +-
 boards/arm/samv7/same70-xplained/src/sam_bringup.c |  12 +-
 boards/arm/samv7/samv71-xult/src/sam_bringup.c     |   2 +-
 .../arm/stm32/clicker2-stm32/src/stm32_bringup.c   |   6 +-
 boards/arm/stm32/cloudctrl/src/stm32_w25.c         |   4 +-
 boards/arm/stm32/fire-stm32v2/src/stm32_w25.c      |   4 +-
 boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c |   3 +-
 boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c |   3 +-
 boards/arm/stm32/omnibusf4/src/stm32_bringup.c     |   1 -
 .../stm32/omnibusf4/src/stm32_romfs_initialize.c   |   4 +-
 boards/arm/stm32/shenzhou/src/stm32_w25.c          |   4 +-
 boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c |   7 +-
 .../arm/stm32/stm32f103-minimum/src/stm32_at24.c   |   6 +-
 boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c | 184 ++++++++--------
 .../arm/stm32/stm32f411e-disco/src/stm32_bringup.c |   4 +-
 .../stm32f4discovery/src/stm32_romfs_initialize.c  |   4 +-
 .../stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c  |   3 +-
 .../nucleo-144/src/stm32_romfs_initialize.c        |   4 +-
 .../arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c | 231 +++++++++++----------
 .../arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c   |  26 +--
 boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c   |   2 +-
 .../arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c  |  24 +--
 .../nucleo-l496zg/src/stm32_appinitialize.c        |  13 +-
 .../arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c  |  45 ++--
 .../stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c  |  10 +-
 .../arm/tiva/launchxl-cc1310/src/cc1310_bringup.c  |   4 +-
 .../tiva/launchxl-cc1312r1/src/cc1312_bringup.c    |   4 +-
 boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c       |   3 +-
 boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c |   5 +-
 boards/mips/pic32mx/mirtoo/src/pic32_appinit.c     |   5 +-
 drivers/lcd/ili9340.c                              |  10 +-
 libs/libc/grp/lib_find_grpfile.c                   |   3 +-
 libs/libc/misc/lib_sendfile.c                      |  10 +-
 libs/libc/pwd/lib_find_pwdfile.c                   |   3 +-
 libs/libc/stdio/lib_libfwrite.c                    |  21 +-
 libs/libc/stdio/lib_perror.c                       |   1 -
 50 files changed, 397 insertions(+), 348 deletions(-)

diff --git a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
index a99ad80..1148627 100644
--- a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
+++ b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_bringup.c
@@ -121,6 +121,7 @@ static int nsh_sdmmc_initialize(void)
                  ret);
         }
     }
+
   return OK;
 }
 #else
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
index a1bde89..65d9cab 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_bringup.c
  *
  *   Copyright (C) 2019 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- *****************************************************************************/
+ ****************************************************************************/
 
-/*****************************************************************************
+/****************************************************************************
  * Included Files
- *****************************************************************************/
+ ****************************************************************************/
 
 #include <nuttx/config.h>
 
@@ -76,11 +76,11 @@
 #include "lpc17_40_symtab.h"
 #include "lpc17_40_progmem.h"
 
-/*****************************************************************************
+/****************************************************************************
  * Pre-processor Definitions
- *****************************************************************************/
+ ****************************************************************************/
 
-/* Configuration *************************************************************/
+/* Configuration ************************************************************/
 
 /* PORT and SLOT number probably depend on the board configuration */
 
@@ -97,9 +97,9 @@
 #  undef CONFIG_NSH_HAVEUSBDEV
 #endif
 
-/*****************************************************************************
+/****************************************************************************
  * Public Functions
- *****************************************************************************/
+ ****************************************************************************/
 
 /****************************************************************************
  * Name: pnev5180b_bringup
@@ -133,7 +133,8 @@ int pnev5180b_bringup(void)
   ret = nx_mount(NULL, "/bin", "binfs", 0, NULL);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to mount the BIN filesystem: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: Failed to mount the BIN filesystem: %d\n",
+             ret);
       goto done;
     }
 #endif
@@ -166,7 +167,8 @@ int pnev5180b_bringup(void)
   ret = lpc17_40_romfs_initialize();
   if (ret != OK)
     {
-      syslog(LOG_ERR, "ERROR: lpc17_40_romfs_initialize() failed: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: lpc17_40_romfs_initialize() failed: %d\n",
+             ret);
       goto done;
     }
 #endif
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
index 41636d1..96616af 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_romfs.c
  * This file provides contents of an optional ROMFS volume, mounted at boot.
  *
@@ -39,7 +39,7 @@
  *
  ****************************************************************************/
 
-/*****************************************************************************
+/****************************************************************************
  * Included Files
  ****************************************************************************/
 
diff --git a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
index 14a57ec..7df1aa0 100644
--- a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c
@@ -105,7 +105,7 @@ static int nsh_spifi_initialize(void)
     }
 
 #ifndef CONFIG_SPFI_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd);
   if (ret < 0)
diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
index 46b7471..a9e9d38 100644
--- a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c
@@ -96,7 +96,7 @@ static int nsh_spifi_initialize(void)
     }
 
 #ifndef CONFIG_SPFI_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd);
   if (ret < 0)
diff --git a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
index 5598495..8d86fb9 100644
--- a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
+++ b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c
@@ -96,7 +96,7 @@ static int nsh_spifi_initialize(void)
     }
 
 #ifndef CONFIG_SPFI_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd);
   if (ret < 0)
diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
index d839b72..b51393a 100644
--- a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c
@@ -80,13 +80,13 @@ int sam_at25_automount(int minor)
       mtd = at25_initialize(spi);
       if (!mtd)
         {
-          ferr("ERROR: Failed to bind SPI port %d to the AT25 FLASH driver\n");
+          ferr("ERROR: Failed to bind SPI port %d to AT25 FLASH driver\n");
           return -ENODEV;
         }
 
 #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL)
 
-      /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+      /* And use the FTL layer to wrap the MTD driver as a block driver */
 
       ret = ftl_initialize(AT25_MINOR, mtd);
       if (ret < 0)
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
index e31c7aa..d5a67ff 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c
@@ -95,13 +95,13 @@ int sam_at25_automount(int minor)
       mtd = at25_initialize(spi);
       if (!mtd)
         {
-          ferr("ERROR: Failed to bind SPI port %d to the AT25 FLASH driver\n");
+          ferr("ERROR: Failed to bind SPI port %d to AT25 FLASH driver\n");
           return -ENODEV;
         }
 
 #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL)
 
-      /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+      /* And use the FTL layer to wrap the MTD driver as a block driver */
 
       ret = ftl_initialize(AT25_MINOR, mtd);
       if (ret < 0)
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c b/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
index 47013cc..b1c7ea7 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_bringup.c
@@ -205,7 +205,7 @@ int sam_bringup(void)
 #ifdef CONFIG_SAMA5D4EK_HSMCI1_MOUNT
   else
     {
-      /* REVISIT:  A delay seems to be required here or the mount will fail. */
+      /* REVISIT: A delay seems to be required here or the mount will fail */
 
       /* Mount the volume on HSMCI1 */
 
diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
index 38e86cc..aad48eb 100644
--- a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c
@@ -187,7 +187,8 @@ int sam_nand_automount(int minor)
       mtd = sam_nand_initialize(HSMC_CS3);
       if (!mtd)
         {
-          ferr("ERROR: Failed to create the NAND driver on CS%d\n", HSMC_CS3);
+          ferr("ERROR: Failed to create the NAND driver on CS%d\n",
+               HSMC_CS3);
           return -ENODEV;
         }
 
@@ -220,6 +221,7 @@ int sam_nand_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initialized */
 
       initialized = true;
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
index 7ad8e71..331b27b 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c
@@ -35,8 +35,8 @@
 
 /* AT24 Serial EEPROM
  *
- * A AT24C512 Serial EEPPROM was used for tested I2C.  There are other I2C/TWI
- * devices on-board, but the serial EEPROM is the simplest test.
+ * A AT24C512 Serial EEPPROM was used for tested I2C.  There are other
+ * I2C/TWI devices on-board, but the serial EEPROM is the simplest test.
  *
  * There is, however, no AT24 EEPROM on board the SAMA5D3x-EK:  The Serial
  * EEPROM was mounted on an external adaptor board and connected to the
@@ -121,7 +121,7 @@ int sam_at24_automount(int minor)
         }
 
 #if defined(CONFIG_SAMA5D3xEK_AT24_FTL)
-      /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+      /* And use the FTL layer to wrap the MTD driver as a block driver */
 
       finfo("Initialize the FTL layer to create /dev/mtdblock%d\n",
             AT24_MINOR);
@@ -153,6 +153,7 @@ int sam_at24_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initializeed */
 
       initialized = true;
diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
index 52f4d0a..a8874e9 100644
--- a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c
@@ -187,7 +187,8 @@ int sam_nand_automount(int minor)
       mtd = sam_nand_initialize(HSMC_CS3);
       if (!mtd)
         {
-          ferr("ERROR: Failed to create the NAND driver on CS%d\n", HSMC_CS3);
+          ferr("ERROR: Failed to create the NAND driver on CS%d\n",
+               HSMC_CS3);
           return -ENODEV;
         }
 
@@ -220,6 +221,7 @@ int sam_nand_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initialized */
 
       initialized = true;
diff --git a/boards/arm/sama5/sama5d4-ek/src/at25_main.c b/boards/arm/sama5/sama5d4-ek/src/at25_main.c
index 10af0ec..8ecee48 100644
--- a/boards/arm/sama5/sama5d4-ek/src/at25_main.c
+++ b/boards/arm/sama5/sama5d4-ek/src/at25_main.c
@@ -173,8 +173,8 @@ int at25_main(int argc, char *argv)
   fflush(stdout);
 
   ret = hex2bin(&rawinstream.public, &memoutstream.public,
-                (uint32_t)SAM_ISRAM_VSECTION,
-                (uint32_t)(SAM_ISRAM_VSECTION + CONFIG_SAMA5D4EK_AT25_PROGSIZE),
+                SAM_ISRAM_VSECTION,
+                SAM_ISRAM_VSECTION + CONFIG_SAMA5D4EK_AT25_PROGSIZE,
                 0);
   if (ret < 0)
     {
diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c b/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
index f4ae399..2d32370 100644
--- a/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
+++ b/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c
@@ -220,7 +220,7 @@ int sam_bringup(void)
 #ifdef CONFIG_SAMA5D4EK_HSMCI1_MOUNT
   else
     {
-      /* REVISIT:  A delay seems to be required here or the mount will fail. */
+      /* REVISIT: A delay seems to be required here or the mount will fail */
 
       /* Mount the volume on HSMCI1 */
 
diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
index ccfa04c..8d1c99a 100644
--- a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
+++ b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c
@@ -187,7 +187,8 @@ int sam_nand_automount(int minor)
       mtd = sam_nand_initialize(HSMC_CS3);
       if (!mtd)
         {
-          ferr("ERROR: Failed to create the NAND driver on CS%d\n", HSMC_CS3);
+          ferr("ERROR: Failed to create the NAND driver on CS%d\n",
+               HSMC_CS3);
           return -ENODEV;
         }
 
@@ -220,6 +221,7 @@ int sam_nand_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initialized */
 
       initialized = true;
diff --git a/boards/arm/samv7/same70-xplained/src/sam_bringup.c b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
index 4fd09de..8285806 100644
--- a/boards/arm/samv7/same70-xplained/src/sam_bringup.c
+++ b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
@@ -211,7 +211,7 @@ int sam_bringup(void)
 #ifdef CONFIG_SAME70XPLAINED_HSMCI0_MOUNT
   else
     {
-      /* REVISIT:  A delay seems to be required here or the mount will fail. */
+      /* REVISIT: A delay seems to be required here or the mount will fail */
 
       /* Mount the volume on HSMCI0 */
 
@@ -239,8 +239,8 @@ int sam_bringup(void)
 #ifdef HAVE_ROMFS
   /* Create a ROM disk for the /etc filesystem */
 
-  ret = romdisk_register(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_MINOR, romfs_img,
-                         NSECTORS(romfs_img_len),
+  ret = romdisk_register(CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_MINOR,
+                         romfs_img, NSECTORS(romfs_img_len),
                          CONFIG_SAME70XPLAINED_ROMFS_ROMDISK_SECTSIZE);
   if (ret < 0)
     {
@@ -280,7 +280,8 @@ int sam_bringup(void)
   ret = ftl_initialize(PROGMEM_MTD_MINOR, mtd);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n",
+             ret);
       return ret;
     }
 
@@ -294,7 +295,8 @@ int sam_bringup(void)
   ret = bchdev_register(blockdev, chardev, false);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n", chardev, ret);
+      syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n",
+             chardev, ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/samv7/samv71-xult/src/sam_bringup.c b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
index 379be84..67b60c6 100644
--- a/boards/arm/samv7/samv71-xult/src/sam_bringup.c
+++ b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
@@ -320,7 +320,7 @@ int sam_bringup(void)
 #ifdef CONFIG_SAMV71XULT_HSMCI0_MOUNT
   else
     {
-      /* REVISIT:  A delay seems to be required here or the mount will fail. */
+      /* REVISIT: A delay seems to be required here or the mount will fail */
 
       /* Mount the volume on HSMCI0 */
 
diff --git a/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c b/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
index 36105ab..d861e03 100644
--- a/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
+++ b/boards/arm/stm32/clicker2-stm32/src/stm32_bringup.c
@@ -138,7 +138,8 @@ int stm32_bringup(void)
   ret = stm32_mrf24j40_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: stm32_mrf24j40_initialize() failed: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: stm32_mrf24j40_initialize() failed: %d\n",
+             ret);
     }
 #endif
 
@@ -159,7 +160,8 @@ int stm32_bringup(void)
   ret = stm32_automount_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: stm32_automount_initialize() failed: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: stm32_automount_initialize() failed: %d\n",
+             ret);
     }
 #endif
 
diff --git a/boards/arm/stm32/cloudctrl/src/stm32_w25.c b/boards/arm/stm32/cloudctrl/src/stm32_w25.c
index 09c24b1..55d191b 100644
--- a/boards/arm/stm32/cloudctrl/src/stm32_w25.c
+++ b/boards/arm/stm32/cloudctrl/src/stm32_w25.c
@@ -60,6 +60,7 @@
  ****************************************************************************/
 
 /* Configuration ************************************************************/
+
 /* Can't support the W25 device if it SPI1 or W25 support is not enabled */
 
 #define HAVE_W25  1
@@ -120,7 +121,7 @@ int stm32_w25initialize(int minor)
     }
 
 #ifndef CONFIG_FS_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(minor, mtd);
   if (ret < 0)
@@ -149,5 +150,6 @@ int stm32_w25initialize(int minor)
     }
 #endif
 #endif
+
   return OK;
 }
diff --git a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
index 95e129d..5e4de80 100644
--- a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
+++ b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c
@@ -59,6 +59,7 @@
  ****************************************************************************/
 
 /* Configuration ************************************************************/
+
 /* Can't support the W25 device if it SPI1 or W25 support is not enabled */
 
 #define HAVE_W25  1
@@ -119,7 +120,7 @@ int stm32_w25initialize(int minor)
     }
 
 #ifndef CONFIG_FS_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(minor, mtd);
   if (ret < 0)
@@ -148,5 +149,6 @@ int stm32_w25initialize(int minor)
     }
 #endif
 #endif
+
   return OK;
 }
diff --git a/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
index 6f9fb84..1fdaa9f 100644
--- a/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f207zg/src/stm32_bringup.c
@@ -62,7 +62,8 @@
  *   CONFIG_BOARD_LATE_INITIALIZE=y :
  *     Called from board_late_initialize().
  *
- *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y && CONFIG_NSH_ARCHINIT:
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y &&
+ *   CONFIG_NSH_ARCHINIT:
  *     Called from the NSH library
  *
  ****************************************************************************/
diff --git a/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
index 8b0d9db..433bde8 100644
--- a/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
+++ b/boards/arm/stm32/nucleo-f303ze/src/stm32_bringup.c
@@ -62,7 +62,8 @@
  *   CONFIG_BOARD_LATE_INITIALIZE=y :
  *     Called from board_late_initialize().
  *
- *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y && CONFIG_NSH_ARCHINIT:
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y &&
+ *   CONFIG_NSH_ARCHINIT:
  *     Called from the NSH library
  *
  ****************************************************************************/
diff --git a/boards/arm/stm32/omnibusf4/src/stm32_bringup.c b/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
index e8ec765..8f125e4 100644
--- a/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
+++ b/boards/arm/stm32/omnibusf4/src/stm32_bringup.c
@@ -234,7 +234,6 @@ int stm32_bringup(void)
     }
 #endif
 
-
 #ifdef CONFIG_USERLED
   /* Register the LED driver */
 
diff --git a/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c b/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
index 5c98f55..768702b 100644
--- a/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/stm32/omnibusf4/src/stm32_romfs_initialize.c
  * This file provides contents of an optional ROMFS volume, mounted at boot.
  *
@@ -34,7 +34,7 @@
  *
  ****************************************************************************/
 
-/*****************************************************************************
+/****************************************************************************
  * Included Files
  ****************************************************************************/
 
diff --git a/boards/arm/stm32/shenzhou/src/stm32_w25.c b/boards/arm/stm32/shenzhou/src/stm32_w25.c
index 846b5c7..a58c2e8 100644
--- a/boards/arm/stm32/shenzhou/src/stm32_w25.c
+++ b/boards/arm/stm32/shenzhou/src/stm32_w25.c
@@ -60,6 +60,7 @@
  ****************************************************************************/
 
 /* Configuration ************************************************************/
+
 /* Can't support the W25 device if it SPI1 or W25 support is not enabled */
 
 #define HAVE_W25  1
@@ -120,7 +121,7 @@ int stm32_w25initialize(int minor)
     }
 
 #ifndef CONFIG_FS_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(minor, mtd);
   if (ret < 0)
@@ -149,5 +150,6 @@ int stm32_w25initialize(int minor)
     }
 #endif
 #endif
+
   return OK;
 }
diff --git a/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c b/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
index a721fe6..5057149 100644
--- a/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm3240g-eval/src/stm32_bringup.c
@@ -96,8 +96,8 @@
 #define HAVE_USBHOST    1
 #define HAVE_RTC_DRIVER 1
 
-/* Can't support MMC/SD features if mountpoints are disabled or if SDIO support
- * is not enabled.
+/* Can't support MMC/SD features if mountpoints are disabled or if SDIO
+ * support is not enabled.
  */
 
 #if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_SDIO)
@@ -287,7 +287,7 @@ int stm32_bringup(void)
       if (!mtd)
         {
           syslog(LOG_ERR,
-                 "ERROR: Failed to bind SPI port 0 to the SPI FLASH driver\n");
+                 "ERROR: Failed to bind SPI port 0 to SPI FLASH driver\n");
         }
     }
 
@@ -296,6 +296,7 @@ int stm32_bringup(void)
 
 #ifdef HAVE_MMCSD
   /* Mount the SDIO-based MMC/SD block driver */
+
   /* First, get an instance of the SDIO interface */
 
   sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
index 6b8a731..061167c 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c
@@ -103,9 +103,10 @@ int stm32_at24_automount(int minor)
         }
 
 #if defined(CONFIG_STM32F103MINIMUM_AT24_FTL)
-      /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+      /* And use the FTL layer to wrap the MTD driver as a block driver */
 
-      finfo("Initialize the FTL layer to create /dev/mtdblock%d\n", AT24_MINOR);
+      finfo("Initialize the FTL layer to create /dev/mtdblock%d\n",
+            AT24_MINOR);
       ret = ftl_initialize(AT24_MINOR, mtd);
       if (ret < 0)
         {
@@ -134,6 +135,7 @@ int stm32_at24_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initialized */
 
       initialized = true;
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
index 173710c..2ba1748 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c
@@ -61,6 +61,7 @@
  ****************************************************************************/
 
 /* Debug ********************************************************************/
+
 /* Non-standard debug that may be enabled just for testing the watchdog
  * timer
  */
@@ -68,6 +69,7 @@
 #define W25_SPI_PORT 1
 
 /* Configuration ************************************************************/
+
 /* Can't support the W25 device if it SPI1 or W25 support is not enabled */
 
 #define HAVE_W25  1
@@ -131,7 +133,7 @@ int stm32_w25initialize(int minor)
     }
 
 #ifndef CONFIG_FS_SMARTFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(minor, mtd);
   if (ret < 0)
@@ -152,122 +154,126 @@ int stm32_w25initialize(int minor)
     }
 
 #ifdef CONFIG_STM32F103MINIMUM_FLASH_PART
-  {
-    int partno;
-    int partsize;
-    int partoffset;
-    int partszbytes;
-    int erasesize;
-    const char *partstring = CONFIG_STM32F103MINIMUM_FLASH_PART_LIST;
-    const char *ptr;
-    FAR struct mtd_dev_s *mtd_part;
-    char  partref[4];
+    {
+      int partno;
+      int partsize;
+      int partoffset;
+      int partszbytes;
+      int erasesize;
+      const char *partstring = CONFIG_STM32F103MINIMUM_FLASH_PART_LIST;
+      const char *ptr;
+      FAR struct mtd_dev_s *mtd_part;
+      char  partref[4];
 
-    /* Now create a partition on the FLASH device */
+      /* Now create a partition on the FLASH device */
 
-    partno = 0;
-    ptr = partstring;
-    partoffset = 0;
+      partno = 0;
+      ptr = partstring;
+      partoffset = 0;
 
-    /* Get the Flash erase size */
+      /* Get the Flash erase size */
 
-    erasesize = geo.erasesize;
+      erasesize = geo.erasesize;
 
-    while (*ptr != '\0')
-      {
-        /* Get the partition size */
+      while (*ptr != '\0')
+        {
+          /* Get the partition size */
 
-        partsize = atoi(ptr);
-        partszbytes = (partsize << 10); /* partsize is defined in KB */
+          partsize = atoi(ptr);
+          partszbytes = (partsize << 10); /* partsize is defined in KB */
 
-        /* Check if partition size is bigger then erase block */
+          /* Check if partition size is bigger then erase block */
 
-        if (partszbytes < erasesize)
-          {
-            syslog(LOG_ERR, "ERROR: Partition size is lesser than erasesize!\n");
-            return -1;
-          }
+          if (partszbytes < erasesize)
+            {
+              syslog(LOG_ERR,
+                     "ERROR: Partition size is lesser than erasesize!\n");
+              return -1;
+            }
 
-        /* Check if partition size is multiple of erase block */
+          /* Check if partition size is multiple of erase block */
 
-        if ( (partszbytes % erasesize) != 0 )
-          {
-            syslog(LOG_ERR, "ERROR: Partition size is not multiple of erasesize!\n");
-            return -1;
-          }
+          if ((partszbytes % erasesize) != 0)
+            {
+              syslog(LOG_ERR,
+                     "ERROR: Partition size isn't multiple of erasesize!\n");
+              return -1;
+            }
 
-        mtd_part = mtd_partition(mtd, partoffset,  partszbytes/ erasesize);
-        partoffset += partszbytes / erasesize;
+          mtd_part = mtd_partition(mtd, partoffset, partszbytes / erasesize);
+          partoffset += partszbytes / erasesize;
 
 #ifdef CONFIG_STM32F103MINIMUM_FLASH_CONFIG_PART
-        /* Test if this is the config partition */
+          /* Test if this is the config partition */
 
-        if (CONFIG_STM32F103MINIMUM_FLASH_CONFIG_PART_NUMBER == partno)
-          {
-            /* Register the partition as the config device */
+          if (CONFIG_STM32F103MINIMUM_FLASH_CONFIG_PART_NUMBER == partno)
+            {
+              /* Register the partition as the config device */
 
-            mtdconfig_register(mtd_part);
-          }
-        else
+              mtdconfig_register(mtd_part);
+            }
+          else
 #endif
-          {
-            /* Now initialize a SMART Flash block device and bind it
-             * to the MTD device.
-             */
+            {
+              /* Now initialize a SMART Flash block device and bind it
+               * to the MTD device.
+               */
 
 #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
-            sprintf(partref, "p%d", partno);
-            smart_initialize(CONFIG_STM32F103MINIMUM_FLASH_MINOR, mtd_part, partref);
+              sprintf(partref, "p%d", partno);
+              smart_initialize(CONFIG_STM32F103MINIMUM_FLASH_MINOR,
+                               mtd_part, partref);
 #endif
-          }
+            }
 
-        /* Set the partition name */
+          /* Set the partition name */
 
 #if defined(CONFIG_MTD_PARTITION_NAMES)
-        if (!mtd_part)
-          {
-            syslog(LOG_ERR, "Error: failed to create partition %s\n", partname);
-            return -1;
-          }
-
-        mtd_setpartitionname(mtd_part, partname);
-
-        /* Now skip to next name.  We don't need to split the string here
-         * because the MTD partition logic will only display names up to
-         * the comma, thus allowing us to use a single static name
-         * in the code.
-         */
-
-        while (*partname != ',' && *partname != '\0')
-          {
-            /* Skip to next ',' */
-
-            partname++;
-          }
-
-        if (*partname == ',')
-          {
-            partname++;
-          }
+          if (!mtd_part)
+            {
+              syslog(LOG_ERR, "Error: failed to create partition %s\n",
+                     partname);
+              return -1;
+            }
+
+          mtd_setpartitionname(mtd_part, partname);
+
+          /* Now skip to next name.  We don't need to split the string here
+           * because the MTD partition logic will only display names up to
+           * the comma, thus allowing us to use a single static name
+           * in the code.
+           */
+
+          while (*partname != ',' && *partname != '\0')
+            {
+              /* Skip to next ',' */
+
+              partname++;
+            }
+
+          if (*partname == ',')
+            {
+              partname++;
+            }
 #endif
 
-        /* Update the pointer to point to the next size in the list */
+          /* Update the pointer to point to the next size in the list */
 
-        while ((*ptr >= '0') && (*ptr <= '9'))
-          {
-            ptr++;
-          }
+          while ((*ptr >= '0') && (*ptr <= '9'))
+            {
+              ptr++;
+            }
 
-        if (*ptr == ',')
-          {
-            ptr++;
-          }
+          if (*ptr == ',')
+            {
+              ptr++;
+            }
 
-        /* Increment the part number */
+          /* Increment the part number */
 
-        partno++;
-      }
-  }
+          partno++;
+        }
+    }
 #else /* CONFIG_STM32F103MINIMUM_FLASH_PART */
 
   /* Configure the device with no partition support */
diff --git a/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c b/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
index 60a2cf5..a08c1e7 100644
--- a/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f411e-disco/src/stm32_bringup.c
@@ -74,8 +74,8 @@ int stm32_bringup(void)
   int ret = OK;
 
 #if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
-  /* Initialize USB host operation.  stm32_usbhost_initialize() starts a thread
-   * will monitor for USB connection and disconnection events.
+  /* Initialize USB host operation.  stm32_usbhost_initialize() starts
+   * a thread will monitor for USB connection and disconnection events.
    */
 
   ret = stm32_usbhost_initialize();
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c b/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
index bfb925e..0e2c5e4 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/stm32/stm32f4discovery/src/stm32_romfs_initialize.c
  * This file provides contents of an optional ROMFS volume, mounted at boot.
  *
@@ -34,7 +34,7 @@
  *
  ****************************************************************************/
 
-/*****************************************************************************
+/****************************************************************************
  * Included Files
  ****************************************************************************/
 
diff --git a/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
index 741378e..985a6dc 100644
--- a/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
+++ b/boards/arm/stm32f0l0g0/nucleo-f091rc/src/stm32_bringup.c
@@ -82,7 +82,8 @@ int stm32_bringup(void)
   ret = stm32_lpwaninitialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to initialize wireless driver: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: Failed to initialize wireless driver: %d\n",
+             ret);
     }
 #endif /* CONFIG_LPWAN_SX127X */
 
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c b/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
index 68e9ce2..9a8302c 100644
--- a/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/stm32f7/nucleo-144/src/stm32_romfs_initialize.c
  * This file provides contents of an optional ROMFS volume, mounted at boot.
  *
@@ -34,7 +34,7 @@
  *
  ****************************************************************************/
 
-/*****************************************************************************
+/****************************************************************************
  * Included Files
  ****************************************************************************/
 
diff --git a/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c b/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
index d2fe1bc..a6cb501 100644
--- a/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
+++ b/boards/arm/stm32l4/b-l475e-iot01a/src/stm32_bringup.c
@@ -65,10 +65,10 @@
  * Name: stm32l4_bringup
  *
  * Description:
- *   Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or by
- *   board_app_initialize if CONFIG_LIB_BOARDCTL is selected.  This function
- *   initializes and configures all on-board features appropriate for the
- *   selected configuration.
+ *   Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or
+ *   by board_app_initialize if CONFIG_LIB_BOARDCTL is selected.  This
+ *   function initializes and configures all on-board features appropriate
+ *   for the selected configuration.
  *
  ****************************************************************************/
 
@@ -104,131 +104,134 @@ int stm32l4_bringup(void)
 #endif /* CONFIG_USERLED && !CONFIG_ARCH_LEDS */
 
 #ifdef HAVE_MX25R6435F
-  {
-    /* Create an instance of the STM32L4 QSPI device driver */
-
-    FAR struct qspi_dev_s *g_qspi;
-    FAR struct mtd_dev_s *g_mtd_fs;
-
-    g_qspi = stm32l4_qspi_initialize(0);
-    if (g_qspi == NULL)
-      {
-        syslog(LOG_ERR, "ERROR: stm32l4_qspi_initialize failed\n");
-        return -EIO;
-      }
-
-    /* Use the QSPI device instance to initialize the
-     * MX25R6435F flash device.
-     */
-
-    g_mtd_fs = mx25rxx_initialize(g_qspi, true);
-    if (!g_mtd_fs)
-      {
-        syslog(LOG_ERR, "ERROR: mx25rxx_initialize failed\n");
-        return -EIO;
-      }
+    {
+      /* Create an instance of the STM32L4 QSPI device driver */
+
+      FAR struct qspi_dev_s *g_qspi;
+      FAR struct mtd_dev_s *g_mtd_fs;
+
+      g_qspi = stm32l4_qspi_initialize(0);
+      if (g_qspi == NULL)
+        {
+          syslog(LOG_ERR, "ERROR: stm32l4_qspi_initialize failed\n");
+          return -EIO;
+        }
+
+      /* Use the QSPI device instance to initialize the
+       * MX25R6435F flash device.
+       */
+
+      g_mtd_fs = mx25rxx_initialize(g_qspi, true);
+      if (!g_mtd_fs)
+        {
+          syslog(LOG_ERR, "ERROR: mx25rxx_initialize failed\n");
+          return -EIO;
+        }
 
 #ifdef CONFIG_B_L475E_IOT01A_MTD_PART
-      {
-        /* Create partitions on external flash memory */
-
-        int partno;
-        int partsize;
-        int partoffset;
-        int partszbytes;
-        int erasesize;
-        FAR struct mtd_geometry_s geo;
-        const char *ptr = CONFIG_B_L475E_IOT01A_MTD_PART_LIST;
-        FAR struct mtd_dev_s *mtd_part;
-        char  partref[4];
-
-        /* Now create a partition on the FLASH device */
-
-        partno = 0;
-        partoffset = 0;
-
-        /* Query MTD geometry */
-
-        ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
-                        (unsigned long)(uintptr_t)&geo);
-        if (ret < 0)
-          {
-            syslog(LOG_ERR, "ERROR: MTDIOC_GEOMETRY failed\n");
-            return ret;
-          }
-
-        /* Get the Flash erase size */
-
-        erasesize = geo.erasesize;
-
-        while (*ptr != '\0')
-          {
-            /* Get the partition size */
-
-            partsize = atoi(ptr);
-            if (partsize <= 0)
-              {
-                syslog(LOG_ERR, "Error while processing <%s>\n", ptr);
-                goto process_next_part;
-              }
-
-            partszbytes = (partsize << 10); /* partsize is defined in KB */
-
-            if ((partszbytes < erasesize) || ((partszbytes % erasesize) != 0))
-              {
-                syslog(LOG_ERR, "Invalid partition size: %d bytes\n",
-                       partszbytes);
-                partszbytes = (partszbytes+erasesize) & -erasesize;
-              }
-
-            mtd_part = mtd_partition(g_mtd_fs, partoffset,
-                                     partszbytes / geo.blocksize);
-            partoffset += partszbytes / geo.blocksize;
-
-            if (!mtd_part)
-              {
-                syslog(LOG_ERR, "Failed to create part %d, size=%d\n",
-                       partno, partsize);
-                goto process_next_part;
-              }
+        {
+          /* Create partitions on external flash memory */
+
+          int partno;
+          int partsize;
+          int partoffset;
+          int partszbytes;
+          int erasesize;
+          FAR struct mtd_geometry_s geo;
+          const char *ptr = CONFIG_B_L475E_IOT01A_MTD_PART_LIST;
+          FAR struct mtd_dev_s *mtd_part;
+          char  partref[4];
+
+          /* Now create a partition on the FLASH device */
+
+          partno = 0;
+          partoffset = 0;
+
+          /* Query MTD geometry */
+
+          ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY,
+                          (unsigned long)(uintptr_t)&geo);
+          if (ret < 0)
+            {
+              syslog(LOG_ERR, "ERROR: MTDIOC_GEOMETRY failed\n");
+              return ret;
+            }
+
+          /* Get the Flash erase size */
+
+          erasesize = geo.erasesize;
+
+          while (*ptr != '\0')
+            {
+              /* Get the partition size */
+
+              partsize = atoi(ptr);
+              if (partsize <= 0)
+                {
+                  syslog(LOG_ERR, "Error while processing <%s>\n", ptr);
+                  goto process_next_part;
+                }
+
+              partszbytes = (partsize << 10); /* partsize is defined in KB */
+
+              if (partszbytes < erasesize || (partszbytes % erasesize) != 0)
+                {
+                  syslog(LOG_ERR, "Invalid partition size: %d bytes\n",
+                        partszbytes);
+                  partszbytes = (partszbytes + erasesize) & -erasesize;
+                }
+
+              mtd_part = mtd_partition(g_mtd_fs, partoffset,
+                                      partszbytes / geo.blocksize);
+              partoffset += partszbytes / geo.blocksize;
+
+              if (!mtd_part)
+                {
+                  syslog(LOG_ERR, "Failed to create part %d, size=%d\n",
+                        partno, partsize);
+                  goto process_next_part;
+                }
 
 #if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
-            /* Now initialize a SMART Flash block device and bind it to the MTD
-             * device */
+              /* Now initialize a SMART Flash block device and bind it to
+               * the MTD device
+               */
 
-            sprintf(partref, "p%d", partno);
-            smart_initialize(CONFIG_B_L475E_IOT01A_MTD_FLASH_MINOR,
-                             mtd_part, partref);
+              sprintf(partref, "p%d", partno);
+              smart_initialize(CONFIG_B_L475E_IOT01A_MTD_FLASH_MINOR,
+                              mtd_part, partref);
 #endif
 
-process_next_part:
-            /* Update the pointer to point to the next size in the list */
+  process_next_part:
+
+              /* Update the pointer to point to the next size in the list */
 
-            while ((*ptr >= '0') && (*ptr <= '9'))
-              {
-                ptr++;
-              }
+              while ((*ptr >= '0') && (*ptr <= '9'))
+                {
+                  ptr++;
+                }
 
-            if (*ptr == ',')
-              {
-                ptr++;
-              }
+              if (*ptr == ',')
+                {
+                  ptr++;
+                }
 
-            /* Increment the part number */
+              /* Increment the part number */
 
-            partno++;
-          }
-      }
+              partno++;
+            }
+        }
 #else /* CONFIG_B_L475E_IOT01A_MTD_PART */
 
 #ifdef HAVE_MX25R6435F_SMARTFS
       /* Configure the device with no partition support */
 
-      smart_initialize(CONFIG_B_L475E_IOT01A_MTD_FLASH_MINOR, g_mtd_fs, NULL);
+      smart_initialize(CONFIG_B_L475E_IOT01A_MTD_FLASH_MINOR,
+                       g_mtd_fs, NULL);
 #endif /* HAVE_MX25R6435F_SMARTFS */
 
 #endif /* CONFIG_B_L475E_IOT01A_MTD_PART */
-  }
+    }
 #endif /* HAVE_MX25R6435F */
 
 #ifdef HAVE_SPSGRF
@@ -237,17 +240,19 @@ process_next_part:
   ret = stm32l4_spirit_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: stm32l4_spirit_initialize() failed: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: stm32l4_spirit_initialize() failed: %d\n",
+             ret);
     }
 #endif
 
 #ifdef CONFIG_TIMER
-/* Register timer drivers */
+  /* Register timer drivers */
 
   ret = stm32l4_timer_driver_setup();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to setup TIM1 at /dev/timer0: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: Failed to setup TIM1 at /dev/timer0: %d\n",
+             ret);
     }
 #endif
 
diff --git a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
index 45d6da6..e303e80 100644
--- a/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
+++ b/boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45db.c
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/****************************************************************************
  * boards/arm/stm32l4/nucleo-l432kc/src/stm32_at45.c
  *
  *   Copyright (C) 2018 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ******************************************************************************/
+ ****************************************************************************/
 
-/*******************************************************************************
+/****************************************************************************
  * Included Files
- ******************************************************************************/
+ ****************************************************************************/
 
 #include <nuttx/config.h>
 
@@ -51,31 +51,31 @@
 
 #include "stm32l4_spi.h"
 
-/*******************************************************************************
+/****************************************************************************
  * Pre-processor Definitions
- ******************************************************************************/
+ ****************************************************************************/
 
 #ifndef CONFIG_STM32L4_SPI1
 #  error "AT45DB driver requires CONFIG_STM32_SPI1 to be enabled"
 #endif
 
-/*******************************************************************************
-* Private Definitions
-******************************************************************************/
+/****************************************************************************
+ * Private Definitions
+ ****************************************************************************/
 
 static const int AT45DB_SPI_PORT = 1; /* AT45DB is connected to SPI1 port */
 
-/*******************************************************************************
+/****************************************************************************
  * Public Functions
- ******************************************************************************/
+ ****************************************************************************/
 
-/*******************************************************************************
+/****************************************************************************
  * Name: stm32_at45dbinitialize
  *
  * Description:
  *   Initialize and configure the AT45DB SPI Serial Flash Memory
  *
- ******************************************************************************/
+ ****************************************************************************/
 
 int stm32_at45dbinitialize(int minor)
 {
diff --git a/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c b/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
index 36f7c30..8b51f13 100644
--- a/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
+++ b/boards/arm/stm32l4/nucleo-l452re/src/stm32_adc.c
@@ -77,7 +77,7 @@
 #endif
 
 /* Internal reference voltage calibration value locations. Taken from
- * https://github.com/micropython/micropython/commit/87215a0f0480dd0324a1b9c1d3fc3a5c2806249d
+ * https://github.com/micropython/micropython/commit/87215a0f0480dd0324a1b9c1
  *
  * F0 value from DM00115237 Rev 4 p. 19. for STM32F091xB and STM32F091xC
  *
diff --git a/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c b/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
index 3ab5e72..d2860c6 100644
--- a/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/nucleo-l476rg/src/stm32_appinit.c
@@ -68,7 +68,7 @@
 
 /****************************************************************************
  * Private Data
- ***************************************************************************/
+ ****************************************************************************/
 
 /****************************************************************************
  * Public Functions
@@ -98,19 +98,19 @@ static void stm32_i2c_register(int bus)
 
   i2c = stm32l4_i2cbus_initialize(bus);
   if (i2c == NULL)
-  {
-    syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
-  }
+    {
+      syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
+    }
   else
-  {
-    ret = i2c_register(i2c, bus);
-    if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
-             bus, ret);
-      stm32l4_i2cbus_uninitialize(i2c);
+      ret = i2c_register(i2c, bus);
+      if (ret < 0)
+        {
+          syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
+                bus, ret);
+          stm32l4_i2cbus_uninitialize(i2c);
+        }
     }
-  }
 }
 #endif
 
@@ -292,7 +292,7 @@ int board_app_initialize(uintptr_t arg)
     }
 #endif
 
-/* Initialize MMC and register the MMC driver. */
+  /* Initialize MMC and register the MMC driver. */
 
 #ifdef HAVE_MMCSD_SPI
   ret = stm32l4_mmcsd_initialize(MMCSD_MINOR);
diff --git a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
index bfa3342..fcc2cbe 100644
--- a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
+++ b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_appinitialize.c
@@ -53,19 +53,19 @@
 
 /****************************************************************************
  * Private Data
- ***************************************************************************/
+ ****************************************************************************/
 
 #if defined(CONFIG_STM32L4_I2C1)
-struct i2c_master_s* i2c1;
+struct i2c_master_s *i2c1;
 #endif
 #if defined(CONFIG_STM32L4_I2C2)
-struct i2c_master_s* i2c2;
+struct i2c_master_s *i2c2;
 #endif
 #if defined(CONFIG_STM32L4_I2C3)
-struct i2c_master_s* i2c3;
+struct i2c_master_s *i2c3;
 #endif
 #if defined(CONFIG_STM32L4_I2C4)
-struct i2c_master_s* i2c4;
+struct i2c_master_s *i2c4;
 #endif
 
 /****************************************************************************
@@ -166,7 +166,8 @@ int board_app_initialize(uintptr_t arg)
   ret = stm32_spidev_bus_test();
   if (ret != OK)
     {
-      syslog(LOG_ERR, "ERROR: Failed to initialize SPI interfaces: %d\n", ret);
+      syslog(LOG_ERR, "ERROR: Failed to initialize SPI interfaces: %d\n",
+             ret);
       return ret;
     }
 #endif
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
index 17e74e2..51c700a 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/****************************************************************************
  * boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_adc.c
  *
  *   Copyright (C) 2017-2018 Haltian Ltd. All rights reserved.
@@ -61,9 +61,9 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* STM32 chip specific calibration values *******************************************/
+/* STM32 chip specific calibration values ***********************************/
 
-/* Voltage used for calibration of internal analog reference voltage (Vrefint) */
+/* Voltage used for calibration of internal analog reference voltage */
 
 #if defined(CONFIG_ARCH_CHIP_STM32F7) \
  || defined(CONFIG_ARCH_CHIP_STM32F4) \
@@ -74,7 +74,7 @@
 #endif
 
 /* Internal reference voltage calibration value locations. Taken from
- * https://github.com/micropython/micropython/commit/87215a0f0480dd0324a1b9c1d3fc3a5c2806249d
+ * https://github.com/micropython/micropython/commit/87215a0f0480dd0324a1b9c1
  *
  * F0 value from DM00115237 Rev 4 p. 19. for STM32F091xB and STM32F091xC
  *
@@ -110,7 +110,7 @@
 #  define STM32_TSENSE_TSCAL2 (*(int16_t *)((uint32_t)0x1fff75ca))
 #endif
 
-/* Configuration ********************************************************************/
+/* Configuration ************************************************************/
 
 /* These are internal to STM32L4 */
 
@@ -146,9 +146,9 @@ static const uint8_t g_chanlist[ADC1_NCHANNELS] =
 
 static const uint32_t g_pinlist[ADC1_NCHANNELS] =
 {
-  0xffffffffU,
-  0xffffffffU,
-  0xffffffffU,
+  0xffffffffu,
+  0xffffffffu,
+  0xffffffffu,
   GPIO_MEASURE_ADC,
 };
 
@@ -164,9 +164,10 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] =
  *
  ****************************************************************************/
 
-int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *vext)
+int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat,
+                                 uint32_t *vext)
 {
-  struct adc_msg_s sample[ADC1_NCHANNELS] = { 0 };
+  struct adc_msg_s sample[ADC1_NCHANNELS];
   FAR struct file filestruct;
   ssize_t nbytes;
   int nsamples;
@@ -223,7 +224,7 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *ve
       for (i = 0; i < nsamples ; i++)
         {
           ainfo("%d: channel: %d value: %d\n",
-                i+1, sample[i].am_channel, sample[i].am_data);
+                i + 1, sample[i].am_channel, sample[i].am_data);
 
           /* Add the raw value to entropy pool. */
 
@@ -232,9 +233,11 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *ve
           switch (sample[i].am_channel)
             {
               case ADC1_INTERNAL_VREFINT_CHANNEL:
-                /* Calculate corrected Vrefint with factory calibration value. */
 
-                *vrefint = STM32_VREFINT_MVOLTS * STM32_VREFINT_CAL / sample[i].am_data;
+                /* Calculate corrected Vrefint with factory value. */
+
+                *vrefint = STM32_VREFINT_MVOLTS * STM32_VREFINT_CAL /
+                           sample[i].am_data;
                 ainfo("VREFINT: %d -> %u mV\n", sample[i].am_data, *vrefint);
                 break;
 
@@ -243,8 +246,9 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *ve
                  * so it does not matter much if we use integer type here.
                  */
 
-                tsense = (110 - 30) * (sample[i].am_data - STM32_TSENSE_TSCAL1)
-                                    / (STM32_TSENSE_TSCAL2 - STM32_TSENSE_TSCAL1) + 30;
+                tsense = 30 + (110 - 30) *
+                         (sample[i].am_data - STM32_TSENSE_TSCAL1) /
+                         (STM32_TSENSE_TSCAL2 - STM32_TSENSE_TSCAL1);
                 ainfo("TSENSE: %d -> %d °C\n", sample[i].am_data, tsense);
                 UNUSED(tsense);
                 break;
@@ -260,7 +264,8 @@ int stm32l4_adc_measure_voltages(uint32_t *vrefint, uint32_t *vbat, uint32_t *ve
                 break;
 
               default:
-                aerr("ERROR: ADC got value from unknown channel %d\n", sample[i].am_channel);
+                aerr("ERROR: ADC got value from unknown channel %d\n",
+                     sample[i].am_channel);
                 break;
             }
         }
@@ -283,19 +288,20 @@ int stm32l4_adc_setup(void)
   if (!initialized)
     {
 #ifdef CONFIG_STM32L4_ADC1
-      int ret, i;
+      int ret;
+      int i;
 
       /* Configure the pins as analog inputs for the selected channels */
 
       for (i = 0; i < ADC1_NCHANNELS; i++)
         {
-          if (g_pinlist[i] != 0xffffffffU)
+          if (g_pinlist[i] != 0xffffffffu)
             {
               stm32l4_configgpio(g_pinlist[i]);
             }
         }
 
-      /* Call stm32l4_adc_initialize() to get an instance of the ADC interface */
+      /* Call stm32l4_adc_initialize() to get an instance of the ADC */
 
       g_adc = stm32l4_adc_initialize(1, g_chanlist, ADC1_NCHANNELS);
       if (g_adc == NULL)
@@ -313,6 +319,7 @@ int stm32l4_adc_setup(void)
           return ret;
         }
 #endif
+
       initialized = true;
     }
 
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
index 56d93a7..bb1b9a6 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_appinit.c
@@ -64,9 +64,9 @@
 
 #include "stm32l4r9ai-disco.h"
 
-/* Conditional logic in stm32l4r9ai-disco.h will determine if certain features
- * are supported.  Tests for these features need to be made after including
- * stm32l4r9ai-disco.
+/* Conditional logic in stm32l4r9ai-disco.h will determine if certain
+ * features are supported.  Tests for these features need to be made
+ * after includingstm32l4r9ai-disco.
  */
 
 #ifdef HAVE_RTC_DRIVER
@@ -80,10 +80,10 @@
 
 #ifdef CONFIG_I2C
 #  ifdef CONFIG_STM32L4_I2C1
-static struct i2c_master_s* g_i2c1;
+static struct i2c_master_s *g_i2c1;
 #  endif
 #  ifdef CONFIG_STM32L4_I2C3
-static struct i2c_master_s* g_i2c3;
+static struct i2c_master_s *g_i2c3;
 #  endif
 #endif
 
diff --git a/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c b/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
index 3b3e7f4..3cf103f 100644
--- a/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
+++ b/boards/arm/tiva/launchxl-cc1310/src/cc1310_bringup.c
@@ -60,8 +60,8 @@
  * Description:
  *   Bring up board features.
  *
- *   If CONFIG_BOARD_LATE_INITIALIZE=y, then this function will be called from
- *   board_late_initialize().
+ *   If CONFIG_BOARD_LATE_INITIALIZE=y, then this function will be called
+ *   from board_late_initialize().
  *
  *   If CONFIG_BOARD_LATE_INITIALIZE is not selected,
  *   but CONFIG_LIB_BOARDCTL=y
diff --git a/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c b/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
index 497798b..606eac9 100644
--- a/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
+++ b/boards/arm/tiva/launchxl-cc1312r1/src/cc1312_bringup.c
@@ -60,8 +60,8 @@
  * Description:
  *   Bring up board features.
  *
- *   If CONFIG_BOARD_LATE_INITIALIZE=y, then this function will be called from
- *   board_late_initialize().
+ *   If CONFIG_BOARD_LATE_INITIALIZE=y, then this function will be called
+ *   from board_late_initialize().
  *
  *   If CONFIG_BOARD_LATE_INITIALIZE is not selected,
  *   but CONFIG_LIB_BOARDCTL=y
diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
index ead4a83..b762cdd 100644
--- a/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
+++ b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c
@@ -108,7 +108,8 @@ int lm_bringup(void)
       return -ENODEV;
     }
 
-  mcinfo("Successfully initialized SPI port %d\n", CONFIG_NSH_MMCSDSPIPORTNO);
+  mcinfo("Successfully initialized SPI port %d\n",
+         CONFIG_NSH_MMCSDSPIPORTNO);
 
   /* Bind the SPI port to the slot */
 
diff --git a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
index 0f06feb..462816c 100644
--- a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
+++ b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c
@@ -117,9 +117,7 @@ int tm4c_at24_automount(int minor)
         }
 
 #if defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL)
-      /* And finally,
-       * use the FTL layer to wrap the MTD driver as a block driver
-       */
+      /* And use the FTL layer to wrap the MTD driver as a block driver */
 
       ret = ftl_initialize(AT24_MINOR, mtd);
       if (ret < 0)
@@ -149,6 +147,7 @@ int tm4c_at24_automount(int minor)
           return ret;
         }
 #endif
+
       /* Now we are initialized */
 
       initialized = true;
diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
index 23540c3..77afa32 100644
--- a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
+++ b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c
@@ -61,7 +61,7 @@
 
 /* Configuration ************************************************************/
 
-/* Can't support the SST25 device if it SPI2 or SST25 support is not enabled */
+/* Can't support the SST25 device if it SPI2/SST25 support is not enabled */
 
 #define HAVE_SST25  1
 #if !defined(CONFIG_PIC32MX_SPI2) || !defined(CONFIG_MTD_SST25)
@@ -139,7 +139,7 @@ int board_app_initialize(uintptr_t arg)
     }
 
 #ifndef CONFIG_FS_NXFFS
-  /* And finally, use the FTL layer to wrap the MTD driver as a block driver */
+  /* And use the FTL layer to wrap the MTD driver as a block driver */
 
   ret = ftl_initialize(CONFIG_NSH_MMCSDMINOR, mtd);
   if (ret < 0)
@@ -167,5 +167,6 @@ int board_app_initialize(uintptr_t arg)
     }
 #endif
 #endif
+
   return OK;
 }
diff --git a/drivers/lcd/ili9340.c b/drivers/lcd/ili9340.c
index 24e462f..3a5a3c6 100644
--- a/drivers/lcd/ili9340.c
+++ b/drivers/lcd/ili9340.c
@@ -1133,8 +1133,8 @@ static int ili9340_setcontrast(struct lcd_dev_s *dev, unsigned int contrast)
  *
  * Returned Value:
  *
- *  On success, this function returns a reference to the LCD driver object for
- *  the specified LCD driver. NULL is returned on any failure.
+ *  On success, this function returns a reference to the LCD driver object
+ *  for the specified LCD driver. NULL is returned on any failure.
  *
  ****************************************************************************/
 
@@ -1181,9 +1181,9 @@ FAR struct lcd_dev_s *ili9340_initialize(
  *
  * Description:
  *  This is a non-standard LCD interface.  Because of the various rotations,
- *  clearing the display in the normal way by writing a sequences of runs that
- *  covers the entire display can be very slow. Here the display is cleared by
- *  simply setting all GRAM memory to the specified color.
+ *  clearing the display in the normal way by writing a sequences of runs
+ *  that covers the entire display can be very slow. Here the display is
+ *  cleared by simply setting all GRAM memory to the specified color.
  *
  * Parameter:
  *  dev   - A reference to the lcd driver structure
diff --git a/libs/libc/grp/lib_find_grpfile.c b/libs/libc/grp/lib_find_grpfile.c
index 6f9886e..60d3e48 100644
--- a/libs/libc/grp/lib_find_grpfile.c
+++ b/libs/libc/grp/lib_find_grpfile.c
@@ -312,7 +312,8 @@ static int grp_foreach(grp_foreach_match_t match, uintptr_t arg,
 int grp_findby_name(FAR const char *gname, FAR struct group *entry,
                     FAR char *buffer, size_t buflen)
 {
-  return grp_foreach(grp_match_name, (uintptr_t)gname, entry, buffer, buflen);
+  return grp_foreach(grp_match_name, (uintptr_t)gname,
+                     entry, buffer, buflen);
 }
 
 /****************************************************************************
diff --git a/libs/libc/misc/lib_sendfile.c b/libs/libc/misc/lib_sendfile.c
index dd33355..ad0f9f5 100644
--- a/libs/libc/misc/lib_sendfile.c
+++ b/libs/libc/misc/lib_sendfile.c
@@ -217,15 +217,17 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
 
               if (nbyteswritten >= 0)
                 {
-                  /* Advance the buffer pointer and decrement the number of bytes
-                   * remaining in the iobuffer.  Typically, nbytesread will now
-                   * be zero.
+                  /* Advance the buffer pointer and decrement the number of
+                   * bytes remaining in the iobuffer.  Typically, nbytesread
+                   * will now be zero.
                    */
 
                   wrbuffer     += nbyteswritten;
                   nbytesread   -= nbyteswritten;
 
-                  /* Increment the total number of bytes successfully transferred. */
+                  /* Increment the total number of bytes successfully
+                   * transferred.
+                   */
 
                   ntransferred += nbyteswritten;
                 }
diff --git a/libs/libc/pwd/lib_find_pwdfile.c b/libs/libc/pwd/lib_find_pwdfile.c
index f9f109b..dcd5152 100644
--- a/libs/libc/pwd/lib_find_pwdfile.c
+++ b/libs/libc/pwd/lib_find_pwdfile.c
@@ -289,7 +289,8 @@ static int pwd_foreach(pwd_foreach_match_t match, uintptr_t arg,
 int pwd_findby_name(FAR const char *uname, FAR struct passwd *entry,
                     FAR char *buffer, size_t buflen)
 {
-  return pwd_foreach(pwd_match_name, (uintptr_t)uname, entry, buffer, buflen);
+  return pwd_foreach(pwd_match_name, (uintptr_t)uname,
+                     entry, buffer, buflen);
 }
 
 /****************************************************************************
diff --git a/libs/libc/stdio/lib_libfwrite.c b/libs/libc/stdio/lib_libfwrite.c
index 220a274..93ec54e 100644
--- a/libs/libc/stdio/lib_libfwrite.c
+++ b/libs/libc/stdio/lib_libfwrite.c
@@ -1,7 +1,8 @@
 /****************************************************************************
  * libs/libc/stdio/lib_libfwrite.c
  *
- *   Copyright (C) 2007-2009, 2011, 2013-2014, 2017 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007-2009, 2011, 2013-2014, 2017 Gregory Nutt. All rights
+ *   reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -85,18 +86,18 @@ ssize_t lib_fwrite(FAR const void *ptr, size_t count, FAR FILE *stream)
   /* If there is no I/O buffer, then output data immediately */
 
   if (stream->fs_bufstart == NULL)
-   {
-     ret = _NX_WRITE(stream->fs_fd, ptr, count);
+    {
+      ret = _NX_WRITE(stream->fs_fd, ptr, count);
 #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
-     if (ret < 0)
-       {
-         _NX_SETERRNO(ret);
-         ret = ERROR;
-       }
+      if (ret < 0)
+        {
+          _NX_SETERRNO(ret);
+          ret = ERROR;
+        }
 #endif
 
-     goto errout;
-   }
+      goto errout;
+    }
 
   /* Get exclusive access to the stream */
 
diff --git a/libs/libc/stdio/lib_perror.c b/libs/libc/stdio/lib_perror.c
index c37fb75..354e2c5 100644
--- a/libs/libc/stdio/lib_perror.c
+++ b/libs/libc/stdio/lib_perror.c
@@ -68,7 +68,6 @@
 
 void perror(FAR const char *s)
 {
-
   /* If strerror() is not enabled, then just print the error number */
 
 #ifdef CONFIG_LIBC_STRERROR


[incubator-nuttx] 01/03: fs/fs.h: Reference the argumnet 'r' in _NX_SETERRNO

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit cf73496d9e643cbbe846a51a6a048634fb30df69
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 22 03:00:14 2021 +0800

    fs/fs.h: Reference the argumnet 'r' in _NX_SETERRNO
    
    to avoid the unused variable warning
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/nuttx/fs/fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h
index a8eec37..f651808 100644
--- a/include/nuttx/fs/fs.h
+++ b/include/nuttx/fs/fs.h
@@ -87,7 +87,7 @@
 #  define _NX_IOCTL(f,r,a)     ioctl(f,r,a)
 #  define _NX_STAT(p,s)        stat(p,s)
 #  define _NX_GETERRNO(r)      errno
-#  define _NX_SETERRNO(r)
+#  define _NX_SETERRNO(r)      ((void)(r))
 #  define _NX_GETERRVAL(r)     (-errno)
 #endif