diff --git a/include/fs/fs.h b/include/fs/fs.h index 2758f325f9a4..0ed06922a1b8 100644 --- a/include/fs/fs.h +++ b/include/fs/fs.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2016 Intel Corporation. - * Copyright (c) 2020 Nordic Semiconductor ASA + * Copyright (c) 2020-2021 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,24 +8,7 @@ #ifndef ZEPHYR_INCLUDE_FS_FS_H_ #define ZEPHYR_INCLUDE_FS_FS_H_ -#ifdef CONFIG_ARCH_POSIX -#ifndef __ssize_t_defined -typedef __SIZE_TYPE__ ssize_t; -#define __ssize_t_defined -#endif - -#ifndef __off_t_defined -#ifndef __USE_FILE_OFFSET64 -typedef long int off_t; -#else -typedef long long int off_t; -#endif -#define __off_t_defined -#endif - -#else #include -#endif #include #include diff --git a/samples/subsys/fs/littlefs/src/main.c b/samples/subsys/fs/littlefs/src/main.c index c6a9e3842a3a..63838080e8aa 100644 --- a/samples/subsys/fs/littlefs/src/main.c +++ b/samples/subsys/fs/littlefs/src/main.c @@ -14,6 +14,16 @@ #include #include +/* + * FIXME: The Zephyr always overrides uintptr_t as long int, which causes type size mismatch with + * 32bit tools that may define PRIuPTR as "u". + * See: include/toolchain/zephyr_stdint.h. + * The UINTPTR_T_CAST should be replaced with cast to uintptr_t when this thing gets fixed. + */ +#undef PRIuPTR +#define PRIuPTR "lu" +#define UINTPTR_T_CAST(t) ((unsigned long)(t)) + /* Matches LFS_NAME_MAX */ #define MAX_PATH_LEN 255 @@ -73,8 +83,8 @@ void main(void) !(FSTAB_ENTRY_DT_MOUNT_FLAGS(PARTITION_NODE) & FS_MOUNT_FLAG_AUTOMOUNT) rc = fs_mount(mp); if (rc < 0) { - printk("FAIL: mount id %u at %s: %d\n", - (unsigned int)mp->storage_dev, mp->mnt_point, + printk("FAIL: mount id %" PRIuPTR " at %s: %d\n", + UINTPTR_T_CAST(mp->storage_dev), mp->mnt_point, rc); return; } @@ -100,7 +110,7 @@ void main(void) rc = fs_stat(fname, &dirent); printk("%s stat: %d\n", fname, rc); if (rc >= 0) { - printk("\tfn '%s' siz %u\n", dirent.name, dirent.size); + printk("\tfn '%s' size %zu\n", dirent.name, dirent.size); } struct fs_file_t file; @@ -149,7 +159,7 @@ void main(void) printk("End of files\n"); break; } - printk(" %c %u %s\n", + printk(" %c %zu %s\n", (ent.type == FS_DIR_ENTRY_FILE) ? 'F' : 'D', ent.size, ent.name);