mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 11:30:01 +08:00
[libc] fix the fcntl issue in newlib
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
* 2010-07-18 Bernard add stat and statfs structure definitions.
|
||||
* 2011-05-16 Yi.qiu Change parameter name of rename, "new" is C++ key word.
|
||||
* 2017-12-27 Bernard Add fcntl API.
|
||||
* 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
|
||||
*/
|
||||
|
||||
#ifndef __DFS_POSIX_H__
|
||||
@@ -52,7 +53,7 @@ void rewinddir(DIR *d);
|
||||
int closedir(DIR* d);
|
||||
|
||||
/* file api*/
|
||||
int open(const char *file, int flags, int mode);
|
||||
int open(const char *file, int flags, ...);
|
||||
int close(int d);
|
||||
#ifdef RT_USING_NEWLIB
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
|
||||
@@ -67,8 +68,8 @@ int unlink(const char *pathname);
|
||||
int stat(const char *file, struct stat *buf);
|
||||
int fstat(int fildes, struct stat *buf);
|
||||
int fsync(int fildes);
|
||||
int fcntl(int fildes, int cmd, void *data);
|
||||
int ioctl(int fildes, int cmd, void *data);
|
||||
int fcntl(int fildes, int cmd, ...);
|
||||
int ioctl(int fildes, int cmd, ...);
|
||||
|
||||
/* directory api*/
|
||||
int rmdir(const char *path);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-05-27 Yi.qiu The first version
|
||||
* 2018-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
|
||||
*/
|
||||
|
||||
#include <dfs.h>
|
||||
@@ -38,11 +39,10 @@
|
||||
*
|
||||
* @param file the path name of file.
|
||||
* @param flags the file open flags.
|
||||
* @param mode ignored parameter
|
||||
*
|
||||
* @return the non-negative integer on successful open, others for failed.
|
||||
*/
|
||||
int open(const char *file, int flags, int mode)
|
||||
int open(const char *file, int flags, ...)
|
||||
{
|
||||
int fd, result;
|
||||
struct dfs_fd *d;
|
||||
@@ -428,7 +428,7 @@ RTM_EXPORT(fsync);
|
||||
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
|
||||
* set to indicate the error.
|
||||
*/
|
||||
int fcntl(int fildes, int cmd, void *data)
|
||||
int fcntl(int fildes, int cmd, ...)
|
||||
{
|
||||
int ret = -1;
|
||||
struct dfs_fd *d;
|
||||
@@ -437,7 +437,14 @@ int fcntl(int fildes, int cmd, void *data)
|
||||
d = fd_get(fildes);
|
||||
if (d)
|
||||
{
|
||||
ret = dfs_file_ioctl(d, cmd, data);
|
||||
void* arg;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, cmd);
|
||||
arg = va_arg(ap, void*);
|
||||
va_end(ap);
|
||||
|
||||
ret = dfs_file_ioctl(d, cmd, arg);
|
||||
fd_put(d);
|
||||
}
|
||||
else ret = -EBADF;
|
||||
@@ -464,10 +471,17 @@ RTM_EXPORT(fcntl);
|
||||
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
|
||||
* set to indicate the error.
|
||||
*/
|
||||
int ioctl(int fildes, int cmd, void *data)
|
||||
int ioctl(int fildes, int cmd, ...)
|
||||
{
|
||||
void* arg;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, cmd);
|
||||
arg = va_arg(ap, void*);
|
||||
va_end(ap);
|
||||
|
||||
/* we use fcntl for this API. */
|
||||
return fcntl(fildes, cmd, data);
|
||||
return fcntl(fildes, cmd, arg);
|
||||
}
|
||||
RTM_EXPORT(ioctl);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user