subsys: fs: Migrate to new logging subsys

subsys:fs : Migrate from `SYS_LOG` to `LOG` logging mechanism.

tests: subsys: fs: Enabled CONFIG_LOG in prj.conf

Signed-off-by: Varun Sharma <varun.sharma@intel.com>
This commit is contained in:
Varun Sharma 2018-10-12 02:54:24 +05:30 committed by Anas Nashif
parent a58eddb84f
commit 7622fc37a0
16 changed files with 72 additions and 54 deletions

View file

@ -15,18 +15,18 @@ config FILE_SYSTEM
help
Enables support for file system.
config SYS_LOG_FS_LEVEL
config LOG_FS_LEVEL
int "File System log level"
depends on SYS_LOG
depends on LOG
default 0
help
Sets log level for File System drivers.
Levels are:
- 0 OFF, do not write
- 1 ERROR, only write SYS_LOG_ERR
- 2 WARNING, write SYS_LOG_WRN in addition to previous level
- 3 INFO, write SYS_LOG_INF in addition to previous levels
- 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
- 1 ERROR, only write LOG_ERR
- 2 WARNING, write LOG_WRN in addition to previous level
- 3 INFO, write LOG_INF in addition to previous levels
- 4 DEBUG, write LOG_DBG in addition to previous levels
if FILE_SYSTEM

View file

