summaryrefslogtreecommitdiff
path: root/components/dfs/include
diff options
context:
space:
mode:
Diffstat (limited to 'components/dfs/include')
-rw-r--r--components/dfs/include/dfs.h20
-rw-r--r--components/dfs/include/dfs_file.h23
-rw-r--r--components/dfs/include/dfs_fs.h30
-rw-r--r--components/dfs/include/dfs_poll.h19
-rw-r--r--components/dfs/include/dfs_posix.h25
-rw-r--r--components/dfs/include/dfs_private.h15
-rw-r--r--components/dfs/include/dfs_select.h9
7 files changed, 60 insertions, 81 deletions
diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h
index f17458bd69..eb32a4b411 100644
--- a/components/dfs/include/dfs.h
+++ b/components/dfs/include/dfs.h
@@ -1,21 +1,7 @@
/*
- * File : dfs.h
- * This file is part of Device File System in RT-Thread RTOS
- * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -116,7 +102,7 @@ struct dfs_fd *fd_get(int fd);
void fd_put(struct dfs_fd *fd);
int fd_is_open(const char *pathname);
-struct dfs_fdtable* dfs_fdtable_get(void);
+struct dfs_fdtable *dfs_fdtable_get(void);
#ifdef __cplusplus
}
diff --git a/components/dfs/include/dfs_file.h b/components/dfs/include/dfs_file.h
index 5dc3946899..2dfacd653e 100644
--- a/components/dfs/include/dfs_file.h
+++ b/components/dfs/include/dfs_file.h
@@ -1,21 +1,7 @@
/*
- * File : dfs_file.h
- * This file is part of Device File System in RT-Thread RTOS
- * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -58,6 +44,7 @@ struct dfs_fd
char *path; /* Name (below mount point) */
int ref_count; /* Descriptor reference count */
+ struct dfs_filesystem *fs;
const struct dfs_file_ops *fops;
uint32_t flags; /* Descriptor flags */
@@ -79,6 +66,10 @@ int dfs_file_lseek(struct dfs_fd *fd, off_t offset);
int dfs_file_stat(const char *path, struct stat *buf);
int dfs_file_rename(const char *oldpath, const char *newpath);
+int dfs_file_ftruncate(struct dfs_fd *fd, off_t length);
+
+/* 0x5254 is just a magic number to make these relatively unique ("RT") */
+#define RT_FIOFTRUNCATE 0x52540000U
#ifdef __cplusplus
}
diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h
index 38d8766ee1..a35a513044 100644
--- a/components/dfs/include/dfs_fs.h
+++ b/components/dfs/include/dfs_fs.h
@@ -1,27 +1,13 @@
/*
- * File : dfs_fs.h
- * This file is part of Device File System in RT-Thread RTOS
- * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2005-02-22 Bernard The first version.
*/
-
+
#ifndef __DFS_FS_H__
#define __DFS_FS_H__
@@ -74,7 +60,7 @@ struct dfs_partition
uint8_t type; /* file system type */
off_t offset; /* partition start offset */
size_t size; /* partition size */
- rt_sem_t lock;
+ rt_sem_t lock;
};
/* mount table */
@@ -89,11 +75,11 @@ struct dfs_mount_tbl
int dfs_register(const struct dfs_filesystem_ops *ops);
struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
-const char* dfs_filesystem_get_mounted_path(struct rt_device* device);
+const char *dfs_filesystem_get_mounted_path(struct rt_device *device);
int dfs_filesystem_get_partition(struct dfs_partition *part,
- uint8_t *buf,
- uint32_t pindex);
+ uint8_t *buf,
+ uint32_t pindex);
int dfs_mount(const char *device_name,
const char *path,
@@ -104,6 +90,8 @@ int dfs_unmount(const char *specialfile);
int dfs_mkfs(const char *fs_name, const char *device_name);
int dfs_statfs(const char *path, struct statfs *buffer);
+int dfs_mount_device(rt_device_t dev);
+int dfs_unmount_device(rt_device_t dev);
#ifdef __cplusplus
}
diff --git a/components/dfs/include/dfs_poll.h b/components/dfs/include/dfs_poll.h
index cfdf74fbe4..d9597a4364 100644
--- a/components/dfs/include/dfs_poll.h
+++ b/components/dfs/include/dfs_poll.h
@@ -1,3 +1,12 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
#ifndef DFS_POLL_H__
#define DFS_POLL_H__
@@ -6,6 +15,7 @@
#ifdef RT_USING_POSIX
#include <sys/time.h> /* for struct timeval */
+#if !defined(POLLIN) && !defined(POLLOUT)
#define POLLIN (0x01)
#define POLLRDNORM (0x01)
#define POLLRDBAND (0x01)
@@ -19,8 +29,6 @@
#define POLLHUP (0x08)
#define POLLNVAL (0x10)
-#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
-
typedef unsigned int nfds_t;
struct pollfd
@@ -29,9 +37,10 @@ struct pollfd
short events;
short revents;
};
+#endif /* !defined(POLLIN) && !defined(POLLOUT) */
+#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
-#endif
-
-#endif
+#endif /* RT_USING_POSIX */
+#endif /* DFS_POLL_H__ */
diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h
index b751f1ed17..87d5f0771e 100644
--- a/components/dfs/include/dfs_posix.h
+++ b/components/dfs/include/dfs_posix.h
@@ -1,21 +1,7 @@
/*
- * File : dfs_posix.h
- * This file is part of Device File System in RT-Thread RTOS
- * COPYRIGHT (C) 2004-2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -50,18 +36,20 @@ struct dirent *readdir(DIR *d);
long telldir(DIR *d);
void seekdir(DIR *d, off_t offset);
void rewinddir(DIR *d);
-int closedir(DIR* d);
+int closedir(DIR *d);
/* file api*/
int open(const char *file, int flags, ...);
int close(int d);
-#ifdef RT_USING_NEWLIB
+
+#if defined(RT_USING_NEWLIB) && defined(_EXFUN)
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte));
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte));
#else
int read(int fd, void *buf, size_t len);
int write(int fd, const void *buf, size_t len);
#endif
+
off_t lseek(int fd, off_t offset, int whence);
int rename(const char *from, const char *to);
int unlink(const char *pathname);
@@ -70,6 +58,7 @@ int fstat(int fildes, struct stat *buf);
int fsync(int fildes);
int fcntl(int fildes, int cmd, ...);
int ioctl(int fildes, int cmd, ...);
+int ftruncate(int fd, off_t length);
/* directory api*/
int rmdir(const char *path);
diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h
index 43be0db00e..fccd260ac0 100644
--- a/components/dfs/include/dfs_private.h
+++ b/components/dfs/include/dfs_private.h
@@ -1,12 +1,19 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
#ifndef DFS_PRIVATE_H__
#define DFS_PRIVATE_H__
#include <dfs.h>
-// #define DBG_ENABLE
-#define DBG_SECTION_NAME "DFS"
-#define DBG_COLOR
-#define DBG_LEVEL DBG_LOG
+#define DBG_TAG "DFS"
+#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define NO_WORKING_DIR "system does not support working directory\n"
diff --git a/components/dfs/include/dfs_select.h b/components/dfs/include/dfs_select.h
index 1c51b1df38..3ac5817874 100644
--- a/components/dfs/include/dfs_select.h
+++ b/components/dfs/include/dfs_select.h
@@ -1,3 +1,12 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
#ifndef DFS_SELECT_H__
#define DFS_SELECT_H__