diff --git a/fs/Kconfig b/fs/Kconfig index 2dc71bf90a3..240f712b201 100644 --- a/fs/Kconfig +++ b/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 diff --git a/include/aio.h b/include/aio.h index a1455dd19d8..768a08198b0 100644 --- a/include/aio.h +++ b/include/aio.h @@ -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 ****************************************************************************/ diff --git a/include/dirent.h b/include/dirent.h index a1f2886de60..7a1ed7180f7 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -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 ****************************************************************************/ diff --git a/include/fcntl.h b/include/fcntl.h index e17f69ffb36..2b1de821292 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -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 ********************************************************************************/ diff --git a/include/ftw.h b/include/ftw.h index ae02bcaff74..5a184cbd33e 100644 --- a/include/ftw.h +++ b/include/ftw.h @@ -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 ****************************************************************************/ diff --git a/include/inttypes.h b/include/inttypes.h index e9666e14013..7d15a1f3903 100644 --- a/include/inttypes.h +++ b/include/inttypes.h @@ -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 ****************************************************************************/ diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h index df22e36b5b1..bf009ed6c9e 100644 --- a/include/nuttx/fs/hostfs.h +++ b/include/nuttx/fs/hostfs.h @@ -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; diff --git a/include/stdio.h b/include/stdio.h index 9db74589c80..a2a7e00713a 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -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 ****************************************************************************/ diff --git a/include/stdlib.h b/include/stdlib.h index 93ac5fd845a..d3454a05305 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -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) diff --git a/include/sys/mman.h b/include/sys/mman.h index 8989c9220c5..769671d9e86 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -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 ****************************************************************************/ diff --git a/include/sys/resource.h b/include/sys/resource.h index 4ebf2db9bf8..0b3478301da 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -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 */ diff --git a/include/sys/sendfile.h b/include/sys/sendfile.h index cb583a9031a..c07b944cb45 100644 --- a/include/sys/sendfile.h +++ b/include/sys/sendfile.h @@ -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 ****************************************************************************/ diff --git a/include/sys/stat.h b/include/sys/stat.h index 8c1496bf485..bb1fae04206 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -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 ****************************************************************************/ diff --git a/include/sys/statfs.h b/include/sys/statfs.h index 0817e310c02..6cbd2543f77 100644 --- a/include/sys/statfs.h +++ b/include/sys/statfs.h @@ -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 ****************************************************************************/ diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h index a6cd2f456ad..57870828798 100644 --- a/include/sys/statvfs.h +++ b/include/sys/statvfs.h @@ -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 ****************************************************************************/ diff --git a/include/sys/types.h b/include/sys/types.h index 0ad7fe78174..f1f655de7ed 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -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 */ diff --git a/include/sys/uio.h b/include/sys/uio.h index a7ce94cd520..551cc5c26e0 100644 --- a/include/sys/uio.h +++ b/include/sys/uio.h @@ -44,6 +44,15 @@ #include +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG) +# define preadv64 preadv +# define pwritev64 pwritev +#endif + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/include/unistd.h b/include/unistd.h index dacc57e6b8c..41a5213a7da 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -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