mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 06:18:40 +08:00
fs: Change off_t and related types to int64_t if long long is supported
since it is very popular that the storage capcacity is large than 4GB even in the embedded system: https://www.opengroup.org/platform/lfs.html https://en.wikipedia.org/wiki/Large-file_support Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I019dc08aff02f9ea01eb6d750033bbc358994da5
This commit is contained in:
parent
238a96e7de
commit
319474b1b1
18 changed files with 195 additions and 14 deletions
12
fs/Kconfig
12
fs/Kconfig
|
@ -9,6 +9,18 @@ config DISABLE_MOUNTPOINT
|
|||
bool "Disable support for mount points"
|
||||
default n
|
||||
|
||||
config FS_LARGEFILE
|
||||
bool "Large File Support"
|
||||
default !DEFAULT_SMALL
|
||||
---help---
|
||||
Support files which's length is larger than 4GB:
|
||||
https://www.opengroup.org/platform/lfs.html
|
||||
|
||||
Note: the protected and kernel mode on 32bit platform can't exceed
|
||||
the 4GB limitation since the auto generated proxy and stub still
|
||||
cut 64bit to 32bit value. Please check tools/mksyscall.c for more
|
||||
information.
|
||||
|
||||
config FS_AUTOMOUNTER
|
||||
bool "Auto-mounter"
|
||||
default n
|
||||
|
|
|
@ -101,6 +101,18 @@
|
|||
#define LIO_NOWAIT 0
|
||||
#define LIO_WAIT 1
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define aiocb64 aiocb
|
||||
# define aio_read64 aio_read
|
||||
# define aio_write64 aio_write
|
||||
# define aio_error64 aio_error
|
||||
# define aio_return64 aio_return
|
||||
# define aio_cancel64 aio_cancel
|
||||
# define aio_suspend64 aio_suspend
|
||||
# define aio_fsync64 aio_fsync
|
||||
# define lio_listio64 lio_listio
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -86,6 +86,16 @@
|
|||
#define DT_LNK DTYPE_LINK
|
||||
#define DT_SOCK DTYPE_SOCK
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define dirent64 dirent
|
||||
# define readdir64 readdir
|
||||
# define readdir64_r readdir_r
|
||||
# define scandir64 scandir
|
||||
# define alphasort64 alphasort
|
||||
# define versionsort64 versionsort
|
||||
# define getdents64 getdents
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -123,6 +123,20 @@
|
|||
|
||||
#define creat(path, mode) open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define F_GETLK64 F_GETLK
|
||||
# define F_SETLK64 F_SETLK
|
||||
# define F_SETLKW64 F_SETLKW
|
||||
|
||||
# define flock64 flock
|
||||
# define open64 open
|
||||
# define openat64 openat
|
||||
# define creat64 creat
|
||||
# define fallocate64 fallocate
|
||||
# define posix_fadvise64 posix_fadvise
|
||||
# define posix_fallocate64 posix_fallocate
|
||||
#endif
|
||||
|
||||
/********************************************************************************
|
||||
* Public Type Definitions
|
||||
********************************************************************************/
|
||||
|
|
|
@ -63,6 +63,11 @@
|
|||
* it. */
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define ftw64 ftw
|
||||
# define nftw64 nftw
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
|
|
@ -306,6 +306,36 @@
|
|||
#define SCNuMAX "ju"
|
||||
#define SCNxMAX "jx"
|
||||
|
||||
/* off_t */
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
#define PRIdOFF PRId64
|
||||
#define PRIiOFF PRIi64
|
||||
#define PRIoOFF PRIo64
|
||||
#define PRIuOFF PRIu64
|
||||
#define PRIxOFF PRIx64
|
||||
#define PRIXOFF PRIX64
|
||||
|
||||
#define SCNdOFF SCNd64
|
||||
#define SCNiOFF SCNi64
|
||||
#define SCNoOFF SCNo64
|
||||
#define SCNuOFF SCNu64
|
||||
#define SCNxOFF SCNx64
|
||||
#else
|
||||
#define PRIdOFF PRId32
|
||||
#define PRIiOFF PRIi32
|
||||
#define PRIoOFF PRIo32
|
||||
#define PRIuOFF PRIu32
|
||||
#define PRIxOFF PRIx32
|
||||
#define PRIXOFF PRIX32
|
||||
|
||||
#define SCNdOFF SCNd32
|
||||
#define SCNiOFF SCNi32
|
||||
#define SCNoOFF SCNo32
|
||||
#define SCNuOFF SCNu32
|
||||
#define SCNxOFF SCNx32
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -107,8 +107,13 @@ typedef int16_t nuttx_uid_t;
|
|||
typedef uint16_t nuttx_dev_t;
|
||||
typedef uint16_t nuttx_ino_t;
|
||||
typedef uint16_t nuttx_nlink_t;
|
||||
#ifdef CONFIG_FS_LARGEFILE
|
||||
typedef int64_t nuttx_off_t;
|
||||
typedef uint64_t nuttx_blkcnt_t;
|
||||
#else
|
||||
typedef int32_t nuttx_off_t;
|
||||
typedef uint32_t nuttx_blkcnt_t;
|
||||
#endif
|
||||
typedef unsigned int nuttx_mode_t;
|
||||
typedef uintptr_t nuttx_size_t;
|
||||
typedef intptr_t nuttx_ssize_t;
|
||||
|
|
|
@ -86,6 +86,16 @@
|
|||
|
||||
#define TMP_MAX 56800235584ull
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define tmpfile64 tmpfile
|
||||
# define fopen64 fopen
|
||||
# define freopen64 freopen
|
||||
# define fseeko64 fseeko
|
||||
# define ftello64 ftello
|
||||
# define fgetpos64 fgetpos
|
||||
# define fsetpos64 fsetpos
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -66,6 +66,13 @@
|
|||
# define environ get_environ_ptr()
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define mkstemp64 mkstemp
|
||||
# define mkostemp64 mkostemp
|
||||
# define mkstemps64 mkstemps
|
||||
# define mkostemps64 mkostemps
|
||||
#endif
|
||||
|
||||
#define strtof_l(s, e, l) strtof(s, e)
|
||||
#define strtod_l(s, e, l) strtod(s, e)
|
||||
#define strtold_l(s, e, l) strtold(s, e)
|
||||
|
|
|
@ -122,6 +122,10 @@
|
|||
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG (1)
|
||||
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE (2)
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define mmap64 mmap
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -58,6 +58,22 @@
|
|||
#define RLIMIT_STACK 6 /* Limit on stack size */
|
||||
#define RLIMIT_AS 7 /* Limit on address space size */
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define RLIM_INFINITY UINT64_MAX /* No limit */
|
||||
# define RLIM_SAVED_MAX UINT64_MAX /* Unrepresentable saved hard limit */
|
||||
# define RLIM_SAVED_CUR UINT64_MAX /* Unrepresentable saved soft limit */
|
||||
|
||||
# define RLIM64_INFINITY RLIM_INFINITY
|
||||
# define RLIM64_SAVED_MAX RLIM_SAVED_MAX
|
||||
# define RLIM64_SAVED_CUR RLIM_SAVED_CUR
|
||||
|
||||
# define getrlimit64 getrlimit
|
||||
# define setrlimit64 setrlimit
|
||||
# define prlimit64 prlimit
|
||||
|
||||
# define rlimit64 rlimit
|
||||
# define rlim64_t rlim_t
|
||||
#else
|
||||
/* The following symbolic constants are defined. Each is a value of type
|
||||
* rlim_t.
|
||||
*
|
||||
|
@ -66,9 +82,10 @@
|
|||
* distinct from RLIM_INFINITY.
|
||||
*/
|
||||
|
||||
#define RLIM_INFINITY UINT32_MAX /* No limit */
|
||||
#define RLIM_SAVED_MAX UINT32_MAX /* Unrepresentable saved hard limit */
|
||||
#define RLIM_SAVED_CUR UINT32_MAX /* Unrepresentable saved soft limit */
|
||||
# define RLIM_INFINITY UINT32_MAX /* No limit */
|
||||
# define RLIM_SAVED_MAX UINT32_MAX /* Unrepresentable saved hard limit */
|
||||
# define RLIM_SAVED_CUR UINT32_MAX /* Unrepresentable saved soft limit */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
|
@ -78,7 +95,11 @@
|
|||
* It must be an unsigned integral type.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
typedef uint64_t rlim_t;
|
||||
#else
|
||||
typedef uint32_t rlim_t;
|
||||
#endif
|
||||
|
||||
/* Minimal, compliant rlimit structure */
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
# define CONFIG_SENDFILE_BUFSIZE 512
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define sendfile64 sendfile
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -122,6 +122,13 @@
|
|||
#define st_ctime st_ctim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define stat64 stat
|
||||
# define fstat64 fstat
|
||||
# define lstat64 lstat
|
||||
# define fstatat64 fstatat
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
#define USERFS_MAGIC 0x52455355
|
||||
#define CROMFS_MAGIC 0x4d4f5243
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define statfs64 statfs
|
||||
# define fstatfs64 fstatfs
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
#define ST_RDONLY 0x0001 /* Mount read-only. */
|
||||
#define ST_NOSUID 0x0002 /* Ignore suid and sgid bits. */
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define statvfs64 statvfs
|
||||
# define fstatvfs64 fstatvfs
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -73,6 +73,14 @@
|
|||
#define SCHED_PRIORITY_MIN 1
|
||||
#define SCHED_PRIORITY_IDLE 0
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define fsblkcnt64_t fsblkcnt_t
|
||||
# define fsfilcnt64_t fsfilcnt_t
|
||||
# define blkcnt64_t blkcnt_t
|
||||
# define off64_t off_t
|
||||
# define fpos64_t fpos_t
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Type Declarations
|
||||
****************************************************************************/
|
||||
|
@ -175,6 +183,16 @@ typedef int wint_t;
|
|||
|
||||
typedef int wctype_t;
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
/* Large file versions */
|
||||
|
||||
typedef uint64_t fsblkcnt_t;
|
||||
typedef uint64_t fsfilcnt_t;
|
||||
|
||||
typedef uint64_t blkcnt_t;
|
||||
typedef int64_t off_t;
|
||||
typedef int64_t fpos_t;
|
||||
#else
|
||||
/* fsblkcnt_t and fsfilcnt_t shall be defined as unsigned integer types. */
|
||||
|
||||
typedef uint32_t fsblkcnt_t;
|
||||
|
@ -191,13 +209,7 @@ typedef uint32_t fsfilcnt_t;
|
|||
|
||||
typedef uint32_t blkcnt_t;
|
||||
typedef int32_t off_t;
|
||||
typedef off_t fpos_t;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
/* Large file versions */
|
||||
|
||||
typedef int64_t off64_t;
|
||||
typedef int64_t fpos64_t;
|
||||
typedef int32_t fpos_t;
|
||||
#endif
|
||||
|
||||
/* blksize_t is a signed integer value used for file block sizes */
|
||||
|
|
|
@ -44,6 +44,15 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define preadv64 preadv
|
||||
# define pwritev64 pwritev
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
|
|
@ -267,10 +267,19 @@
|
|||
|
||||
/* Accessor functions associated with getopt(). */
|
||||
|
||||
#define optarg (*(getoptargp()))
|
||||
#define opterr (*(getopterrp()))
|
||||
#define optind (*(getoptindp()))
|
||||
#define optopt (*(getoptoptp()))
|
||||
#define optarg (*(getoptargp()))
|
||||
#define opterr (*(getopterrp()))
|
||||
#define optind (*(getoptindp()))
|
||||
#define optopt (*(getoptoptp()))
|
||||
|
||||
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
|
||||
# define lseek64 lseek
|
||||
# define pread64 pread
|
||||
# define pwrite64 pwrite
|
||||
# define truncate64 truncate
|
||||
# define ftruncate64 ftruncate
|
||||
# define lockf64 lockf
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
|
Loading…
Reference in a new issue