@ -11,8 +11,11 @@
#include <init.h>
#include <fs.h>
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_FS_LEVEL
#include <logging/sys_log.h>
#define LOG_MODULE_NAME fs
#define LOG_LEVEL CONFIG_LOG_FS_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
/* list of mounted file systems */
static sys_dlist_t fs_mnt_list;
@ -80,13 +83,13 @@ int fs_open(struct fs_file_t *zfp, const char *file_name)
if ((file_name == NULL) ||
(strlen(file_name) <= 1) || (file_name[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, file_name, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
@ -95,7 +98,7 @@ int fs_open(struct fs_file_t *zfp, const char *file_name)
if (zfp->mp->fs->open != NULL) {
rc = zfp->mp->fs->open(zfp, file_name);
if (rc < 0) {
SYS_LOG_ERR("file open error (%d)", rc);
LOG_ERR("file open error (%d)", rc);
return rc;
}
}
@ -110,7 +113,7 @@ int fs_close(struct fs_file_t *zfp)
if (zfp->mp->fs->close != NULL) {
rc = zfp->mp->fs->close(zfp);
if (rc < 0) {
SYS_LOG_ERR("file close error (%d)", rc);
LOG_ERR("file close error (%d)", rc);
return rc;
}
}
@ -127,7 +130,7 @@ ssize_t fs_read(struct fs_file_t *zfp, void *ptr, size_t size)
if (zfp->mp->fs->read != NULL) {
rc = zfp->mp->fs->read(zfp, ptr, size);
if (rc < 0) {
SYS_LOG_ERR("file read error (%d)", rc);
LOG_ERR("file read error (%d)", rc);
}
}
@ -141,7 +144,7 @@ ssize_t fs_write(struct fs_file_t *zfp, const void *ptr, size_t size)
if (zfp->mp->fs->write != NULL) {
rc = zfp->mp->fs->write(zfp, ptr, size);
if (rc < 0) {
SYS_LOG_ERR("file write error (%d)", rc);
LOG_ERR("file write error (%d)", rc);
}
}
@ -155,7 +158,7 @@ int fs_seek(struct fs_file_t *zfp, off_t offset, int whence)
if (zfp->mp->fs->lseek != NULL) {
rc = zfp->mp->fs->lseek(zfp, offset, whence);
if (rc < 0) {
SYS_LOG_ERR("file seek error (%d)", rc);
LOG_ERR("file seek error (%d)", rc);
}
}
@ -169,7 +172,7 @@ off_t fs_tell(struct fs_file_t *zfp)
if (zfp->mp->fs->tell != NULL) {
rc = zfp->mp->fs->tell(zfp);
if (rc < 0) {
SYS_LOG_ERR("file tell error (%d)", rc);
LOG_ERR("file tell error (%d)", rc);
}
}
@ -183,7 +186,7 @@ int fs_truncate(struct fs_file_t *zfp, off_t length)
if (zfp->mp->fs->truncate != NULL) {
rc = zfp->mp->fs->truncate(zfp, length);
if (rc < 0) {
SYS_LOG_ERR("file truncate error (%d)", rc);
LOG_ERR("file truncate error (%d)", rc);
}
}
@ -197,7 +200,7 @@ int fs_sync(struct fs_file_t *zfp)
if (zfp->mp->fs->sync != NULL) {
rc = zfp->mp->fs->sync(zfp);
if (rc < 0) {
SYS_LOG_ERR("file sync error (%d)", rc);
LOG_ERR("file sync error (%d)", rc);
}
}
@ -212,13 +215,13 @@ int fs_opendir(struct fs_dir_t *zdp, const char *abs_path)
if ((abs_path == NULL) ||
(strlen(abs_path) <= 1) || (abs_path[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, abs_path, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
@ -227,7 +230,7 @@ int fs_opendir(struct fs_dir_t *zdp, const char *abs_path)
if (zdp->mp->fs->opendir != NULL) {
rc = zdp->mp->fs->opendir(zdp, abs_path);
if (rc < 0) {
SYS_LOG_ERR("directory open error (%d)", rc);
LOG_ERR("directory open error (%d)", rc);
}
}
@ -241,7 +244,7 @@ int fs_readdir(struct fs_dir_t *zdp, struct fs_dirent *entry)
if (zdp->mp->fs->readdir != NULL) {
rc = zdp->mp->fs->readdir(zdp, entry);
if (rc < 0) {
SYS_LOG_ERR("directory read error (%d)", rc);
LOG_ERR("directory read error (%d)", rc);
}
}
return rc;
@ -254,7 +257,7 @@ int fs_closedir(struct fs_dir_t *zdp)
if (zdp->mp->fs->closedir != NULL) {
rc = zdp->mp->fs->closedir(zdp);
if (rc < 0) {
SYS_LOG_ERR("directory close error (%d)", rc);
LOG_ERR("directory close error (%d)", rc);
return rc;
}
}
@ -271,20 +274,20 @@ int fs_mkdir(const char *abs_path)
if ((abs_path == NULL) ||
(strlen(abs_path) <= 1) || (abs_path[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, abs_path, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
if (mp->fs->mkdir != NULL) {
rc = mp->fs->mkdir(mp, abs_path);
if (rc < 0) {
SYS_LOG_ERR("failed to create directory (%d)", rc);
LOG_ERR("failed to create directory (%d)", rc);
}
}
@ -298,20 +301,20 @@ int fs_unlink(const char *abs_path)
if ((abs_path == NULL) ||
(strlen(abs_path) <= 1) || (abs_path[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, abs_path, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
if (mp->fs->unlink != NULL) {
rc = mp->fs->unlink(mp, abs_path);
if (rc < 0) {
SYS_LOG_ERR("failed to unlink path (%d)", rc);
LOG_ERR("failed to unlink path (%d)", rc);
}
}
@ -326,26 +329,26 @@ int fs_rename(const char *from, const char *to)
if ((from == NULL) || (strlen(from) <= 1) || (from[0] != '/') ||
(to == NULL) || (strlen(to) <= 1) || (to[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, from, &match_len);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
/* Make sure both files are mounted on the same path */
if (strncmp(from, to, match_len) != 0) {
SYS_LOG_ERR("mount point not same!!");
LOG_ERR("mount point not same!!");
return -EINVAL;
}
if (mp->fs->rename != NULL) {
rc = mp->fs->rename(mp, from, to);
if (rc < 0) {
SYS_LOG_ERR("failed to rename file or dir (%d)", rc);
LOG_ERR("failed to rename file or dir (%d)", rc);
}
}
@ -359,20 +362,20 @@ int fs_stat(const char *abs_path, struct fs_dirent *entry)
if ((abs_path == NULL) ||
(strlen(abs_path) <= 1) || (abs_path[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, abs_path, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
if (mp->fs->stat != NULL) {
rc = mp->fs->stat(mp, abs_path, entry);
if (rc < 0) {
SYS_LOG_ERR("failed get file or dir stat (%d)", rc);
LOG_ERR("failed get file or dir stat (%d)", rc);
}
}
return rc;
@ -385,20 +388,20 @@ int fs_statvfs(const char *abs_path, struct fs_statvfs *stat)
if ((abs_path == NULL) ||
(strlen(abs_path) <= 1) || (abs_path[0] != '/')) {
SYS_LOG_ERR("invalid file name!!");
LOG_ERR("invalid file name!!");
return -EINVAL;
}
rc = fs_get_mnt_point(&mp, abs_path, NULL);
if (rc < 0) {
SYS_LOG_ERR("%s:mount point not found!!", __func__);
LOG_ERR("%s:mount point not found!!", __func__);
return rc;
}
if (mp->fs->statvfs != NULL) {
rc = mp->fs->statvfs(mp, abs_path, stat);
if (rc < 0) {
SYS_LOG_ERR("failed get file or dir stat (%d)", rc);
LOG_ERR("failed get file or dir stat (%d)", rc);
}
}
@ -413,14 +416,14 @@ int fs_mount(struct fs_mount_t *mp)
int rc = -EINVAL;
if ((mp == NULL) || (mp->mnt_point == NULL)) {
SYS_LOG_ERR("mount point not initialized!!");
LOG_ERR("mount point not initialized!!");
return -EINVAL;
}
k_mutex_lock(&mutex, K_FOREVER);
/* Check if requested file system is registered */
if (mp->type >= FS_TYPE_END || fs_map[mp->type] == NULL) {
SYS_LOG_ERR("requested file system not registered!!");
LOG_ERR("requested file system not registered!!");
rc = -ENOENT;
goto mount_err;
}
@ -431,13 +434,13 @@ int fs_mount(struct fs_mount_t *mp)
if ((mp->mnt_point[0] != '/') ||
(strlen(mp->mnt_point) <= 1)) {
SYS_LOG_ERR("invalid mount point!!");
LOG_ERR("invalid mount point!!");
rc = -EINVAL;
goto mount_err;
}
if (fs->mount == NULL) {
SYS_LOG_ERR("fs ops functions not set!!");
LOG_ERR("fs ops functions not set!!");
rc = -EINVAL;
goto mount_err;
}
@ -452,7 +455,7 @@ int fs_mount(struct fs_mount_t *mp)
if (strncmp(mp->mnt_point, itr->mnt_point,
mp->mountp_len) == 0) {
SYS_LOG_ERR("mount Point already exists!!");
LOG_ERR("mount Point already exists!!");
rc = -EBUSY;
goto mount_err;
}
@ -461,7 +464,7 @@ int fs_mount(struct fs_mount_t *mp)
rc = fs->mount(mp);
if (rc < 0) {
SYS_LOG_ERR("fs mount error (%d)", rc);
LOG_ERR("fs mount error (%d)", rc);
goto mount_err;
}
@ -470,7 +473,7 @@ int fs_mount(struct fs_mount_t *mp)
/* append to the mount list */
sys_dlist_append(&fs_mnt_list, &mp->node);
SYS_LOG_DBG("fs mouted, mount point:%s", mp->mnt_point);
LOG_DBG("fs mouted, mount point:%s", mp->mnt_point);
mount_err:
k_mutex_unlock(&mutex);
@ -484,20 +487,20 @@ int fs_unmount(struct fs_mount_t *mp)
if ((mp == NULL) || (mp->mnt_point == NULL) ||
(strlen(mp->mnt_point) <= 1)) {
SYS_LOG_ERR("invalid mount point!!");
LOG_ERR("invalid mount point!!");
return -EINVAL;
}
k_mutex_lock(&mutex, K_FOREVER);
if ((mp->fs == NULL) || mp->fs->unmount == NULL) {
SYS_LOG_ERR("fs ops functions not set!!");
LOG_ERR("fs ops functions not set!!");
rc = -EINVAL;
goto unmount_err;
}
rc = mp->fs->unmount(mp);
if (rc < 0) {
SYS_LOG_ERR("fs unmount error (%d)", rc);
LOG_ERR("fs unmount error (%d)", rc);
goto unmount_err;
}
@ -506,7 +509,7 @@ int fs_unmount(struct fs_mount_t *mp)
/* remove mount node from the list */
sys_dlist_remove(&mp->node);
SYS_LOG_DBG("fs unmouted, mount point:%s", mp->mnt_point);
LOG_DBG("fs unmouted, mount point:%s", mp->mnt_point);
unmount_err:
k_mutex_unlock(&mutex);
@ -520,12 +523,12 @@ int fs_register(enum fs_type type, struct fs_file_system_t *fs)
k_mutex_lock(&mutex, K_FOREVER);
if (type >= FS_TYPE_END) {
SYS_LOG_ERR("failed to register File system!!");
LOG_ERR("failed to register File system!!");
rc = -EINVAL;
goto reg_err;
}
fs_map[type] = fs;
SYS_LOG_DBG("fs registered of type(%u)", type);
LOG_DBG("fs registered of type(%u)", type);
reg_err:
k_mutex_unlock(&mutex);
return rc;
@ -539,12 +542,12 @@ int fs_unregister(enum fs_type type, struct fs_file_system_t *fs)
k_mutex_lock(&mutex, K_FOREVER);
if ((type >= FS_TYPE_END) ||
(fs_map[type] != fs)) {
SYS_LOG_ERR("failed to unregister File system!!");
LOG_ERR("failed to unregister File system!!");
rc = -EINVAL;
goto unreg_err;
}
fs_map[type] = NULL;
SYS_LOG_DBG("fs unregistered of type(%u)", type);
LOG_DBG("fs unregistered of type(%u)", type);
unreg_err:
k_mutex_unlock(&mutex);
return rc;

View file

@ -1,4 +1,5 @@
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_POSIX_API=y

View file

@ -1,4 +1,5 @@
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_DISK_ACCESS_FLASH=y
CONFIG_SPI=y

View file

@ -1,4 +1,5 @@
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_NUM_FILES=8
CONFIG_FS_FATFS_NUM_DIRS=8

View file

@ -1,4 +1,5 @@
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_FILE_SYSTEM_NFFS=y

View file

@ -1,4 +1,5 @@
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_CONSOLE_SHELL=y
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_FAT_FILESYSTEM_ELM=y

View file

@ -8,6 +8,7 @@ CONFIG_SOC_FLASH_NRF_RADIO_SYNC=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
CONFIG_FS_NFFS_NUM_FILES=4

View file

@ -1,6 +1,7 @@
CONFIG_TEST_FLASH_DRIVERS=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="ram_flash_test_drv"
@ -15,3 +16,4 @@ CONFIG_MAIN_STACK_SIZE=1024
CONFIG_NFFS_FILESYSTEM_MAX_AREAS=12
CONFIG_ZTEST_STACKSIZE=2048
CONFIG_ZTEST=y
CONFIG_LOG=y

View file

@ -8,6 +8,7 @@ CONFIG_SOC_FLASH_NRF_RADIO_SYNC=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
CONFIG_FS_NFFS_NUM_FILES=4

View file

@ -1,6 +1,7 @@
CONFIG_TEST_FLASH_DRIVERS=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="ram_flash_test_drv"

View file

@ -8,6 +8,7 @@ CONFIG_SOC_FLASH_NRF_RADIO_SYNC=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
CONFIG_FS_NFFS_NUM_FILES=4

View file

@ -1,6 +1,7 @@
CONFIG_TEST_FLASH_DRIVERS=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="ram_flash_test_drv"

View file

@ -8,6 +8,7 @@ CONFIG_SOC_FLASH_NRF_RADIO_SYNC=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
CONFIG_FS_NFFS_NUM_FILES=4

View file

@ -1,6 +1,7 @@
CONFIG_TEST_FLASH_DRIVERS=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="ram_flash_test_drv"

View file

@ -10,6 +10,7 @@ CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_FILE_SYSTEM=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
CONFIG_FS_NFFS_NUM_FILES=4