mirror of
https://github.com/openharmony/third_party_NuttX.git
synced 2026-07-01 08:17:34 -04:00
fix: remove redundant headfile
1.remove redundant headfile in kernel, such as: compiler.h;debug.h;automount.h;inode.h;syslog.h;net.h; 2.split fs.h to file.h and driver.h 3.move vnode.h and path_cache.h to vfs/include 4.remove redundant interface and defines close: #I3RTNR Signed-off-by: mucor <mucorwang@gmail.com>
This commit is contained in:
@@ -47,7 +47,6 @@
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "bch.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "bch.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -55,10 +54,10 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int bchdev_register(FAR const char *blkdev, FAR const char *chardev,
|
||||
int bchdev_register(const char *blkdev, const char *chardev,
|
||||
bool readonly)
|
||||
{
|
||||
FAR void *handle;
|
||||
void *handle;
|
||||
int ret;
|
||||
|
||||
/* Setup the BCH lib functions */
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "bch.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
#define _err PRINTK
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int bchdev_unregister(FAR const char *chardev)
|
||||
int bchdev_unregister(const char *chardev)
|
||||
{
|
||||
FAR struct bchlib_s *bch;
|
||||
struct bchlib_s *bch;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "bch.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -62,7 +61,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int bchlib_flushsector(FAR struct bchlib_s *bch)
|
||||
int bchlib_flushsector(struct bchlib_s *bch)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
@@ -74,7 +73,7 @@ int bchlib_flushsector(FAR struct bchlib_s *bch)
|
||||
{
|
||||
/* Write the sector to the media */
|
||||
|
||||
ret = los_disk_write(bch->disk->disk_id, (FAR const void *)bch->buffer, bch->sector, 1);
|
||||
ret = los_disk_write(bch->disk->disk_id, (const void *)bch->buffer, bch->sector, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
PRINTK("bchlib_flushsector Write failed: %d\n", ret);
|
||||
@@ -100,7 +99,7 @@ int bchlib_flushsector(FAR struct bchlib_s *bch)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int bchlib_readsector(FAR struct bchlib_s *bch, unsigned long long sector)
|
||||
int bchlib_readsector(struct bchlib_s *bch, unsigned long long sector)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
@@ -114,7 +113,7 @@ int bchlib_readsector(FAR struct bchlib_s *bch, unsigned long long sector)
|
||||
|
||||
bch->sector = (unsigned long long)-1;
|
||||
/* useRead is set TRUE, it'll use read block for not reading large data */
|
||||
ret = los_disk_read(bch->disk->disk_id, (FAR void *)bch->buffer, sector, 1, TRUE);
|
||||
ret = los_disk_read(bch->disk->disk_id, (void *)bch->buffer, sector, 1, TRUE);
|
||||
if (ret < 0)
|
||||
{
|
||||
PRINTK("Read failed: %d\n", ret);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "bch.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -74,9 +73,9 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t bchlib_read(FAR void *handle, FAR char *buffer, loff_t offset, size_t len)
|
||||
ssize_t bchlib_read(void *handle, char *buffer, loff_t offset, size_t len)
|
||||
{
|
||||
FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle;
|
||||
struct bchlib_s *bch = (struct bchlib_s *)handle;
|
||||
size_t nsectors;
|
||||
unsigned long long sector;
|
||||
uint16_t sectoffset;
|
||||
@@ -160,7 +159,7 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, loff_t offset, size_t le
|
||||
nsectors = bch->nsectors - sector;
|
||||
}
|
||||
/* No need for reading large contiguous data, useRead(param 4) is set TRUE */
|
||||
ret = los_disk_read(bch->disk->disk_id, (FAR void *)buffer, sector + bch->sectstart, nsectors, TRUE);
|
||||
ret = los_disk_read(bch->disk->disk_id, (void *)buffer, sector + bch->sectstart, nsectors, TRUE);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
****************************************************************************/
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <semaphore.h>
|
||||
#include "bch.h"
|
||||
|
||||
@@ -50,7 +49,7 @@
|
||||
* Name: bch_semtake
|
||||
****************************************************************************/
|
||||
|
||||
void bchlib_semtake(FAR struct bchlib_s *bch)
|
||||
void bchlib_semtake(struct bchlib_s *bch)
|
||||
{
|
||||
while (sem_wait(&bch->sem) != 0)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <securec.h>
|
||||
#include "bch.h"
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "fs/fs.h"
|
||||
#include "bch.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "bch.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -58,9 +57,9 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, loff_t offset, size_t len)
|
||||
ssize_t bchlib_write(void *handle, const char *buffer, loff_t offset, size_t len)
|
||||
{
|
||||
FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle;
|
||||
struct bchlib_s *bch = (struct bchlib_s *)handle;
|
||||
size_t nsectors;
|
||||
unsigned long long sector;
|
||||
uint16_t sectoffset;
|
||||
@@ -145,7 +144,7 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, loff_t offset, si
|
||||
|
||||
/* Write the contiguous sectors */
|
||||
|
||||
ret = los_disk_write(bch->disk->disk_id, (FAR const void *)buffer,
|
||||
ret = los_disk_write(bch->disk->disk_id, (const void *)buffer,
|
||||
sector + bch->sectstart, nsectors);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
@@ -40,9 +40,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <fs/fs.h>
|
||||
|
||||
#include <fs/driver.h>
|
||||
#include "pipe_common.h"
|
||||
|
||||
#if CONFIG_DEV_FIFO_SIZE > 0
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/driver.h"
|
||||
#include "los_init.h"
|
||||
|
||||
#if CONFIG_DEV_PIPE_SIZE > 0
|
||||
|
||||
@@ -49,25 +49,20 @@
|
||||
#include <semaphore.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <poll.h>
|
||||
#include "linux/wait.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs_poll_pri.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
# include <nuttx/arch.h>
|
||||
#endif
|
||||
#include <semaphore.h>
|
||||
#include <fs/fs.h>
|
||||
#include <fs/driver.h>
|
||||
#include "pipe_common.h"
|
||||
#include "los_printf.h"
|
||||
#include "user_copy.h"
|
||||
#ifdef LOSCFG_KERNEL_PIPE
|
||||
|
||||
#include "fs/vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
@@ -154,14 +153,14 @@ extern "C"
|
||||
struct file; /* Forward reference */
|
||||
struct inode; /* Forward reference */
|
||||
|
||||
FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize, const char *name);
|
||||
void pipecommon_freedev(FAR struct pipe_dev_s *dev);
|
||||
int pipecommon_open(FAR struct file *filep);
|
||||
int pipecommon_close(FAR struct file *filep);
|
||||
ssize_t pipecommon_read(FAR struct file *, FAR char *, size_t);
|
||||
ssize_t pipecommon_write(FAR struct file *, FAR const char *, size_t);
|
||||
int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
int pipecommon_poll(FAR struct file *filep, poll_table *fds);
|
||||
struct pipe_dev_s *pipecommon_allocdev(size_t bufsize, const char *name);
|
||||
void pipecommon_freedev(struct pipe_dev_s *dev);
|
||||
int pipecommon_open(struct file *filep);
|
||||
int pipecommon_close(struct file *filep);
|
||||
ssize_t pipecommon_read(struct file *, char *, size_t);
|
||||
ssize_t pipecommon_write(struct file *, const char *, size_t);
|
||||
int pipecommon_ioctl(struct file *filep, int cmd, unsigned long arg);
|
||||
int pipecommon_poll(struct file *filep, poll_table *fds);
|
||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||
int pipecommon_unlink(struct Vnode *vnode);
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "fb.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "user_copy.h"
|
||||
|
||||
@@ -41,9 +41,8 @@
|
||||
#include "dirent.h"
|
||||
#include "errno.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -44,10 +44,9 @@
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "vnode.h"
|
||||
#include "path_cache.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -43,9 +43,10 @@
|
||||
#include "dirent.h"
|
||||
#include "errno.h"
|
||||
#include "unistd.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "user_copy.h"
|
||||
#include "fs/file.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Name: do_readdir
|
||||
|
||||
@@ -40,9 +40,8 @@
|
||||
#include "vfs_config.h"
|
||||
#include "dirent.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -41,9 +41,8 @@
|
||||
#include "sys/types.h"
|
||||
#include "dirent.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "dirent.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/dirent_fs.h"
|
||||
|
||||
|
||||
@@ -70,7 +69,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
long telldir(FAR DIR *dirp)
|
||||
long telldir(DIR *dirp)
|
||||
{
|
||||
struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
|
||||
|
||||
|
||||
@@ -47,12 +47,9 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
#include "blockproxy.h"
|
||||
|
||||
#include "driver/blockproxy.h"
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||
#ifdef LOSCFG_FS_VFS_BLOCK_DEVICE
|
||||
|
||||
/****************************************************************************
|
||||
@@ -167,7 +164,7 @@ static char *unique_chardev(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int block_proxy(FAR const char *blkdev, int oflags)
|
||||
int block_proxy(const char *blkdev, int oflags)
|
||||
{
|
||||
struct file *filep = NULL;
|
||||
struct Vnode *vnode = NULL;
|
||||
@@ -248,4 +245,3 @@ errout_with_chardev:
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT */
|
||||
|
||||
@@ -37,11 +37,10 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
#include "vfs_config.h"
|
||||
#include "debug.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "disk.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "fcntl.h"
|
||||
#include "semaphore.h"
|
||||
#include "assert.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
#include "inode/inode.h"
|
||||
|
||||
#if defined(CONFIG_SYSLOG) && defined(CONFIG_SYSLOG_CHAR)
|
||||
@@ -184,9 +184,9 @@ static inline void syslog_givesem(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline ssize_t syslog_write(FAR const void *buf, size_t nbytes)
|
||||
static inline ssize_t syslog_write(const void *buf, size_t nbytes)
|
||||
{
|
||||
FAR struct inode *inode_ptr;
|
||||
struct inode *inode_ptr;
|
||||
|
||||
/* Let the driver perform the write */
|
||||
|
||||
@@ -205,7 +205,7 @@ static inline ssize_t syslog_write(FAR const void *buf, size_t nbytes)
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
static inline void syslog_flush(void)
|
||||
{
|
||||
FAR struct inode *inode_ptr = g_sysdev.sl_file.f_inode;
|
||||
struct inode *inode_ptr = g_sysdev.sl_file.f_inode;
|
||||
|
||||
/* Is this a mountpoint? Does it support the sync method? */
|
||||
|
||||
@@ -236,8 +236,8 @@ static inline void syslog_flush(void)
|
||||
|
||||
int syslog_initialize(void)
|
||||
{
|
||||
FAR struct inode *inode_ptr;
|
||||
FAR const char *relpath = NULL;
|
||||
struct inode *inode_ptr;
|
||||
const char *relpath = NULL;
|
||||
int ret;
|
||||
struct inode_search_s desc;
|
||||
|
||||
|
||||
@@ -39,12 +39,10 @@
|
||||
|
||||
#include "vfs_config.h"
|
||||
|
||||
#include "driver/driver.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/mount.h"
|
||||
#include "debug.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
#include "string.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -91,7 +89,7 @@ int find_blockdriver(const char *pathname, int mountflags, struct Vnode **vpp)
|
||||
/* Verify that the vnode is a block driver. */
|
||||
if (vp->type != VNODE_TYPE_BLK)
|
||||
{
|
||||
fdbg("%s is not a block driver\n", pathname);
|
||||
PRINT_DEBUG("%s is not a block driver\n", pathname);
|
||||
ret = -ENOTBLK;
|
||||
goto errout;
|
||||
}
|
||||
@@ -102,7 +100,7 @@ int find_blockdriver(const char *pathname, int mountflags, struct Vnode **vpp)
|
||||
|
||||
if (i_bops == NULL || i_bops->read == NULL || (i_bops->write == NULL && (mountflags & MS_RDONLY) == 0))
|
||||
{
|
||||
fdbg("%s does not support requested access\n", pathname);
|
||||
PRINT_DEBUG("%s does not support requested access\n", pathname);
|
||||
ret = -EACCES;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@@ -38,11 +38,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "vfs_config.h"
|
||||
#include "debug.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "driver/driver.h"
|
||||
#include "fs/driver.h"
|
||||
#include "vnode.h"
|
||||
#include "disk.h"
|
||||
#include <linux/kernel.h>
|
||||
|
||||
@@ -101,7 +99,7 @@ int open_blockdriver(const char *pathname, int mountflags,
|
||||
ret = find_blockdriver(pathname, mountflags, &vnode_ptr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("Failed to file %s block driver\n", pathname);
|
||||
PRINT_DEBUG("Failed to file %s block driver\n", pathname);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@@ -136,7 +134,7 @@ int open_blockdriver(const char *pathname, int mountflags,
|
||||
ret = ops->open(vnode_ptr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("%s driver open failed\n", pathname);
|
||||
PRINT_DEBUG("%s driver open failed\n", pathname);
|
||||
(void)pthread_mutex_unlock(&disk->disk_mutex);
|
||||
goto errout_with_vnode;
|
||||
}
|
||||
@@ -157,7 +155,7 @@ int open_blockdriver(const char *pathname, int mountflags,
|
||||
ret = ops->open(vnode_ptr);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("%s driver open failed\n", pathname);
|
||||
PRINT_DEBUG("%s driver open failed\n", pathname);
|
||||
goto errout_with_vnode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,17 +40,13 @@
|
||||
#include "vfs_config.h"
|
||||
#include "sys/types.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/driver.h"
|
||||
#include "vnode.h"
|
||||
#include "string.h"
|
||||
#include "fs/vfs_util.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "path_cache.h"
|
||||
#include "vnode.h"
|
||||
#include "limits.h"
|
||||
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -103,7 +99,7 @@ int register_blockdriver(const char *path,
|
||||
data->priv = priv;
|
||||
|
||||
VnodeHold();
|
||||
ret = VnodeLookup(path, &vp, V_CREATE | V_CACHE | V_DUMMY);
|
||||
ret = VnodeLookup(path, &vp, V_CREATE | V_DUMMY);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* We have it, now populate it with block driver specific information. */
|
||||
@@ -116,5 +112,3 @@ int register_blockdriver(const char *path,
|
||||
VnodeDrop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_DISABLE_MOUNTPOINT */
|
||||
|
||||
@@ -40,11 +40,10 @@
|
||||
#include "vfs_config.h"
|
||||
#include "sys/types.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/driver.h"
|
||||
#include "vnode.h"
|
||||
#include "string.h"
|
||||
#include "fs/vfs_util.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "path_cache.h"
|
||||
#include "limits.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -103,7 +102,7 @@ int register_driver(const char *path, const struct file_operations_vfs *fops,
|
||||
data->mode = mode;
|
||||
data->priv = priv;
|
||||
|
||||
ret = VnodeLookup(path, &vnode, V_CREATE | V_CACHE | V_DUMMY);
|
||||
ret = VnodeLookup(path, &vnode, V_CREATE | V_DUMMY);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* We have it, now populate it with driver specific information.
|
||||
|
||||
@@ -39,9 +39,8 @@
|
||||
|
||||
#include "vfs_config.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
#include "inode/inode.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "vfs_config.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/driver.h"
|
||||
#include "vnode.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
|
||||
@@ -64,7 +64,7 @@ int unregister_driver(const char *path)
|
||||
return -EINVAL;
|
||||
}
|
||||
VnodeHold();
|
||||
ret = VnodeLookup(path, &vnode, V_CACHE | V_DUMMY);
|
||||
ret = VnodeLookup(path, &vnode, V_DUMMY);
|
||||
if (ret != OK)
|
||||
{
|
||||
VnodeDrop();
|
||||
@@ -75,7 +75,7 @@ int unregister_driver(const char *path)
|
||||
VnodeDrop();
|
||||
return -EPERM;
|
||||
}
|
||||
ret = VnodeDestory(vnode);
|
||||
ret = VnodeFree(vnode);
|
||||
VnodeDrop();
|
||||
|
||||
return ret;
|
||||
|
||||
+2
-10
@@ -45,17 +45,15 @@
|
||||
#include "semaphore.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "los_mux.h"
|
||||
#include "fs/fd_table.h"
|
||||
#ifdef LOSCFG_NET_LWIP_SACK
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
#include "fs_file.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_vm_filemap.h"
|
||||
#include "mqueue.h"
|
||||
@@ -65,10 +63,6 @@
|
||||
struct filelist tg_filelist;
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
struct streamlist tg_streamlist;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -372,7 +366,6 @@ int file_dup2(struct file *filep1, struct file *filep2)
|
||||
|
||||
if (vnode_ptr->vop)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
if (vnode_ptr->originMount)
|
||||
{
|
||||
/* Dup the open file on the in the new file structure */
|
||||
@@ -383,7 +376,6 @@ int file_dup2(struct file *filep1, struct file *filep2)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* (Re-)open the pseudo file or device driver */
|
||||
|
||||
@@ -701,7 +693,7 @@ void files_refer(int fd)
|
||||
{
|
||||
struct file *filep = NULL;
|
||||
|
||||
FAR struct filelist *list = sched_getfiles();
|
||||
struct filelist *list = sched_getfiles();
|
||||
if (!list || fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "string.h"
|
||||
#include "inode/inode.h"
|
||||
#include "capability_api.h"
|
||||
#include "fs_other.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "stdlib.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#include "fs_other.h"
|
||||
#include "inode/inode.h"
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
||||
@@ -1,437 +0,0 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/inode.h
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2012, 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __FS_INODE_H
|
||||
#define __FS_INODE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "vfs_config.h"
|
||||
#include "sys/types.h"
|
||||
#include "dirent.h"
|
||||
#include "limits.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/fs_operation.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define DEV_PATH_LEN 5
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Inode i_flag values */
|
||||
|
||||
#define FSNODEFLAG_TYPE_MASK 0x00000007 /* Isolates type field */
|
||||
#define FSNODEFLAG_TYPE_DRIVER 0x00000000 /* Character driver */
|
||||
#define FSNODEFLAG_TYPE_BLOCK 0x00000001 /* Block driver */
|
||||
#define FSNODEFLAG_TYPE_MOUNTPT 0x00000002 /* Mount point */
|
||||
#define FSNODEFLAG_TYPE_SPECIAL 0x00000004 /* Special OS type */
|
||||
#define FSNODEFLAG_TYPE_NAMEDSEM 0x00000004 /* Named semaphore */
|
||||
#define FSNODEFLAG_TYPE_MQUEUE 0x00000005 /* Message Queue */
|
||||
#define FSNODEFLAG_TYPE_SHM 0x00000006 /* Shared memory region */
|
||||
#define FSNODEFLAG_DELETED 0x00000008 /* Unlinked */
|
||||
|
||||
#define INODE_IS_TYPE(i,t) \
|
||||
(((i)->i_flags & FSNODEFLAG_TYPE_MASK) == (t))
|
||||
#define INODE_IS_SPECIAL(i) \
|
||||
(((i)->i_flags & FSNODEFLAG_TYPE_SPECIAL) != 0)
|
||||
|
||||
#define INODE_IS_DRIVER(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_DRIVER)
|
||||
#define INODE_IS_BLOCK(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_BLOCK)
|
||||
#define INODE_IS_MOUNTPT(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_MOUNTPT)
|
||||
#define INODE_IS_NAMEDSEM(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_NAMEDSEM)
|
||||
#define INODE_IS_MQUEUE(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_MQUEUE)
|
||||
#define INODE_IS_SHM(i) INODE_IS_TYPE(i,FSNODEFLAG_TYPE_SHM)
|
||||
|
||||
#define INODE_GET_TYPE(i) ((i)->i_flags & FSNODEFLAG_TYPE_MASK)
|
||||
#define INODE_SET_TYPE(i,t) \
|
||||
do \
|
||||
{ \
|
||||
(i)->i_flags = ((i)->i_flags & ~FSNODEFLAG_TYPE_MASK) | (t); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define INODE_SET_DRIVER(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_DRIVER)
|
||||
#define INODE_SET_BLOCK(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_BLOCK)
|
||||
#define INODE_SET_MOUNTPT(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_MOUNTPT)
|
||||
#define INODE_SET_NAMEDSEM(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_NAMEDSEM)
|
||||
#define INODE_SET_MQUEUE(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_MQUEUE)
|
||||
#define INODE_SET_SHM(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_SHM)
|
||||
|
||||
/* Mountpoint fd_flags values */
|
||||
|
||||
#define DIRENTFLAGS_PSEUDONODE 1
|
||||
|
||||
#define DIRENT_SETPSEUDONODE(f) do (f) |= DIRENTFLAGS_PSEUDONODE; while (0)
|
||||
#define DIRENT_ISPSEUDONODE(f) (((f) & DIRENTFLAGS_PSEUDONODE) != 0)
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||
|
||||
# define SETUP_SEARCH(d,p,n) \
|
||||
do \
|
||||
{ \
|
||||
(d)->path = (p); \
|
||||
(d)->node = NULL; \
|
||||
(d)->peer = NULL; \
|
||||
(d)->parent = NULL; \
|
||||
(d)->relpath = NULL; \
|
||||
(d)->linktgt = NULL; \
|
||||
(d)->buffer = NULL; \
|
||||
(d)->nofollow = (n); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define RELEASE_SEARCH(d) \
|
||||
if ((d)->buffer != NULL) \
|
||||
{ \
|
||||
kmm_free((d)->buffer); \
|
||||
(d)->buffer = NULL; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# define SETUP_SEARCH(d,p,n) \
|
||||
do \
|
||||
{ \
|
||||
(d)->path = (p); \
|
||||
(d)->node = NULL; \
|
||||
(d)->peer = NULL; \
|
||||
(d)->parent = NULL; \
|
||||
(d)->relpath = NULL; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define RELEASE_SEARCH(d)
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This is the type of the argument to inode_search().
|
||||
*
|
||||
* path - INPUT: Path of inode to find
|
||||
* OUTPUT: Residual part of path not traversed
|
||||
* node - INPUT: (not used)
|
||||
* OUTPUT: On success, holds the pointer to the inode found.
|
||||
* peer - INPUT: (not used)
|
||||
* OUTPUT: The inode to the "left" of the inode found.
|
||||
* parent - INPUT: (not used)
|
||||
* OUTPUT: The inode to the "above" of the inode found.
|
||||
* relpath - INPUT: (not used)
|
||||
* OUTPUT: If the returned inode is a mountpoint, this is the
|
||||
* relative path from the mountpoint.
|
||||
* linktgt - INPUT: (not used)
|
||||
* OUTPUT: If a symobolic link into a mounted file system is
|
||||
* detected while traversing the path, then the link
|
||||
* will be converted to a mountpoint inode if the
|
||||
* mountpoint link is in an intermediate node of the
|
||||
* path or at the final node of the path with nofollow=true.
|
||||
* nofollow - INPUT: true: terminal node is returned; false: if the
|
||||
* terminal is a soft link, then return the inode of
|
||||
* the link target.
|
||||
* - OUTPUT: (not used)
|
||||
* buffer - INPUT: Not used
|
||||
* - OUTPUT: May hold an allocated intermediate path which is
|
||||
* probably of no interest to the caller unless it holds
|
||||
* the relpath.
|
||||
*/
|
||||
|
||||
struct inode_search_s
|
||||
{
|
||||
FAR const char *path; /* Path of inode to find */
|
||||
FAR struct inode *node; /* Pointer to the inode found */
|
||||
FAR struct inode *peer; /* Node to the "left" for the found inode */
|
||||
FAR struct inode *parent; /* Node "above" the found inode */
|
||||
FAR const char *relpath; /* Relative path into the mountpoint */
|
||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||
FAR const char *linktgt; /* Target of symbolic link if linked to a directory */
|
||||
FAR char *buffer; /* Path expansion buffer */
|
||||
bool nofollow; /* true: Don't follow terminal soft link */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Callback used by foreach_inode to traverse all inodes in the pseudo-
|
||||
* file system.
|
||||
*/
|
||||
|
||||
typedef int (*foreach_inode_t)(FAR struct inode *node,
|
||||
FAR char dirpath[PATH_MAX],
|
||||
FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern FAR struct inode *g_root_inode;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_initialize
|
||||
*
|
||||
* Description:
|
||||
* This is called from the OS initialization logic to configure the file
|
||||
* system.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_semtake
|
||||
*
|
||||
* Description:
|
||||
* Get exclusive access to the in-memory inode tree (tree_sem).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_semtake(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_semgive
|
||||
*
|
||||
* Description:
|
||||
* Relinquish exclusive access to the in-memory inode tree (tree_sem).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_semgive(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_search
|
||||
*
|
||||
* Description:
|
||||
* Find the inode associated with 'path' returning the inode references
|
||||
* and references to its companion nodes.
|
||||
*
|
||||
* If a mountpoint is encountered in the search prior to encountering the
|
||||
* terminal node, the search will terminate at the mountpoint inode. That
|
||||
* inode and the relative path from the mountpoint, 'relpath' will be
|
||||
* returned.
|
||||
*
|
||||
* inode_search will follow soft links in path leading up to the terminal
|
||||
* node. Whether or no inode_search() will deference that terminal node
|
||||
* depends on the 'nofollow' input.
|
||||
*
|
||||
* If a soft link is encountered that is not the terminal node in the path,
|
||||
* that link WILL be deferenced unconditionally.
|
||||
*
|
||||
* Assumptions:
|
||||
* The caller holds the g_inode_sem semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct inode *inode_search(FAR const char **path,
|
||||
FAR struct inode **peer,
|
||||
FAR struct inode **parent,
|
||||
FAR const char **relpath);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_find
|
||||
*
|
||||
* Description:
|
||||
* This is called from the open() logic to get a reference to the inode
|
||||
* associated with a path. This is accomplished by calling inode_search().
|
||||
* inode_find() is a simple wrapper around inode_search(). The primary
|
||||
* difference between inode_find() and inode_search is that inode_find()
|
||||
* will lock the inode tree and increment the reference count on the inode.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int inode_find(FAR struct inode_search_s *desc);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_stat
|
||||
*
|
||||
* Description:
|
||||
* The inode_stat() function will obtain information about an 'inode' in
|
||||
* the pseudo file system and will write it to the area pointed to by 'buf'.
|
||||
*
|
||||
* The 'buf' argument is a pointer to a stat structure, as defined in
|
||||
* <sys/stat.h>, into which information is placed concerning the file.
|
||||
*
|
||||
* Input Parameters:
|
||||
* inode - The indoe of interest
|
||||
* buf - The caller provide location in which to return information about
|
||||
* the inode.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct stat; /* Forward reference */
|
||||
int inode_stat(FAR struct inode *inode, FAR struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_free
|
||||
*
|
||||
* Description:
|
||||
* Free resources used by an inode
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_free(FAR struct inode *node);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_nextname
|
||||
*
|
||||
* Description:
|
||||
* Given a path with node names separated by '/', return the next node
|
||||
* name.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
const char *inode_nextname(FAR const char *name);
|
||||
|
||||
bool IsInRootfs(const char *relpath);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_reserve
|
||||
*
|
||||
* Description:
|
||||
* Reserve an (initialized) inode the pseudo file system.
|
||||
*
|
||||
* NOTE: Caller must hold the inode semaphore
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - The path to the inode to create
|
||||
* inode - The location to return the inode pointer
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success (with the inode point in 'inode'); A negated errno
|
||||
* value is returned on failure:
|
||||
*
|
||||
* EINVAL - 'path' is invalid for this operation
|
||||
* EEXIST - An inode already exists at 'path'
|
||||
* ENOMEM - Failed to allocate in-memory resources for the operation
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int inode_reserve(FAR const char *path, FAR struct inode **inode);
|
||||
#ifdef LOSCFG_FS_ZPFS
|
||||
int inode_reserve_rootdir(FAR const char *path, FAR struct inode **inode, bool force);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_unlink
|
||||
*
|
||||
* Description:
|
||||
* Given a path, remove a the node from the in-memory, inode tree that the
|
||||
* path refers to. This is normally done in preparation to removing or
|
||||
* moving an inode.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* The caller must hold the inode semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct inode *inode_unlink(FAR const char *path);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_remove
|
||||
*
|
||||
* Description:
|
||||
* Given a path, remove a the node from the in-memory, inode tree that the
|
||||
* path refers to and free all resources related to the inode. If the
|
||||
* inode is in-use, then it will be unlinked, but will not be freed until
|
||||
* the last reference to the inode is released.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* The caller must hold the inode semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int inode_remove(FAR const char *path);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_addref
|
||||
*
|
||||
* Description:
|
||||
* Increment the reference count on an inode (as when a file descriptor
|
||||
* is dup'ed).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_addref(FAR struct inode *inode);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_release
|
||||
*
|
||||
* Description:
|
||||
* This is called from close() logic when it no longer refers to the inode.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_release(FAR struct inode *inode);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: foreach_inode
|
||||
*
|
||||
* Description:
|
||||
* Visit each inode in the pseudo-file system. The traversal is terminated
|
||||
* when the callback 'handler' returns a non-zero value, or when all of
|
||||
* the inodes have been visited.
|
||||
*
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
* real work issue.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int foreach_inode(foreach_inode_t handler, FAR void *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __FS_INODE_H */
|
||||
@@ -37,10 +37,9 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
#include "vfs_config.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs/mount.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -84,5 +83,3 @@ int foreach_mountpoint(foreach_mountpoint_t handler, void *arg)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+5
-8
@@ -40,16 +40,12 @@
|
||||
|
||||
#include "vfs_config.h"
|
||||
|
||||
#include "driver/driver.h"
|
||||
#include "sys/mount.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
#include "assert.h"
|
||||
#include "debug.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "stdlib.h"
|
||||
#include "driver/driver.h"
|
||||
#ifdef LOSCFG_DRIVERS_MTD
|
||||
#include "mtd_partition.h"
|
||||
#endif
|
||||
@@ -62,9 +58,10 @@
|
||||
#else
|
||||
#include "stdlib.h"
|
||||
#endif
|
||||
#include "fs/vfs_util.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "path_cache.h"
|
||||
#include "fs/mount.h"
|
||||
#include "fs/driver.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
|
||||
/* At least one filesystem must be defined, or this file will not compile.
|
||||
@@ -269,7 +266,7 @@ int mount(const char *source, const char *target,
|
||||
* error.
|
||||
*/
|
||||
|
||||
fdbg("ERROR: Bind method failed: %d\n", ret);
|
||||
PRINT_ERR("Bind method failed: %d\n", ret);
|
||||
errcode = ret;
|
||||
#ifdef LOSCFG_DRIVERS_MTD
|
||||
if (fsmap->is_mtd_support && (device != NULL) && (partition != NULL))
|
||||
|
||||
@@ -41,13 +41,12 @@
|
||||
|
||||
#include "sys/mount.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "stdlib.h"
|
||||
#include "unistd.h"
|
||||
#include "string.h"
|
||||
#include "disk.h"
|
||||
#include "fs_other.h"
|
||||
#include "fs/mount.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
+19
-19
@@ -113,26 +113,26 @@ struct nfsstats
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
extern void nfs_mux_take(FAR struct nfsmount *nmp);
|
||||
extern void nfs_mux_release(FAR struct nfsmount *nmp);
|
||||
extern int nfs_checkmount(FAR struct nfsmount *nmp);
|
||||
extern int nfs_fsinfo(FAR struct nfsmount *nmp);
|
||||
extern void nfs_mux_take(struct nfsmount *nmp);
|
||||
extern void nfs_mux_release(struct nfsmount *nmp);
|
||||
extern int nfs_checkmount(struct nfsmount *nmp);
|
||||
extern int nfs_fsinfo(struct nfsmount *nmp);
|
||||
extern int nfs_request(struct nfsmount *nmp, int procnum,
|
||||
FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen);
|
||||
extern int nfs_lookup(FAR struct nfsmount *nmp, FAR const char *filename,
|
||||
FAR struct file_handle *fhandle,
|
||||
FAR struct nfs_fattr *obj_attributes,
|
||||
FAR struct nfs_fattr *dir_attributes);
|
||||
extern int nfs_findnode(FAR struct nfsmount *nmp, FAR const char *relpath,
|
||||
FAR struct file_handle *fhandle,
|
||||
FAR struct nfs_fattr *obj_attributes,
|
||||
FAR struct nfs_fattr *dir_attributes);
|
||||
extern int nfs_finddir(FAR struct nfsmount *nmp, FAR const char *relpath,
|
||||
FAR struct file_handle *fhandle,
|
||||
FAR struct nfs_fattr *attributes, FAR char *filename);
|
||||
extern void nfs_attrupdate(FAR struct nfsnode *np,
|
||||
FAR struct nfs_fattr *attributes);
|
||||
void *request, size_t reqlen,
|
||||
void *response, size_t resplen);
|
||||
extern int nfs_lookup(struct nfsmount *nmp, const char *filename,
|
||||
struct file_handle *fhandle,
|
||||
struct nfs_fattr *obj_attributes,
|
||||
struct nfs_fattr *dir_attributes);
|
||||
extern int nfs_findnode(struct nfsmount *nmp, const char *relpath,
|
||||
struct file_handle *fhandle,
|
||||
struct nfs_fattr *obj_attributes,
|
||||
struct nfs_fattr *dir_attributes);
|
||||
extern int nfs_finddir(struct nfsmount *nmp, const char *relpath,
|
||||
struct file_handle *fhandle,
|
||||
struct nfs_fattr *attributes, char *filename);
|
||||
extern void nfs_attrupdate(struct nfsnode *np,
|
||||
struct nfs_fattr *attributes);
|
||||
extern int nfs_mount(const char *server_ip_and_path, const char *mount_path,
|
||||
unsigned int uid, unsigned int gid);
|
||||
|
||||
|
||||
+14
-15
@@ -55,7 +55,6 @@
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include "lwip/opt.h"
|
||||
@@ -68,7 +67,7 @@
|
||||
#include "nfs_node.h"
|
||||
#include "xdr_subs.h"
|
||||
#include "los_tables.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "los_vm_filemap.h"
|
||||
#include "user_copy.h"
|
||||
|
||||
@@ -101,7 +100,7 @@ struct nfsstats nfsstats;
|
||||
entry = (struct entry3 *)malloc(sizeof(struct entry3)); \
|
||||
if (entry == NULL) \
|
||||
{ \
|
||||
fvdbg("malloc failed\n"); \
|
||||
PRINT_DEBUG("malloc failed\n"); \
|
||||
error = ENOMEM; \
|
||||
goto errout_with_memory; \
|
||||
} \
|
||||
@@ -382,7 +381,7 @@ static void nfs_decode_args(struct nfs_mount_parameters *nprmt,
|
||||
nprmt->retry = NFS_MAXREXMIT + 1; /* Past clip limit */
|
||||
}
|
||||
|
||||
/* Get the maximum amount of data that can be transferred in one packet */
|
||||
/* Get the maximum amount of data that can be transPRINT_ERRed in one packet */
|
||||
|
||||
if ((argp->sotype == SOCK_DGRAM) != 0)
|
||||
{
|
||||
@@ -390,11 +389,11 @@ static void nfs_decode_args(struct nfs_mount_parameters *nprmt,
|
||||
}
|
||||
else
|
||||
{
|
||||
ferr("ERROR: Only SOCK_DRAM is supported\n");
|
||||
PRINT_ERR("Only SOCK_DRAM is supported\n");
|
||||
maxio = NFS_MAXDATA;
|
||||
}
|
||||
|
||||
/* Get the maximum amount of data that can be transferred in one write transfer */
|
||||
/* Get the maximum amount of data that can be transPRINT_ERRed in one write transfer */
|
||||
|
||||
if ((argp->flags & NFSMNT_WSIZE) != 0 && argp->wsize > 0)
|
||||
{
|
||||
@@ -419,7 +418,7 @@ static void nfs_decode_args(struct nfs_mount_parameters *nprmt,
|
||||
nprmt->wsize = MAXBSIZE;
|
||||
}
|
||||
|
||||
/* Get the maximum amount of data that can be transferred in one read transfer */
|
||||
/* Get the maximum amount of data that can be transPRINT_ERRed in one read transfer */
|
||||
|
||||
if ((argp->flags & NFSMNT_RSIZE) != 0 && argp->rsize > 0)
|
||||
{
|
||||
@@ -444,7 +443,7 @@ static void nfs_decode_args(struct nfs_mount_parameters *nprmt,
|
||||
nprmt->rsize = MAXBSIZE;
|
||||
}
|
||||
|
||||
/* Get the maximum amount of data that can be transferred in directory transfer */
|
||||
/* Get the maximum amount of data that can be transPRINT_ERRed in directory transfer */
|
||||
|
||||
if ((argp->flags & NFSMNT_READDIRSIZE) != 0 && argp->readdirsize > 0)
|
||||
{
|
||||
@@ -544,7 +543,7 @@ int nfs_bind(struct Vnode *blkdriver, const void *data,
|
||||
nmp = (struct nfsmount *)malloc(SIZEOF_nfsmount(buflen));
|
||||
if (!nmp)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate mountpoint structure\n");
|
||||
PRINT_ERR("Failed to allocate mountpoint structure\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -599,14 +598,14 @@ int nfs_bind(struct Vnode *blkdriver, const void *data,
|
||||
rpc = (struct rpcclnt *)malloc(sizeof(struct rpcclnt));
|
||||
if (!rpc)
|
||||
{
|
||||
ferr("ERROR: Failed to allocate rpc structure\n");
|
||||
PRINT_ERR("Failed to allocate rpc structure\n");
|
||||
error = ENOMEM;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
(void)memset_s(rpc, sizeof(struct rpcclnt), 0, sizeof(struct rpcclnt));
|
||||
|
||||
finfo("Connecting\n");
|
||||
PRINT_INFO("Connecting\n");
|
||||
|
||||
/* Translate nfsmnt flags -> rpcclnt flags */
|
||||
|
||||
@@ -644,7 +643,7 @@ int nfs_bind(struct Vnode *blkdriver, const void *data,
|
||||
(void *)&resok, sizeof(struct rpc_reply_getattr));
|
||||
if (error)
|
||||
{
|
||||
ferr("ERROR: nfs_request failed: %d\n", error);
|
||||
PRINT_ERR("nfs_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -656,7 +655,7 @@ int nfs_bind(struct Vnode *blkdriver, const void *data,
|
||||
|
||||
*handle = (void *)nmp;
|
||||
|
||||
finfo("Successfully mounted\n");
|
||||
PRINT_INFO("Successfully mounted\n");
|
||||
return OK;
|
||||
|
||||
bad:
|
||||
@@ -2652,7 +2651,7 @@ static int vfs_nfs_unmount(struct Mount *mnt, struct Vnode **blkDriver)
|
||||
|
||||
if (nmp->nm_head != NULL || nmp->nm_dir != NULL)
|
||||
{
|
||||
ferr("ERROR; There are open files: %p or directories: %p\n", nmp->nm_head, nmp->nm_dir);
|
||||
PRINT_ERR("There are open files: %p or directories: %p\n", nmp->nm_head, nmp->nm_dir);
|
||||
|
||||
/* This implementation currently only supports unmounting if there are
|
||||
* no open file references.
|
||||
@@ -2667,7 +2666,7 @@ static int vfs_nfs_unmount(struct Mount *mnt, struct Vnode **blkDriver)
|
||||
error = rpcclnt_umount(nmp->nm_rpcclnt);
|
||||
if (error)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_umount failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_umount failed: %d\n", error);
|
||||
goto errout_with_mutex;
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -42,7 +42,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <pthread.h>
|
||||
#include "vfs_config.h"
|
||||
#include "dirent.h"
|
||||
@@ -96,7 +95,7 @@ static inline int nfs_pathsegment(const char **path, char *buffer,
|
||||
}
|
||||
else if (nbytes >= NAME_MAX)
|
||||
{
|
||||
ferr("ERROR: File name segment is too long: %d\n", *path);
|
||||
PRINT_ERR("File name segment is too long: %d\n", *path);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
else
|
||||
@@ -189,7 +188,7 @@ tryagain:
|
||||
request, reqlen, response, resplen);
|
||||
if (error != 0)
|
||||
{
|
||||
PRINTK("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -213,7 +212,7 @@ tryagain:
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
PRINTK("ERROR: NFS error %d from server\n", error);
|
||||
PRINT_ERR("NFS error %d from server\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -252,7 +251,7 @@ int nfs_lookup(struct nfsmount *nmp, const char *filename,
|
||||
namelen = strlen(filename);
|
||||
if (namelen > NAME_MAX)
|
||||
{
|
||||
ferr("ERROR: Length of the string is too long: %d\n", namelen);
|
||||
PRINT_ERR("Length of the string is too long: %d\n", namelen);
|
||||
return E2BIG;
|
||||
}
|
||||
|
||||
@@ -287,7 +286,7 @@ int nfs_lookup(struct nfsmount *nmp, const char *filename,
|
||||
|
||||
if (error)
|
||||
{
|
||||
ferr("ERROR: nfs_request failed: %d\n", error);
|
||||
PRINT_ERR("nfs_request failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -304,7 +303,7 @@ int nfs_lookup(struct nfsmount *nmp, const char *filename,
|
||||
value = fxdr_unsigned(uint32_t, value);
|
||||
if (value > NFSX_V3FHMAX)
|
||||
{
|
||||
ferr("ERROR: Bad file handle length: %d\n", value);
|
||||
PRINT_ERR("Bad file handle length: %d\n", value);
|
||||
return EIO;
|
||||
}
|
||||
|
||||
@@ -404,7 +403,7 @@ int nfs_findnode(struct nfsmount *nmp, const char *relpath,
|
||||
{
|
||||
/* The filename segment contains is too long. */
|
||||
|
||||
ferr("ERROR: nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
|
||||
PRINT_ERR("nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
|
||||
relpath, buffer, error);
|
||||
return error;
|
||||
}
|
||||
@@ -414,7 +413,7 @@ int nfs_findnode(struct nfsmount *nmp, const char *relpath,
|
||||
error = nfs_lookup(nmp, buffer, fhandle, obj_attributes, dir_attributes);
|
||||
if (error != OK)
|
||||
{
|
||||
ferr("ERROR: nfs_lookup of \"%s\" failed at \"%s\": %d\n",
|
||||
PRINT_ERR("nfs_lookup of \"%s\" failed at \"%s\": %d\n",
|
||||
relpath, buffer, error);
|
||||
return error;
|
||||
}
|
||||
@@ -443,7 +442,7 @@ int nfs_findnode(struct nfsmount *nmp, const char *relpath,
|
||||
{
|
||||
/* Ooops.. we found something else */
|
||||
|
||||
ferr("ERROR: Intermediate segment \"%s\" of \'%s\" is not a directory\n",
|
||||
PRINT_ERR("Intermediate segment \"%s\" of \'%s\" is not a directory\n",
|
||||
buffer, path);
|
||||
return ENOTDIR;
|
||||
}
|
||||
@@ -498,7 +497,7 @@ int nfs_finddir(struct nfsmount *nmp, const char *relpath,
|
||||
{
|
||||
/* The filename segment contains is too long. */
|
||||
|
||||
ferr("ERROR: nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
|
||||
PRINT_ERR("nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
|
||||
relpath, filename, error);
|
||||
return error;
|
||||
}
|
||||
@@ -522,7 +521,7 @@ int nfs_finddir(struct nfsmount *nmp, const char *relpath,
|
||||
error = nfs_lookup(nmp, filename, fhandle, attributes, NULL);
|
||||
if (error != OK)
|
||||
{
|
||||
ferr("ERROR: fs_lookup of \"%s\" failed at \"%s\": %d\n",
|
||||
PRINT_ERR("fs_lookup of \"%s\" failed at \"%s\": %d\n",
|
||||
relpath, filename, error);
|
||||
return error;
|
||||
}
|
||||
@@ -534,7 +533,7 @@ int nfs_finddir(struct nfsmount *nmp, const char *relpath,
|
||||
{
|
||||
/* Ooops.. we found something else */
|
||||
|
||||
ferr("ERROR: Intermediate segment \"%s\" of \'%s\" is not a directory\n",
|
||||
PRINT_ERR("Intermediate segment \"%s\" of \'%s\" is not a directory\n",
|
||||
filename, path);
|
||||
return ENOTDIR;
|
||||
}
|
||||
|
||||
+7
-7
@@ -548,13 +548,13 @@ struct rpcclnt
|
||||
****************************************************************************/
|
||||
|
||||
void rpcclnt_init(void);
|
||||
int rpcclnt_connect(FAR struct rpcclnt *rpc);
|
||||
void rpcclnt_disconnect(FAR struct rpcclnt *rpc);
|
||||
int rpcclnt_umount(FAR struct rpcclnt *rpc);
|
||||
void rpcclnt_safedisconnect(FAR struct rpcclnt *rpc);
|
||||
int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog, int version,
|
||||
FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen);
|
||||
int rpcclnt_connect(struct rpcclnt *rpc);
|
||||
void rpcclnt_disconnect(struct rpcclnt *rpc);
|
||||
int rpcclnt_umount(struct rpcclnt *rpc);
|
||||
void rpcclnt_safedisconnect(struct rpcclnt *rpc);
|
||||
int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog, int version,
|
||||
void *request, size_t reqlen,
|
||||
void *response, size_t resplen);
|
||||
void rpcclnt_setuidgid(uint32_t uid, uint32_t gid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+46
-47
@@ -80,7 +80,6 @@
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
#include <unistd.h>
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/sockets.h"
|
||||
@@ -179,7 +178,7 @@ static int rpcclnt_send(struct rpcclnt *rpc, int procid, int prog,
|
||||
/* psock_sendto failed */
|
||||
|
||||
ret = get_errno();
|
||||
ferr("ERROR: psock_sendto failed: %d\n", ret);
|
||||
PRINT_ERR("psock_sendto failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -217,13 +216,13 @@ retry:
|
||||
ret = select(rpc->rc_so + 1, &fdreadset, 0, 0, &timeval);
|
||||
if (ret == 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_receive select nothing\n");
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive select nothing\n");
|
||||
return EAGAIN;
|
||||
}
|
||||
else if (ret < 0)
|
||||
{
|
||||
error = get_errno();
|
||||
fdbg("ERROR: rpcclnt_receive select error %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive select error %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -231,7 +230,7 @@ retry:
|
||||
if (nbytes <= (ssize_t)sizeof(xid))
|
||||
{
|
||||
error = get_errno();
|
||||
fdbg("ERROR: psock_recvfrom failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: psock_recvfrom failed: %d\n", error);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
@@ -243,7 +242,7 @@ retry:
|
||||
|
||||
if (fxdr_unsigned(uint32_t, xid) != rpc->xid)
|
||||
{
|
||||
fdbg("ERROR: psock_recvfrom a wrong packet\n");
|
||||
PRINT_DEBUG("ERROR: psock_recvfrom a wrong packet\n");
|
||||
goto retry;
|
||||
}
|
||||
|
||||
@@ -286,13 +285,13 @@ static int rpcclnt_receive(struct rpcclnt *rpc, struct sockaddr *aname,
|
||||
ret = select(rpc->rc_so + 1, &fdreadset, 0, 0, &timeval);
|
||||
if (ret == 0) /* no reply */
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_receive select nothing\n");
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive select nothing\n");
|
||||
return EAGAIN;
|
||||
}
|
||||
else if (ret < 0) /* select error */
|
||||
{
|
||||
error = get_errno();
|
||||
fdbg("ERROR: rpcclnt_receive select error %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive select error %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -300,14 +299,14 @@ static int rpcclnt_receive(struct rpcclnt *rpc, struct sockaddr *aname,
|
||||
if (nbytes < 0)
|
||||
{
|
||||
error = get_errno();
|
||||
fdbg("ERROR: rpcclnt_receive recvfrom error %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive recvfrom error %d\n", error);
|
||||
return error;
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
/* connection closed by peer side */
|
||||
|
||||
fdbg("ERROR: rpcclnt_receive connection closed by peer\n");
|
||||
PRINT_DEBUG("ERROR: rpcclnt_receive connection closed by peer\n");
|
||||
return EIO;
|
||||
}
|
||||
else
|
||||
@@ -360,7 +359,7 @@ static int rpcclnt_reply(struct rpcclnt *rpc, int procid, int prog,
|
||||
error = rpcclnt_receive(rpc, rpc->rc_name, procid, prog, reply, resplen);
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_receive returned: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_receive returned: %d\n", error);
|
||||
|
||||
/* For UDP, If we failed because of a timeout, then try sending the CALL
|
||||
* message again. While for TCP, just return errno.
|
||||
@@ -383,7 +382,7 @@ static int rpcclnt_reply(struct rpcclnt *rpc, int procid, int prog,
|
||||
|
||||
if (replyheader->rp_direction != rpc_reply)
|
||||
{
|
||||
ferr("ERROR: Different RPC REPLY returned\n");
|
||||
PRINT_ERR("Different RPC REPLY returned\n");
|
||||
rpc_statistics(rpcinvalid);
|
||||
error = EPROTO;
|
||||
}
|
||||
@@ -468,7 +467,7 @@ static int rpcclnt_alivecheck(struct rpcclnt *rpc)
|
||||
ret = select(sockfd + 1, &rfd, NULL, NULL, &timeout);
|
||||
if (ret < 0)
|
||||
{
|
||||
fvdbg("ERROR rpc_alivecheck : select failure\n");
|
||||
PRINT_DEBUG("ERROR rpc_alivecheck : select failure\n");
|
||||
return get_errno();
|
||||
}
|
||||
|
||||
@@ -484,7 +483,7 @@ static int rpcclnt_alivecheck(struct rpcclnt *rpc)
|
||||
}
|
||||
else
|
||||
{
|
||||
fvdbg("ERROR rpc_alivecheck : recv unsolocit %d data from server\n", recvlen);
|
||||
PRINT_DEBUG("ERROR rpc_alivecheck : recv unsolocit %d data from server\n", recvlen);
|
||||
return ENOTSOCK;
|
||||
}
|
||||
}
|
||||
@@ -561,7 +560,7 @@ static int rpcclnt_reconnect(struct rpcclnt *rpc, struct sockaddr *saddr)
|
||||
error = socket(rpc->rc_name->sa_family, rpc->rc_sotype, IPPROTO_TCP);
|
||||
if (error < 0)
|
||||
{
|
||||
fdbg("ERROR: psock_socket failed: %d", get_errno());
|
||||
PRINT_DEBUG("ERROR: psock_socket failed: %d", get_errno());
|
||||
return -error;
|
||||
}
|
||||
|
||||
@@ -580,14 +579,14 @@ static int rpcclnt_reconnect(struct rpcclnt *rpc, struct sockaddr *saddr)
|
||||
if (error < 0)
|
||||
{
|
||||
errval = get_errno();
|
||||
fdbg("ERROR: psock_bind failed: %d\n", errval);
|
||||
PRINT_DEBUG("ERROR: psock_bind failed: %d\n", errval);
|
||||
}
|
||||
}
|
||||
while (errval == EADDRINUSE && trycount > 0);
|
||||
|
||||
if (error)
|
||||
{
|
||||
fdbg("ERROR: psock_bind failed: %d, port = %d\n", errval, tport);
|
||||
PRINT_DEBUG("ERROR: psock_bind failed: %d, port = %d\n", errval, tport);
|
||||
goto bad;
|
||||
}
|
||||
#endif
|
||||
@@ -595,7 +594,7 @@ static int rpcclnt_reconnect(struct rpcclnt *rpc, struct sockaddr *saddr)
|
||||
if (error < 0)
|
||||
{
|
||||
errval = get_errno();
|
||||
fdbg("ERROR: psock_connect failed [port=%d]: %d\n",
|
||||
PRINT_DEBUG("ERROR: psock_connect failed [port=%d]: %d\n",
|
||||
ntohs(((struct sockaddr_in *)saddr)->sin_port), errval);
|
||||
goto bad;
|
||||
}
|
||||
@@ -631,7 +630,7 @@ void rpcclnt_init(void)
|
||||
rpc_auth_unix = txdr_unsigned(RPCAUTH_UNIX);
|
||||
rpc_auth_null = txdr_unsigned(RPCAUTH_NULL);
|
||||
|
||||
finfo("RPC initialized\n");
|
||||
PRINT_INFO("RPC initialized\n");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -667,7 +666,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
uint16_t tport = 0;
|
||||
int errval;
|
||||
|
||||
finfo("Connecting\n");
|
||||
PRINT_INFO("Connecting\n");
|
||||
|
||||
/* Create the socket */
|
||||
|
||||
@@ -678,7 +677,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
error = socket(saddr->sa_family, rpc->rc_sotype, NFS_PROTOTYPE);
|
||||
if (error < 0)
|
||||
{
|
||||
fdbg("ERROR: psock_socket failed: %d", get_errno());
|
||||
PRINT_DEBUG("ERROR: psock_socket failed: %d", get_errno());
|
||||
return -error;
|
||||
}
|
||||
|
||||
@@ -698,14 +697,14 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
if (error < 0)
|
||||
{
|
||||
errval = get_errno();
|
||||
ferr("ERROR: psock_bind failed: %d\n", errval);
|
||||
PRINT_ERR("psock_bind failed: %d\n", errval);
|
||||
}
|
||||
}
|
||||
while (errval == EADDRINUSE && trycount > 0);
|
||||
|
||||
if (error)
|
||||
{
|
||||
ferr("ERROR: psock_bind failed: %d, port = %d\n", errval, tport);
|
||||
PRINT_ERR("psock_bind failed: %d, port = %d\n", errval, tport);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -718,7 +717,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
if (error < 0)
|
||||
{
|
||||
error = get_errno();
|
||||
ferr("ERROR: psock_connect to PMAP port failed: %d", error);
|
||||
PRINT_ERR("psock_connect to PMAP port failed: %d", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -736,7 +735,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
(void *)&response.rdata, sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -746,7 +745,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
error = rpcclnt_reconnect(rpc, saddr);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -774,14 +773,14 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
sizeof(struct rpc_reply_mount));
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
error = fxdr_unsigned(uint32_t, response.mdata.mount.status);
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: Bad mount status: %d\n", error);
|
||||
PRINT_ERR("Bad mount status: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -797,7 +796,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
error = rpcclnt_reconnect(rpc, saddr);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -813,7 +812,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -822,7 +821,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
error = rpcclnt_reconnect(rpc, saddr);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -889,7 +888,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
error = rpcclnt_reconnect(rpc, saddr);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -905,7 +904,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -914,7 +913,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
error = rpcclnt_reconnect(rpc, saddr);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR: rpcclnt_reconnect failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -932,7 +931,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
sizeof(struct rpc_reply_umount));
|
||||
if (error != 0)
|
||||
{
|
||||
ferr("ERROR: rpcclnt_request failed: %d\n", error);
|
||||
PRINT_ERR("rpcclnt_request failed: %d\n", error);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -1005,7 +1004,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
error = rpcclnt_send(rpc, procnum, prog, request, reqlen);
|
||||
if (error != OK)
|
||||
{
|
||||
finfo("ERROR rpcclnt_send failed: %d\n", error);
|
||||
PRINT_INFO("ERROR rpcclnt_send failed: %d\n", error);
|
||||
}
|
||||
|
||||
/* Wait for the reply from our send */
|
||||
@@ -1015,7 +1014,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
error = rpcclnt_reply(rpc, procnum, prog, response, resplen);
|
||||
if (error != OK)
|
||||
{
|
||||
finfo("ERROR rpcclnt_reply failed: %d\n", error);
|
||||
PRINT_INFO("ERROR rpcclnt_reply failed: %d\n", error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,7 +1024,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
|
||||
if (error != OK)
|
||||
{
|
||||
ferr("ERROR: RPC failed: %d\n", error);
|
||||
PRINT_ERR("RPC failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1038,7 +1037,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
error = rpcclnt_alivecheck(rpc);
|
||||
if (error != OK)
|
||||
{
|
||||
fvdbg("ERROR rpc_alivecheck failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR rpc_alivecheck failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1050,7 +1049,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
error = rpcclnt_reconnect(rpc, rpc->rc_name);
|
||||
if (error != OK)
|
||||
{
|
||||
fvdbg("ERROR rpcclnt_send failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR rpcclnt_send failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1063,7 +1062,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
if (error != OK)
|
||||
{
|
||||
rpcclnt_disconnect(rpc);
|
||||
fvdbg("ERROR rpcclnt_send failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR rpcclnt_send failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1073,7 +1072,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
if (error != OK)
|
||||
{
|
||||
rpcclnt_disconnect(rpc);
|
||||
fvdbg("ERROR rpcclnt_reply failed: %d\n", error);
|
||||
PRINT_DEBUG("ERROR rpcclnt_reply failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1090,11 +1089,11 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
switch (tmp)
|
||||
{
|
||||
case RPC_MISMATCH:
|
||||
ferr("ERROR: RPC_MSGDENIED: RPC_MISMATCH error\n");
|
||||
PRINT_ERR("RPC_MSGDENIED: RPC_MISMATCH error\n");
|
||||
return EOPNOTSUPP;
|
||||
|
||||
case RPC_AUTHERR:
|
||||
ferr("ERROR: RPC_MSGDENIED: RPC_AUTHERR error\n");
|
||||
PRINT_ERR("RPC_MSGDENIED: RPC_AUTHERR error\n");
|
||||
return EACCES;
|
||||
|
||||
default:
|
||||
@@ -1109,16 +1108,16 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog,
|
||||
tmp = fxdr_unsigned(uint32_t, replymsg->status);
|
||||
if (tmp == RPC_SUCCESS)
|
||||
{
|
||||
finfo("RPC_SUCCESS\n");
|
||||
PRINT_INFO("RPC_SUCCESS\n");
|
||||
}
|
||||
else if (tmp == RPC_PROGMISMATCH)
|
||||
{
|
||||
ferr("ERROR: RPC_MSGACCEPTED: RPC_PROGMISMATCH error\n");
|
||||
PRINT_ERR("RPC_MSGACCEPTED: RPC_PROGMISMATCH error\n");
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
else if (tmp > 5)
|
||||
{
|
||||
ferr("ERROR: Unsupported RPC type: %d\n", tmp);
|
||||
PRINT_ERR("Unsupported RPC type: %d\n", tmp);
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
+201
-214
@@ -40,13 +40,16 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <sys/statfs.h>
|
||||
#include "fs/dirent_fs.h"
|
||||
#include "fs/mount.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/fs.h"
|
||||
#include "los_tables.h"
|
||||
#include "fs_tmpfs.h"
|
||||
#include "los_vm_filemap.h"
|
||||
@@ -67,13 +70,13 @@
|
||||
#endif
|
||||
*/
|
||||
#define tmpfs_lock_file(tfo) \
|
||||
(tmpfs_lock_object((FAR struct tmpfs_object_s *)tfo))
|
||||
(tmpfs_lock_object((struct tmpfs_object_s *)tfo))
|
||||
#define tmpfs_lock_directory(tdo) \
|
||||
(tmpfs_lock_object((FAR struct tmpfs_object_s *)tdo))
|
||||
(tmpfs_lock_object((struct tmpfs_object_s *)tdo))
|
||||
#define tmpfs_unlock_file(tfo) \
|
||||
(tmpfs_unlock_object((FAR struct tmpfs_object_s *)tfo))
|
||||
(tmpfs_unlock_object((struct tmpfs_object_s *)tfo))
|
||||
#define tmpfs_unlock_directory(tdo) \
|
||||
(tmpfs_unlock_object((FAR struct tmpfs_object_s *)tdo))
|
||||
(tmpfs_unlock_object((struct tmpfs_object_s *)tdo))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@@ -81,49 +84,49 @@
|
||||
|
||||
/* TMPFS helpers */
|
||||
|
||||
static void tmpfs_lock_reentrant(FAR struct tmpfs_sem_s *sem);
|
||||
static void tmpfs_lock(FAR struct tmpfs_s *fs);
|
||||
static void tmpfs_unlock_reentrant(FAR struct tmpfs_sem_s *sem);
|
||||
static void tmpfs_unlock(FAR struct tmpfs_s *fs);
|
||||
static void tmpfs_lock_object(FAR struct tmpfs_object_s *to);
|
||||
static void tmpfs_unlock_object(FAR struct tmpfs_object_s *to);
|
||||
static void tmpfs_release_lockedobject(FAR struct tmpfs_object_s *to);
|
||||
static void tmpfs_release_lockedfile(FAR struct tmpfs_file_s *tfo);
|
||||
static struct tmpfs_dirent_s *tmpfs_find_dirent(FAR struct tmpfs_directory_s *tdo,
|
||||
FAR const char *name);
|
||||
static int tmpfs_remove_dirent(FAR struct tmpfs_directory_s *tdo,
|
||||
FAR struct tmpfs_object_s *to);
|
||||
static int tmpfs_add_dirent(FAR struct tmpfs_directory_s **tdo,
|
||||
FAR struct tmpfs_object_s *to, FAR const char *name);
|
||||
static FAR struct tmpfs_file_s *tmpfs_alloc_file(void);
|
||||
static int tmpfs_create_file(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s *parent_input,
|
||||
FAR struct tmpfs_file_s **tfo);
|
||||
static void tmpfs_lock_reentrant(struct tmpfs_sem_s *sem);
|
||||
static void tmpfs_lock(struct tmpfs_s *fs);
|
||||
static void tmpfs_unlock_reentrant(struct tmpfs_sem_s *sem);
|
||||
static void tmpfs_unlock(struct tmpfs_s *fs);
|
||||
static void tmpfs_lock_object(struct tmpfs_object_s *to);
|
||||
static void tmpfs_unlock_object(struct tmpfs_object_s *to);
|
||||
static void tmpfs_release_lockedobject(struct tmpfs_object_s *to);
|
||||
static void tmpfs_release_lockedfile(struct tmpfs_file_s *tfo);
|
||||
static struct tmpfs_dirent_s *tmpfs_find_dirent(struct tmpfs_directory_s *tdo,
|
||||
const char *name);
|
||||
static int tmpfs_remove_dirent(struct tmpfs_directory_s *tdo,
|
||||
struct tmpfs_object_s *to);
|
||||
static int tmpfs_add_dirent(struct tmpfs_directory_s **tdo,
|
||||
struct tmpfs_object_s *to, const char *name);
|
||||
static struct tmpfs_file_s *tmpfs_alloc_file(void);
|
||||
static int tmpfs_create_file(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s *parent_input,
|
||||
struct tmpfs_file_s **tfo);
|
||||
|
||||
static FAR struct tmpfs_directory_s *tmpfs_alloc_directory(void);
|
||||
static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s *parent,
|
||||
FAR struct tmpfs_directory_s **tdo);
|
||||
static struct tmpfs_directory_s *tmpfs_alloc_directory(void);
|
||||
static int tmpfs_create_directory(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s *parent,
|
||||
struct tmpfs_directory_s **tdo);
|
||||
|
||||
static int tmpfs_find_object(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath, FAR struct tmpfs_object_s **object,
|
||||
FAR struct tmpfs_directory_s **parent);
|
||||
static int tmpfs_find_file(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_file_s **tfo,
|
||||
FAR struct tmpfs_directory_s **parent);
|
||||
static int tmpfs_find_directory(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s **tdo,
|
||||
FAR struct tmpfs_directory_s **parent);
|
||||
static int tmpfs_find_object(struct tmpfs_s *fs,
|
||||
const char *relpath, struct tmpfs_object_s **object,
|
||||
struct tmpfs_directory_s **parent);
|
||||
static int tmpfs_find_file(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_file_s **tfo,
|
||||
struct tmpfs_directory_s **parent);
|
||||
static int tmpfs_find_directory(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s **tdo,
|
||||
struct tmpfs_directory_s **parent);
|
||||
|
||||
/* File system operations */
|
||||
|
||||
int tmpfs_close(struct file *filep);
|
||||
off_t tmpfs_seek(FAR struct file *filep, off_t offset, int whence);
|
||||
int tmpfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
off_t tmpfs_seek(struct file *filep, off_t offset, int whence);
|
||||
int tmpfs_ioctl(struct file *filep, int cmd, unsigned long arg);
|
||||
int tmpfs_closedir(struct Vnode *node, struct fs_dirent_s *dir);
|
||||
int tmpfs_rewinddir(struct Vnode *vp, struct fs_dirent_s *dir);
|
||||
int tmpfs_truncate(struct Vnode *vp, off_t len);
|
||||
@@ -146,8 +149,8 @@ int tmpfs_reclaim(struct Vnode *vp);
|
||||
|
||||
int tmpfs_statfs(struct Mount *mp, struct statfs *sbp);
|
||||
|
||||
static void tmpfs_stat_common(FAR struct tmpfs_object_s *to,
|
||||
FAR struct stat *buf);
|
||||
static void tmpfs_stat_common(struct tmpfs_object_s *to,
|
||||
struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@@ -204,7 +207,7 @@ static time_t tmpfs_timestamp(void)
|
||||
* Name: tmpfs_lock_reentrant
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_lock_reentrant(FAR struct tmpfs_sem_s *sem)
|
||||
static void tmpfs_lock_reentrant(struct tmpfs_sem_s *sem)
|
||||
{
|
||||
pid_t me;
|
||||
|
||||
@@ -243,7 +246,7 @@ static void tmpfs_lock_reentrant(FAR struct tmpfs_sem_s *sem)
|
||||
* Name: tmpfs_lock
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_lock(FAR struct tmpfs_s *fs)
|
||||
static void tmpfs_lock(struct tmpfs_s *fs)
|
||||
{
|
||||
tmpfs_lock_reentrant(&fs->tfs_exclsem);
|
||||
}
|
||||
@@ -252,7 +255,7 @@ static void tmpfs_lock(FAR struct tmpfs_s *fs)
|
||||
* Name: tmpfs_lock_object
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_lock_object(FAR struct tmpfs_object_s *to)
|
||||
static void tmpfs_lock_object(struct tmpfs_object_s *to)
|
||||
{
|
||||
tmpfs_lock_reentrant(&to->to_exclsem);
|
||||
}
|
||||
@@ -261,7 +264,7 @@ static void tmpfs_lock_object(FAR struct tmpfs_object_s *to)
|
||||
* Name: tmpfs_unlock_reentrant
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_unlock_reentrant(FAR struct tmpfs_sem_s *sem)
|
||||
static void tmpfs_unlock_reentrant(struct tmpfs_sem_s *sem)
|
||||
{
|
||||
DEBUGASSERT(sem->ts_holder == getpid());
|
||||
|
||||
@@ -288,7 +291,7 @@ static void tmpfs_unlock_reentrant(FAR struct tmpfs_sem_s *sem)
|
||||
* Name: tmpfs_unlock
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_unlock(FAR struct tmpfs_s *fs)
|
||||
static void tmpfs_unlock(struct tmpfs_s *fs)
|
||||
{
|
||||
tmpfs_unlock_reentrant(&fs->tfs_exclsem);
|
||||
}
|
||||
@@ -297,7 +300,7 @@ static void tmpfs_unlock(FAR struct tmpfs_s *fs)
|
||||
* Name: tmpfs_unlock_object
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_unlock_object(FAR struct tmpfs_object_s *to)
|
||||
static void tmpfs_unlock_object(struct tmpfs_object_s *to)
|
||||
{
|
||||
tmpfs_unlock_reentrant(&to->to_exclsem);
|
||||
}
|
||||
@@ -306,7 +309,7 @@ static void tmpfs_unlock_object(FAR struct tmpfs_object_s *to)
|
||||
* Name: tmpfs_release_lockedobject
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_release_lockedobject(FAR struct tmpfs_object_s *to)
|
||||
static void tmpfs_release_lockedobject(struct tmpfs_object_s *to)
|
||||
{
|
||||
DEBUGASSERT(to && to->to_refs > 0);
|
||||
|
||||
@@ -314,7 +317,7 @@ static void tmpfs_release_lockedobject(FAR struct tmpfs_object_s *to)
|
||||
|
||||
if (to->to_type == TMPFS_REGULAR)
|
||||
{
|
||||
tmpfs_release_lockedfile((FAR struct tmpfs_file_s *)to);
|
||||
tmpfs_release_lockedfile((struct tmpfs_file_s *)to);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,7 +333,7 @@ static void tmpfs_release_lockedobject(FAR struct tmpfs_object_s *to)
|
||||
* Name: tmpfs_release_lockedfile
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_release_lockedfile(FAR struct tmpfs_file_s *tfo)
|
||||
static void tmpfs_release_lockedfile(struct tmpfs_file_s *tfo)
|
||||
{
|
||||
DEBUGASSERT(tfo && tfo->tfo_refs > 0);
|
||||
|
||||
@@ -361,8 +364,8 @@ static void tmpfs_release_lockedfile(FAR struct tmpfs_file_s *tfo)
|
||||
* Name: tmpfs_find_dirent
|
||||
****************************************************************************/
|
||||
|
||||
static struct tmpfs_dirent_s *tmpfs_find_dirent(FAR struct tmpfs_directory_s *tdo,
|
||||
FAR const char *name)
|
||||
static struct tmpfs_dirent_s *tmpfs_find_dirent(struct tmpfs_directory_s *tdo,
|
||||
const char *name)
|
||||
{
|
||||
LOS_DL_LIST *node;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
@@ -387,8 +390,8 @@ static struct tmpfs_dirent_s *tmpfs_find_dirent(FAR struct tmpfs_directory_s *td
|
||||
* Name: tmpfs_remove_dirent
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_remove_dirent(FAR struct tmpfs_directory_s *tdo,
|
||||
FAR struct tmpfs_object_s *to)
|
||||
static int tmpfs_remove_dirent(struct tmpfs_directory_s *tdo,
|
||||
struct tmpfs_object_s *to)
|
||||
{
|
||||
struct tmpfs_dirent_s *tde;
|
||||
|
||||
@@ -429,13 +432,13 @@ static int tmpfs_remove_dirent(FAR struct tmpfs_directory_s *tdo,
|
||||
* Name: tmpfs_add_dirent
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_add_dirent(FAR struct tmpfs_directory_s **tdo,
|
||||
FAR struct tmpfs_object_s *to,
|
||||
FAR const char *name)
|
||||
static int tmpfs_add_dirent(struct tmpfs_directory_s **tdo,
|
||||
struct tmpfs_object_s *to,
|
||||
const char *name)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *parent;
|
||||
FAR struct tmpfs_dirent_s *tde;
|
||||
FAR char *newname;
|
||||
struct tmpfs_directory_s *parent;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
char *newname;
|
||||
|
||||
/* Copy the name string so that it will persist as long as the
|
||||
* directory entry.
|
||||
@@ -447,7 +450,7 @@ static int tmpfs_add_dirent(FAR struct tmpfs_directory_s **tdo,
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
tde = (FAR struct tmpfs_dirent_s *)malloc(sizeof(struct tmpfs_dirent_s));
|
||||
tde = (struct tmpfs_dirent_s *)malloc(sizeof(struct tmpfs_dirent_s));
|
||||
if (tde == NULL)
|
||||
{
|
||||
free(newname);
|
||||
@@ -476,15 +479,15 @@ static int tmpfs_add_dirent(FAR struct tmpfs_directory_s **tdo,
|
||||
* Name: tmpfs_alloc_file
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct tmpfs_file_s *tmpfs_alloc_file(void)
|
||||
static struct tmpfs_file_s *tmpfs_alloc_file(void)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
size_t allocsize;
|
||||
|
||||
/* Create a new zero length file object */
|
||||
|
||||
allocsize = sizeof(struct tmpfs_file_s);
|
||||
tfo = (FAR struct tmpfs_file_s *)kmm_malloc(allocsize);
|
||||
tfo = (struct tmpfs_file_s *)kmm_malloc(allocsize);
|
||||
if (tfo == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -519,15 +522,15 @@ static FAR struct tmpfs_file_s *tmpfs_alloc_file(void)
|
||||
* Name: tmpfs_create_file
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_create_file(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s *parent_input,
|
||||
FAR struct tmpfs_file_s **tfo)
|
||||
static int tmpfs_create_file(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s *parent_input,
|
||||
struct tmpfs_file_s **tfo)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *parent;
|
||||
FAR struct tmpfs_file_s *newtfo;
|
||||
struct tmpfs_directory_s *parent;
|
||||
struct tmpfs_file_s *newtfo;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
FAR char *copy;
|
||||
char *copy;
|
||||
int ret;
|
||||
|
||||
/* Duplicate the path variable so that we can modify it */
|
||||
@@ -544,7 +547,7 @@ static int tmpfs_create_file(FAR struct tmpfs_s *fs,
|
||||
if (parent_input == NULL)
|
||||
{
|
||||
/* No subdirectories... use the root directory */
|
||||
parent = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
parent = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
|
||||
/* Lock the root directory to emulate the behavior of tmpfs_find_directory() */
|
||||
|
||||
@@ -586,7 +589,7 @@ static int tmpfs_create_file(FAR struct tmpfs_s *fs,
|
||||
|
||||
/* Then add the new, empty file to the directory */
|
||||
|
||||
ret = tmpfs_add_dirent(&parent, (FAR struct tmpfs_object_s *)newtfo, copy);
|
||||
ret = tmpfs_add_dirent(&parent, (struct tmpfs_object_s *)newtfo, copy);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_file;
|
||||
@@ -627,13 +630,13 @@ errout_with_copy:
|
||||
* Name: tmpfs_alloc_directory
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct tmpfs_directory_s *tmpfs_alloc_directory(void)
|
||||
static struct tmpfs_directory_s *tmpfs_alloc_directory(void)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
size_t allocsize;
|
||||
|
||||
allocsize = sizeof(struct tmpfs_directory_s);
|
||||
tdo = (FAR struct tmpfs_directory_s *)kmm_malloc(allocsize);
|
||||
tdo = (struct tmpfs_directory_s *)kmm_malloc(allocsize);
|
||||
if (tdo == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -665,15 +668,15 @@ static FAR struct tmpfs_directory_s *tmpfs_alloc_directory(void)
|
||||
* Name: tmpfs_create_directory
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s *parent_input,
|
||||
FAR struct tmpfs_directory_s **tdo)
|
||||
static int tmpfs_create_directory(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s *parent_input,
|
||||
struct tmpfs_directory_s **tdo)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *parent;
|
||||
FAR struct tmpfs_directory_s *newtdo;
|
||||
struct tmpfs_directory_s *parent;
|
||||
struct tmpfs_directory_s *newtdo;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
FAR char *copy;
|
||||
char *copy;
|
||||
int ret;
|
||||
|
||||
/* Duplicate the path variable so that we can modify it */
|
||||
@@ -691,7 +694,7 @@ static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
|
||||
{
|
||||
/* No subdirectories... use the root directory */
|
||||
|
||||
parent = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
parent = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
|
||||
tmpfs_lock_directory(parent);
|
||||
parent->tdo_refs++;
|
||||
@@ -732,7 +735,7 @@ static int tmpfs_create_directory(FAR struct tmpfs_s *fs,
|
||||
|
||||
/* Then add the new, empty file to the directory */
|
||||
|
||||
ret = tmpfs_add_dirent(&parent, (FAR struct tmpfs_object_s *)newtdo, copy);
|
||||
ret = tmpfs_add_dirent(&parent, (struct tmpfs_object_s *)newtdo, copy);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_directory;
|
||||
@@ -779,19 +782,19 @@ errout_with_copy:
|
||||
* Name: tmpfs_find_object
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_find_object(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_object_s **object,
|
||||
FAR struct tmpfs_directory_s **parent)
|
||||
static int tmpfs_find_object(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_object_s **object,
|
||||
struct tmpfs_directory_s **parent)
|
||||
{
|
||||
FAR struct tmpfs_object_s *to = NULL;
|
||||
FAR struct tmpfs_dirent_s *tde;
|
||||
FAR struct tmpfs_directory_s *tdo = NULL;
|
||||
FAR struct tmpfs_directory_s *next_tdo;
|
||||
FAR char *segment;
|
||||
FAR char *next_segment;
|
||||
FAR char *tkptr;
|
||||
FAR char *copy;
|
||||
struct tmpfs_object_s *to = NULL;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
struct tmpfs_directory_s *tdo = NULL;
|
||||
struct tmpfs_directory_s *next_tdo;
|
||||
char *segment;
|
||||
char *next_segment;
|
||||
char *tkptr;
|
||||
char *copy;
|
||||
|
||||
/* Make a copy of the path (so that we can modify it via strtok) */
|
||||
|
||||
@@ -804,7 +807,7 @@ static int tmpfs_find_object(FAR struct tmpfs_s *fs,
|
||||
/* Traverse the file system for any object with the matching name */
|
||||
|
||||
to = fs->tfs_root.tde_object;
|
||||
next_tdo = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
next_tdo = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
tdo = next_tdo;
|
||||
for (segment = strtok_r(copy, "/", &tkptr);
|
||||
segment != NULL;
|
||||
@@ -863,7 +866,7 @@ static int tmpfs_find_object(FAR struct tmpfs_s *fs,
|
||||
* directory of to.
|
||||
*/
|
||||
|
||||
next_tdo = (FAR struct tmpfs_directory_s *)to;
|
||||
next_tdo = (struct tmpfs_directory_s *)to;
|
||||
}
|
||||
|
||||
/* When we exit this loop (successfully), to will point to the TMPFS
|
||||
@@ -914,12 +917,12 @@ static int tmpfs_find_object(FAR struct tmpfs_s *fs,
|
||||
* Name: tmpfs_find_file
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_find_file(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_file_s **tfo,
|
||||
FAR struct tmpfs_directory_s **parent)
|
||||
static int tmpfs_find_file(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_file_s **tfo,
|
||||
struct tmpfs_directory_s **parent)
|
||||
{
|
||||
FAR struct tmpfs_object_s *to;
|
||||
struct tmpfs_object_s *to;
|
||||
int ret;
|
||||
|
||||
/* Find the object at this path. If successful, tmpfs_find_object() will
|
||||
@@ -940,7 +943,7 @@ static int tmpfs_find_file(FAR struct tmpfs_s *fs,
|
||||
|
||||
if (parent)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo = *parent;
|
||||
struct tmpfs_directory_s *tdo = *parent;
|
||||
|
||||
tdo->tdo_refs--;
|
||||
tmpfs_unlock_directory(tdo);
|
||||
@@ -951,7 +954,7 @@ static int tmpfs_find_file(FAR struct tmpfs_s *fs,
|
||||
|
||||
/* Return the verified file object */
|
||||
|
||||
*tfo = (FAR struct tmpfs_file_s *)to;
|
||||
*tfo = (struct tmpfs_file_s *)to;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -961,12 +964,12 @@ static int tmpfs_find_file(FAR struct tmpfs_s *fs,
|
||||
* Name: tmpfs_find_directory
|
||||
****************************************************************************/
|
||||
|
||||
static int tmpfs_find_directory(FAR struct tmpfs_s *fs,
|
||||
FAR const char *relpath,
|
||||
FAR struct tmpfs_directory_s **tdo,
|
||||
FAR struct tmpfs_directory_s **parent)
|
||||
static int tmpfs_find_directory(struct tmpfs_s *fs,
|
||||
const char *relpath,
|
||||
struct tmpfs_directory_s **tdo,
|
||||
struct tmpfs_directory_s **parent)
|
||||
{
|
||||
FAR struct tmpfs_object_s *to;
|
||||
struct tmpfs_object_s *to;
|
||||
int ret;
|
||||
|
||||
/* Find the object at this path */
|
||||
@@ -984,7 +987,7 @@ static int tmpfs_find_directory(FAR struct tmpfs_s *fs,
|
||||
|
||||
if (parent)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tmptdo = *parent;
|
||||
struct tmpfs_directory_s *tmptdo = *parent;
|
||||
|
||||
tmptdo->tdo_refs--;
|
||||
tmpfs_unlock_directory(tmptdo);
|
||||
@@ -995,7 +998,7 @@ static int tmpfs_find_directory(FAR struct tmpfs_s *fs,
|
||||
|
||||
/* Return the verified file object */
|
||||
|
||||
*tdo = (FAR struct tmpfs_directory_s *)to;
|
||||
*tdo = (struct tmpfs_directory_s *)to;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1007,13 +1010,12 @@ static int tmpfs_find_directory(FAR struct tmpfs_s *fs,
|
||||
|
||||
int tmpfs_close(struct file *filep)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
|
||||
finfo("filep: %p\n", filep);
|
||||
DEBUGASSERT(filep != NULL);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
tfo = (FAR struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
tfo = (struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
if (tfo == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
@@ -1058,18 +1060,16 @@ int tmpfs_close(struct file *filep)
|
||||
|
||||
ssize_t tmpfs_read(struct file *filep, char *buffer, size_t buflen)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
ssize_t nread;
|
||||
loff_t startpos;
|
||||
loff_t endpos;
|
||||
|
||||
finfo("filep: %p buffer: %p buflen: %lu\n",
|
||||
filep, buffer, (unsigned long)buflen);
|
||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
tfo = (FAR struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
tfo = (struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
if (tfo == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
@@ -1121,10 +1121,10 @@ ssize_t tmpfs_read(struct file *filep, char *buffer, size_t buflen)
|
||||
int tmpfs_create(struct Vnode *dvp, const char *path, int mode, struct Vnode **vpp)
|
||||
{
|
||||
struct Vnode *vp = NULL;
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
FAR struct tmpfs_s *fs;
|
||||
struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_s *fs;
|
||||
int ret = 0;
|
||||
FAR struct tmpfs_directory_s *parent_tdo = NULL;
|
||||
struct tmpfs_directory_s *parent_tdo = NULL;
|
||||
|
||||
if (dvp == NULL)
|
||||
{
|
||||
@@ -1141,7 +1141,7 @@ int tmpfs_create(struct Vnode *dvp, const char *path, int mode, struct Vnode **v
|
||||
|
||||
if (dvp->data != NULL)
|
||||
{
|
||||
parent_tdo = (FAR struct tmpfs_directory_s *)(dvp->data);
|
||||
parent_tdo = (struct tmpfs_directory_s *)(dvp->data);
|
||||
}
|
||||
|
||||
ret = tmpfs_create_file(fs, path, parent_tdo, &tfo);
|
||||
@@ -1201,7 +1201,7 @@ void los_set_ramfs_unit(off_t size)
|
||||
|
||||
ssize_t tmpfs_write(struct file *filep, const char *buffer, size_t buflen)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
ssize_t nwritten;
|
||||
loff_t startpos;
|
||||
loff_t endpos;
|
||||
@@ -1209,8 +1209,6 @@ ssize_t tmpfs_write(struct file *filep, const char *buffer, size_t buflen)
|
||||
int alloc;
|
||||
char *data;
|
||||
|
||||
finfo("filep: %p buffer: %p buflen: %lu\n",
|
||||
filep, buffer, (unsigned long)buflen);
|
||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
|
||||
|
||||
if (buflen == 0)
|
||||
@@ -1219,7 +1217,7 @@ ssize_t tmpfs_write(struct file *filep, const char *buffer, size_t buflen)
|
||||
}
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
tfo = (FAR struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
tfo = (struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
if (tfo == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
@@ -1297,17 +1295,16 @@ errout_with_lock:
|
||||
* Name: tmpfs_seek
|
||||
****************************************************************************/
|
||||
|
||||
off_t tmpfs_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
off_t tmpfs_seek(struct file *filep, off_t offset, int whence)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
off_t position;
|
||||
|
||||
finfo("filep: %p\n", filep);
|
||||
DEBUGASSERT(filep->f_priv != NULL && filep->f_vnode != NULL);
|
||||
|
||||
/* Recover our private data from the struct file instance */
|
||||
|
||||
tfo = (FAR struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
tfo = (struct tmpfs_file_s *)(filep->f_vnode->data);
|
||||
if (tfo == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
@@ -1355,7 +1352,7 @@ off_t tmpfs_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
* Name: tmpfs_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
int tmpfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
int tmpfs_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1366,12 +1363,11 @@ int tmpfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
int tmpfs_opendir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
int ret = 0;
|
||||
FAR struct fs_tmpfsdir_s *tmp;
|
||||
struct fs_tmpfsdir_s *tmp;
|
||||
|
||||
finfo("vp: %p dir: %p\n", vp, dir);
|
||||
DEBUGASSERT(vp != NULL && dir != NULL);
|
||||
|
||||
/* Get the mountpoint private data from the inode structure */
|
||||
@@ -1379,7 +1375,7 @@ int tmpfs_opendir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
fs = vp->originMount->data;
|
||||
DEBUGASSERT(fs != NULL);
|
||||
|
||||
tmp = (FAR struct fs_tmpfsdir_s *)malloc(sizeof(struct fs_tmpfsdir_s));
|
||||
tmp = (struct fs_tmpfsdir_s *)malloc(sizeof(struct fs_tmpfsdir_s));
|
||||
if (!tmp)
|
||||
{
|
||||
return -ENOSPC;
|
||||
@@ -1398,11 +1394,11 @@ int tmpfs_opendir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
|
||||
if (vp->data != NULL)
|
||||
{
|
||||
tdo = (FAR struct tmpfs_directory_s *)vp->data;
|
||||
tdo = (struct tmpfs_directory_s *)vp->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
tdo = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
tdo = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
}
|
||||
|
||||
if (tdo == NULL)
|
||||
@@ -1430,15 +1426,14 @@ int tmpfs_opendir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
|
||||
int tmpfs_closedir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
struct fs_tmpfsdir_s *tmp;
|
||||
|
||||
finfo("vp: %p dir: %p\n", vp, dir);
|
||||
DEBUGASSERT(vp != NULL && dir != NULL);
|
||||
|
||||
/* Get the directory structure from the dir argument */
|
||||
|
||||
tmp = (FAR struct fs_tmpfsdir_s *)dir->u.fs_dir;
|
||||
tmp = (struct fs_tmpfsdir_s *)dir->u.fs_dir;
|
||||
if (tmp == NULL)
|
||||
{
|
||||
return -ENOENT;
|
||||
@@ -1452,10 +1447,10 @@ int tmpfs_closedir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
if (tdo->tdo_count == 1)
|
||||
{
|
||||
LOS_DL_LIST *node = tdo->tdo_entry.pstNext;
|
||||
FAR struct tmpfs_dirent_s *tde;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
while (node != &tdo->tdo_entry)
|
||||
{
|
||||
tde = (FAR struct tmpfs_dirent_s *)node;
|
||||
tde = (struct tmpfs_dirent_s *)node;
|
||||
node = node->pstNext;
|
||||
if (tde->tde_inuse == false)
|
||||
{
|
||||
@@ -1485,19 +1480,18 @@ int tmpfs_closedir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
|
||||
int tmpfs_readdir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
unsigned int index;
|
||||
int ret;
|
||||
struct fs_tmpfsdir_s *tmp;
|
||||
LOS_DL_LIST *node;
|
||||
FAR struct tmpfs_dirent_s *tde;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
|
||||
finfo("vp: %p dir: %p\n", vp, dir);
|
||||
DEBUGASSERT(vp != NULL && dir != NULL);
|
||||
|
||||
/* Get the directory structure from the dir argument and lock it */
|
||||
|
||||
tmp = (FAR struct fs_tmpfsdir_s *)dir->u.fs_dir;
|
||||
tmp = (struct fs_tmpfsdir_s *)dir->u.fs_dir;
|
||||
if (tmp == NULL)
|
||||
{
|
||||
return -ENOENT;
|
||||
@@ -1523,7 +1517,7 @@ int tmpfs_readdir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
|
||||
while (node != &tdo->tdo_entry)
|
||||
{
|
||||
tde = (FAR struct tmpfs_dirent_s *)node;
|
||||
tde = (struct tmpfs_dirent_s *)node;
|
||||
tmp->tf_index++;
|
||||
if (tde->tde_inuse == true)
|
||||
{
|
||||
@@ -1538,12 +1532,12 @@ int tmpfs_readdir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
* -ENOENT
|
||||
*/
|
||||
|
||||
finfo("End of directory\n");
|
||||
PRINT_INFO("End of directory\n");
|
||||
ret = -ENOENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
FAR struct tmpfs_object_s *to;
|
||||
struct tmpfs_object_s *to;
|
||||
|
||||
/* Does this entry refer to a file or a directory object? */
|
||||
|
||||
@@ -1585,7 +1579,7 @@ int tmpfs_readdir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
int tmpfs_rewinddir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
{
|
||||
struct fs_tmpfsdir_s *tmp;
|
||||
fvdbg("vp: %p dir: %p\n", vp, dir);
|
||||
PRINT_DEBUG("vp: %p dir: %p\n", vp, dir);
|
||||
DEBUGASSERT(vp != NULL && dir != NULL);
|
||||
tmp = (struct fs_tmpfsdir_s *)dir->u.fs_dir;
|
||||
|
||||
@@ -1597,7 +1591,7 @@ int tmpfs_rewinddir(struct Vnode *vp, struct fs_dirent_s *dir)
|
||||
|
||||
int tmpfs_truncate(struct Vnode *vp, off_t len)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo = NULL;
|
||||
struct tmpfs_file_s *tfo = NULL;
|
||||
|
||||
tfo = vp->data;
|
||||
tfo->tfo_size = 0;
|
||||
@@ -1617,8 +1611,8 @@ int tmpfs_truncate(struct Vnode *vp, off_t len)
|
||||
|
||||
int tmpfs_mount(struct Mount *mnt, struct Vnode *device, const void *data)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
FAR struct tmpfs_s *fs = &tmpfs_superblock;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_s *fs = &tmpfs_superblock;
|
||||
struct Vnode *vp = NULL;
|
||||
int ret;
|
||||
|
||||
@@ -1640,7 +1634,7 @@ int tmpfs_mount(struct Mount *mnt, struct Vnode *device, const void *data)
|
||||
}
|
||||
|
||||
LOS_ListInit(&fs->tfs_root.tde_node);
|
||||
fs->tfs_root.tde_object = (FAR struct tmpfs_object_s *)tdo;
|
||||
fs->tfs_root.tde_object = (struct tmpfs_object_s *)tdo;
|
||||
fs->tfs_root.tde_name = NULL;
|
||||
|
||||
/* Set up the backward link (to support reallocation) */
|
||||
@@ -1690,18 +1684,17 @@ ERROR_WITH_FSWIN:
|
||||
|
||||
int tmpfs_unmount(struct Mount *mnt, struct Vnode **blkdriver)
|
||||
{
|
||||
FAR struct tmpfs_s *fs = (FAR struct tmpfs_s *)mnt->data;
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_s *fs = (struct tmpfs_s *)mnt->data;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
int ret = 0;
|
||||
|
||||
finfo("handle: %p blkdriver: %p \n", handle, blkdriver);
|
||||
DEBUGASSERT(fs != NULL && fs->tfs_root.tde_object != NULL);
|
||||
|
||||
/* Lock the file system */
|
||||
|
||||
tmpfs_lock(fs);
|
||||
|
||||
tdo = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
tdo = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
if (tdo == NULL)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
@@ -1737,10 +1730,10 @@ int tmpfs_lookup(struct Vnode *parent, const char *relPath, int len, struct Vnod
|
||||
// 1. when first time create file, lookup fail, then call tmpfs_create.
|
||||
// 2. when ls, lookup will success to show.
|
||||
// 3. when cd, lookup success.
|
||||
FAR struct tmpfs_object_s *to;
|
||||
FAR struct tmpfs_s *fs;
|
||||
struct tmpfs_object_s *to;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_dirent_s *tde = NULL;
|
||||
FAR struct tmpfs_directory_s *parent_tdo;
|
||||
struct tmpfs_directory_s *parent_tdo;
|
||||
|
||||
struct Vnode *vp = NULL;
|
||||
int ret = 0;
|
||||
@@ -1758,7 +1751,7 @@ int tmpfs_lookup(struct Vnode *parent, const char *relPath, int len, struct Vnod
|
||||
|
||||
tmpfs_lock(fs);
|
||||
|
||||
parent_tdo = (FAR struct tmpfs_directory_s *)(parent->data);
|
||||
parent_tdo = (struct tmpfs_directory_s *)(parent->data);
|
||||
|
||||
if (parent_tdo == NULL)
|
||||
{
|
||||
@@ -1856,12 +1849,12 @@ int tmpfs_statfs(struct Mount *mp, struct statfs *sbp)
|
||||
|
||||
int tmpfs_unlink(struct Vnode *parent, struct Vnode *node, const char *relpath)
|
||||
{
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_directory_s *parent_dir;
|
||||
FAR struct tmpfs_file_s *tfo = NULL;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_directory_s *parent_dir;
|
||||
struct tmpfs_file_s *tfo = NULL;
|
||||
int ret;
|
||||
|
||||
finfo("mountpt: %p node: %p relpath: %s\n", parent, node, relpath);
|
||||
PRINT_INFO("mountpt: %p node: %p relpath: %s\n", parent, node, relpath);
|
||||
DEBUGASSERT(parent != NULL && node != NULL && relpath != NULL);
|
||||
|
||||
if (strlen(relpath) == 0)
|
||||
@@ -1892,7 +1885,7 @@ int tmpfs_unlink(struct Vnode *parent, struct Vnode *node, const char *relpath)
|
||||
* and the parent directory and take one reference count on each.
|
||||
*/
|
||||
|
||||
parent_dir = (FAR struct tmpfs_directory_s *)(parent->data);
|
||||
parent_dir = (struct tmpfs_directory_s *)(parent->data);
|
||||
if (parent_dir == NULL)
|
||||
{
|
||||
ret = tmpfs_find_file(fs, relpath, &tfo, &parent_dir);
|
||||
@@ -1903,7 +1896,7 @@ int tmpfs_unlink(struct Vnode *parent, struct Vnode *node, const char *relpath)
|
||||
}
|
||||
else
|
||||
{
|
||||
tfo = (FAR struct tmpfs_file_s *)node->data;
|
||||
tfo = (struct tmpfs_file_s *)node->data;
|
||||
}
|
||||
|
||||
if (tfo == NULL || parent_dir == NULL)
|
||||
@@ -1978,13 +1971,12 @@ errout_with_lock:
|
||||
|
||||
int tmpfs_mkdir(struct Vnode *parent, const char *relpath, mode_t mode, struct Vnode **vpp)
|
||||
{
|
||||
FAR struct tmpfs_s *fs;
|
||||
struct tmpfs_s *fs;
|
||||
struct Vnode *vp = NULL;
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
FAR struct tmpfs_directory_s *parent_tdo = NULL;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_directory_s *parent_tdo = NULL;
|
||||
int ret;
|
||||
|
||||
finfo("parent: %p relpath: %s mode: %04x\n", parent, relpath, mode);
|
||||
DEBUGASSERT(parent != NULL && relpath != NULL);
|
||||
|
||||
if (strlen(relpath) == 0)
|
||||
@@ -2003,7 +1995,7 @@ int tmpfs_mkdir(struct Vnode *parent, const char *relpath, mode_t mode, struct V
|
||||
|
||||
if (parent->data != NULL)
|
||||
{
|
||||
parent_tdo = (FAR struct tmpfs_directory_s *)(parent->data);
|
||||
parent_tdo = (struct tmpfs_directory_s *)(parent->data);
|
||||
}
|
||||
/* Create the directory. */
|
||||
ret = tmpfs_create_directory(fs, relpath, parent_tdo, &tdo);
|
||||
@@ -2043,12 +2035,11 @@ errout_with_lock:
|
||||
|
||||
int tmpfs_rmdir(struct Vnode *parent, struct Vnode *target, const char *dirname)
|
||||
{
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_directory_s *parent_dir;
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_directory_s *parent_dir;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
int ret = 0;
|
||||
|
||||
finfo("parent: %p relpath: %s\n", target, relpath);
|
||||
DEBUGASSERT(parent != NULL && target != NULL && relpath != NULL);
|
||||
|
||||
/* Get the file system structure from the inode reference. */
|
||||
@@ -2068,7 +2059,7 @@ int tmpfs_rmdir(struct Vnode *parent, struct Vnode *target, const char *dirname)
|
||||
* directory object and the parent directory and take one reference count
|
||||
* on each.
|
||||
*/
|
||||
parent_dir = (FAR struct tmpfs_directory_s *)(parent->data);
|
||||
parent_dir = (struct tmpfs_directory_s *)(parent->data);
|
||||
if (parent_dir == NULL)
|
||||
{
|
||||
ret = tmpfs_find_directory(fs, dirname, &tdo, &parent_dir);
|
||||
@@ -2079,7 +2070,7 @@ int tmpfs_rmdir(struct Vnode *parent, struct Vnode *target, const char *dirname)
|
||||
}
|
||||
else
|
||||
{
|
||||
tdo = (FAR struct tmpfs_directory_s *)target->data;
|
||||
tdo = (struct tmpfs_directory_s *)target->data;
|
||||
}
|
||||
|
||||
if (tdo == NULL || tdo->tdo_type != TMPFS_DIRECTORY)
|
||||
@@ -2148,23 +2139,20 @@ errout_with_lock:
|
||||
|
||||
int tmpfs_rename(struct Vnode *oldVnode, struct Vnode *newParent, const char *oldname, const char *newname)
|
||||
{
|
||||
FAR struct tmpfs_directory_s *oldparent;
|
||||
FAR struct tmpfs_directory_s *newparent_tdo;
|
||||
FAR struct tmpfs_object_s *old_to;
|
||||
FAR struct tmpfs_dirent_s *tde;
|
||||
FAR struct tmpfs_directory_s *tdo;
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_s *new_fs;
|
||||
FAR struct Vnode *old_parent_vnode;
|
||||
struct tmpfs_directory_s *oldparent;
|
||||
struct tmpfs_directory_s *newparent_tdo;
|
||||
struct tmpfs_object_s *old_to;
|
||||
struct tmpfs_dirent_s *tde;
|
||||
struct tmpfs_directory_s *tdo;
|
||||
struct tmpfs_file_s *tfo;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_s *new_fs;
|
||||
struct Vnode *old_parent_vnode;
|
||||
|
||||
FAR char *copy;
|
||||
char *copy;
|
||||
int ret = 0;
|
||||
unsigned int oldrelpath_len, newrelpath_len, cmp_namelen;
|
||||
|
||||
finfo("oldParent: %p newParent: %p oldname: %s newname: %s\n",
|
||||
oldParent, newParent, oldname, newname);
|
||||
|
||||
oldrelpath_len = strlen(oldname);
|
||||
newrelpath_len = strlen(newname);
|
||||
|
||||
@@ -2205,11 +2193,11 @@ int tmpfs_rename(struct Vnode *oldVnode, struct Vnode *newParent, const char *ol
|
||||
/* Separate the new path into the new file name and the path to the new
|
||||
* parent directory.
|
||||
*/
|
||||
newparent_tdo = (FAR struct tmpfs_directory_s *)(newParent->data);
|
||||
newparent_tdo = (struct tmpfs_directory_s *)(newParent->data);
|
||||
if (newparent_tdo == NULL)
|
||||
{
|
||||
new_fs = newParent->originMount->data;
|
||||
newparent_tdo = (FAR struct tmpfs_directory_s *)new_fs->tfs_root.tde_object;
|
||||
newparent_tdo = (struct tmpfs_directory_s *)new_fs->tfs_root.tde_object;
|
||||
if (newparent_tdo == NULL)
|
||||
{
|
||||
ret = -ENOTEMPTY;
|
||||
@@ -2224,12 +2212,12 @@ int tmpfs_rename(struct Vnode *oldVnode, struct Vnode *newParent, const char *ol
|
||||
* the reference count on both.
|
||||
*/
|
||||
old_parent_vnode = oldVnode->parent;
|
||||
oldparent = (FAR struct tmpfs_directory_s *)(old_parent_vnode->data);
|
||||
old_to = (FAR struct tmpfs_object_s *)oldVnode->data;
|
||||
oldparent = (struct tmpfs_directory_s *)(old_parent_vnode->data);
|
||||
old_to = (struct tmpfs_object_s *)oldVnode->data;
|
||||
|
||||
if (oldparent == NULL)
|
||||
{
|
||||
oldparent = (FAR struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
oldparent = (struct tmpfs_directory_s *)fs->tfs_root.tde_object;
|
||||
if (oldparent == NULL || old_to == NULL)
|
||||
{
|
||||
ret = -ENOTEMPTY;
|
||||
@@ -2241,7 +2229,7 @@ int tmpfs_rename(struct Vnode *oldVnode, struct Vnode *newParent, const char *ol
|
||||
tde = tmpfs_find_dirent(newparent_tdo, copy);
|
||||
if (tde != NULL)
|
||||
{
|
||||
FAR struct tmpfs_object_s *new_to = tde->tde_object;
|
||||
struct tmpfs_object_s *new_to = tde->tde_object;
|
||||
|
||||
/* Cannot rename a directory to a noempty directory */
|
||||
|
||||
@@ -2361,8 +2349,8 @@ errout_with_lock:
|
||||
* Name: tmpfs_stat_common
|
||||
****************************************************************************/
|
||||
|
||||
static void tmpfs_stat_common(FAR struct tmpfs_object_s *to,
|
||||
FAR struct stat *buf)
|
||||
static void tmpfs_stat_common(struct tmpfs_object_s *to,
|
||||
struct stat *buf)
|
||||
{
|
||||
size_t objsize;
|
||||
|
||||
@@ -2372,8 +2360,8 @@ static void tmpfs_stat_common(FAR struct tmpfs_object_s *to,
|
||||
|
||||
if (to->to_type == TMPFS_REGULAR)
|
||||
{
|
||||
FAR struct tmpfs_file_s *tfo =
|
||||
(FAR struct tmpfs_file_s *)to;
|
||||
struct tmpfs_file_s *tfo =
|
||||
(struct tmpfs_file_s *)to;
|
||||
|
||||
/* -rwxrwxrwx */
|
||||
|
||||
@@ -2386,8 +2374,8 @@ static void tmpfs_stat_common(FAR struct tmpfs_object_s *to,
|
||||
}
|
||||
else /* if (to->to_type == TMPFS_DIRECTORY) */
|
||||
{
|
||||
FAR struct tmpfs_directory_s *tdo =
|
||||
(FAR struct tmpfs_directory_s *)to;
|
||||
struct tmpfs_directory_s *tdo =
|
||||
(struct tmpfs_directory_s *)to;
|
||||
|
||||
/* drwxrwxrwx */
|
||||
|
||||
@@ -2415,11 +2403,10 @@ static void tmpfs_stat_common(FAR struct tmpfs_object_s *to,
|
||||
|
||||
int tmpfs_stat(struct Vnode *vp, struct stat *st)
|
||||
{
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_object_s *to;
|
||||
struct tmpfs_s *fs;
|
||||
struct tmpfs_object_s *to;
|
||||
int ret;
|
||||
|
||||
finfo("vp=%p st=%p\n", vp, st);
|
||||
DEBUGASSERT(vp != NULL && st != NULL);
|
||||
/* Get the file system structure from the inode reference. */
|
||||
|
||||
@@ -2436,7 +2423,7 @@ int tmpfs_stat(struct Vnode *vp, struct stat *st)
|
||||
*/
|
||||
if (vp->data != NULL)
|
||||
{
|
||||
to = (FAR struct tmpfs_object_s *)vp->data;
|
||||
to = (struct tmpfs_object_s *)vp->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+8
-9
@@ -41,7 +41,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <semaphore.h>
|
||||
#include "fs/fs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -98,8 +97,8 @@ struct tmpfs_sem_s
|
||||
struct tmpfs_dirent_s
|
||||
{
|
||||
LOS_DL_LIST tde_node;
|
||||
FAR struct tmpfs_object_s *tde_object;
|
||||
FAR char *tde_name;
|
||||
struct tmpfs_object_s *tde_object;
|
||||
char *tde_name;
|
||||
bool tde_inuse;
|
||||
};
|
||||
|
||||
@@ -107,7 +106,7 @@ struct tmpfs_dirent_s
|
||||
|
||||
struct tmpfs_object_s
|
||||
{
|
||||
FAR struct tmpfs_dirent_s *to_dirent;
|
||||
struct tmpfs_dirent_s *to_dirent;
|
||||
struct tmpfs_sem_s to_exclsem;
|
||||
|
||||
uint8_t to_type; /* See enum tmpfs_objtype_e */
|
||||
@@ -127,7 +126,7 @@ struct tmpfs_directory_s
|
||||
{
|
||||
/* First fields must match common TMPFS object layout */
|
||||
|
||||
FAR struct tmpfs_dirent_s *tdo_dirent;
|
||||
struct tmpfs_dirent_s *tdo_dirent;
|
||||
struct tmpfs_sem_s tdo_exclsem;
|
||||
|
||||
uint8_t tdo_type; /* See enum tmpfs_objtype_e */
|
||||
@@ -162,7 +161,7 @@ struct tmpfs_file_s
|
||||
{
|
||||
/* First fields must match common TMPFS object layout */
|
||||
|
||||
FAR struct tmpfs_dirent_s *tfo_dirent;
|
||||
struct tmpfs_dirent_s *tfo_dirent;
|
||||
struct tmpfs_sem_s tfo_exclsem;
|
||||
|
||||
uint8_t tfo_type; /* See enum tmpfs_objtype_e */
|
||||
@@ -189,7 +188,7 @@ struct tmpfs_file_s
|
||||
struct tmpfs_s
|
||||
{
|
||||
/* The root directory */
|
||||
FAR struct tmpfs_dirent_s tfs_root;
|
||||
struct tmpfs_dirent_s tfs_root;
|
||||
struct tmpfs_sem_s tfs_exclsem;
|
||||
};
|
||||
|
||||
@@ -205,8 +204,8 @@ struct tmpfs_statfs_s
|
||||
|
||||
/* This is the type of the for tmpfs_foreach callback */
|
||||
|
||||
typedef int (*tmpfs_foreach_t)(FAR struct tmpfs_directory_s *tdo,
|
||||
unsigned int index, FAR void *arg);
|
||||
typedef int (*tmpfs_foreach_t)(struct tmpfs_directory_s *tdo,
|
||||
unsigned int index, void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
||||
+2
-2
@@ -42,13 +42,13 @@
|
||||
#include "errno.h"
|
||||
#include "unistd.h"
|
||||
#include "sched.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#if defined(LOSCFG_NET_LWIP_SACK)
|
||||
# include "net/net.h"
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
|
||||
#include "mqueue.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
+4
-3
@@ -43,9 +43,10 @@
|
||||
#include "unistd.h"
|
||||
#include "sched.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "net/net.h"
|
||||
#include "vnode.h"
|
||||
#if defined(LOSCFG_NET_LWIP_SACK)
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
#include "errno.h"
|
||||
#include "unistd.h"
|
||||
#include "sched.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/* This logic in this applies only when both socket and file descriptors are
|
||||
* in that case, this function descriminates which type of dup2 is being
|
||||
|
||||
+1
-2
@@ -44,10 +44,9 @@
|
||||
#include "errno.h"
|
||||
#include "sched.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
#include "unistd.h"
|
||||
#include "sched.h"
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
|
||||
+1
-2
@@ -44,8 +44,7 @@
|
||||
#include "fcntl.h"
|
||||
#include "errno.h"
|
||||
#include "assert.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#if defined(LOSCFG_NET_LWIP_SACK)
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
+1
-2
@@ -45,10 +45,9 @@
|
||||
#include "errno.h"
|
||||
#include "assert.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "console.h"
|
||||
#include "sched.h"
|
||||
#include "sys/types.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "vfs_config.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+2
-2
@@ -46,10 +46,10 @@
|
||||
#include "console.h"
|
||||
|
||||
#if defined(LOSCFG_NET_LWIP_SACK)
|
||||
# include "net/net.h"
|
||||
#include "lwip/sockets.h"
|
||||
#endif
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
+3
-2
@@ -30,7 +30,8 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "path_cache.h"
|
||||
|
||||
int do_link(int oldfd, const char *oldpath, int newfd, const char *newpath, int flag)
|
||||
{
|
||||
@@ -147,4 +148,4 @@ int link(const char *oldpath, const char *newpath)
|
||||
int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags)
|
||||
{
|
||||
return do_link(olddirfd, oldpath, newdirfd, newpath, flags);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
#include "sched.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
#include "sched.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
||||
|
||||
+2
-5
@@ -41,14 +41,11 @@
|
||||
#include "errno.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/stat.h"
|
||||
#include "fs/fs.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "string.h"
|
||||
#include "fs_other.h"
|
||||
#include "capability_api.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "fs/vfs_util.h"
|
||||
#include "path_cache.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
+3
-6
@@ -49,12 +49,9 @@
|
||||
#include "stdarg.h"
|
||||
#endif
|
||||
#include "stdlib.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "driver/blockproxy.h"
|
||||
#include "fs_other.h"
|
||||
#include "fs/vfs_util.h"
|
||||
#include "fs/path_cache.h"
|
||||
#include "vnode.h"
|
||||
#include "blockproxy.h"
|
||||
#include "path_cache.h"
|
||||
#include "unistd.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+1
-3
@@ -43,9 +43,7 @@
|
||||
#include "poll.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "debug.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "console.h"
|
||||
|
||||
+3
-4
@@ -43,7 +43,6 @@
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -60,7 +59,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t file_pread(FAR struct file *filep, FAR void *buf, size_t nbytes,
|
||||
ssize_t file_pread(struct file *filep, void *buf, size_t nbytes,
|
||||
off_t offset)
|
||||
{
|
||||
off_t savepos;
|
||||
@@ -141,9 +140,9 @@ ssize_t file_pread(FAR struct file *filep, FAR void *buf, size_t nbytes,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset)
|
||||
ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset)
|
||||
{
|
||||
FAR struct file *filep;
|
||||
struct file *filep;
|
||||
|
||||
/* Get the file structure corresponding to the file descriptor. */
|
||||
|
||||
|
||||
+2
-3
@@ -43,7 +43,6 @@
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -60,7 +59,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t file_pread64(FAR struct file *filep, FAR void *buf, size_t nbytes,
|
||||
ssize_t file_pread64(struct file *filep, void *buf, size_t nbytes,
|
||||
off64_t offset)
|
||||
{
|
||||
off64_t savepos;
|
||||
@@ -143,7 +142,7 @@ ssize_t file_pread64(FAR struct file *filep, FAR void *buf, size_t nbytes,
|
||||
|
||||
ssize_t pread64(int fd, void *buf, size_t nbytes, off64_t offset)
|
||||
{
|
||||
FAR struct file *filep;
|
||||
struct file *filep;
|
||||
|
||||
/* Get the file structure corresponding to the file descriptor. */
|
||||
|
||||
|
||||
+3
-4
@@ -43,7 +43,6 @@
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -60,7 +59,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t file_pwrite(FAR struct file *filep, FAR const void *buf,
|
||||
ssize_t file_pwrite(struct file *filep, const void *buf,
|
||||
size_t nbytes, off_t offset)
|
||||
{
|
||||
off_t savepos;
|
||||
@@ -145,9 +144,9 @@ ssize_t file_pwrite(FAR struct file *filep, FAR const void *buf,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset)
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset)
|
||||
{
|
||||
FAR struct file *filep;
|
||||
struct file *filep;
|
||||
|
||||
/* Get the file structure corresponding to the file descriptor. */
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -60,7 +59,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t file_pwrite64(FAR struct file *filep, FAR const void *buf,
|
||||
static ssize_t file_pwrite64(struct file *filep, const void *buf,
|
||||
size_t nbytes, off64_t offset)
|
||||
{
|
||||
off64_t savepos;
|
||||
@@ -145,9 +144,9 @@ static ssize_t file_pwrite64(FAR struct file *filep, FAR const void *buf,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t pwrite64(int fd, FAR const void *buf, size_t nbytes, off64_t offset)
|
||||
ssize_t pwrite64(int fd, const void *buf, size_t nbytes, off64_t offset)
|
||||
{
|
||||
FAR struct file *filep;
|
||||
struct file *filep;
|
||||
|
||||
/* Get the file structure corresponding to the file descriptor. */
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "user_copy.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
ssize_t do_readlink(int dirfd, const char *path, char *buf, size_t bufsize)
|
||||
{
|
||||
|
||||
+2
-3
@@ -42,12 +42,11 @@
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs_other.h"
|
||||
#include "vnode.h"
|
||||
#include "limits.h"
|
||||
#include "fs/fs_operation.h"
|
||||
#include "path_cache.h"
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
+1
-3
@@ -41,12 +41,10 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "sys/stat.h"
|
||||
#include "string.h"
|
||||
#include "fs_other.h"
|
||||
#include "limits.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -46,10 +46,8 @@
|
||||
#include "poll.h"
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#include "los_signal.h"
|
||||
#include "los_syscall.h"
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <fs/fs.h>
|
||||
|
||||
#ifndef CONFIG_LIB_SENDFILE_BUFSIZE
|
||||
# define CONFIG_LIB_SENDFILE_BUFSIZE 512
|
||||
@@ -103,8 +102,8 @@
|
||||
|
||||
ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
|
||||
{
|
||||
FAR uint8_t *iobuffer;
|
||||
FAR uint8_t *wrbuffer;
|
||||
uint8_t *iobuffer;
|
||||
uint8_t *wrbuffer;
|
||||
off_t startpos = 0;
|
||||
ssize_t nbytesread;
|
||||
ssize_t nbyteswritten;
|
||||
@@ -133,7 +132,7 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
|
||||
|
||||
/* Allocate an I/O buffer */
|
||||
|
||||
iobuffer = (FAR void *)malloc(CONFIG_LIB_SENDFILE_BUFSIZE);
|
||||
iobuffer = (void *)malloc(CONFIG_LIB_SENDFILE_BUFSIZE);
|
||||
if (!iobuffer)
|
||||
{
|
||||
set_errno(ENOMEM);
|
||||
|
||||
+1
-2
@@ -43,8 +43,7 @@
|
||||
#include "sys/stat.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "fs_other.h"
|
||||
#include "vnode.h"
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
+2
-1
@@ -42,7 +42,8 @@
|
||||
#include "sys/statfs.h"
|
||||
#include "string.h"
|
||||
#include "sched.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "fs/mount.h"
|
||||
#include "errno.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "path_cache.h"
|
||||
|
||||
int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **fullpath)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_truncate
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "assert.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_truncate
|
||||
|
||||
+1
-3
@@ -41,12 +41,10 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fcntl.h"
|
||||
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
#include "stdlib.h"
|
||||
#include "fs_other.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
#include "sys/socket.h"
|
||||
#include "console.h"
|
||||
#include "user_copy.h"
|
||||
#include "fs/vnode.h"
|
||||
#include "vnode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
-179
@@ -1,179 +0,0 @@
|
||||
/****************************************************************************
|
||||
* include/debug.h
|
||||
*
|
||||
* Copyright (C) 2007-2011, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_DEBUG_H
|
||||
#define __INCLUDE_DEBUG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "vfs_config.h"
|
||||
#include "compiler.h"
|
||||
#include "syslog.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Debug macros to runtime filter the debug messages sent to the console. In
|
||||
* general, there are four forms of the debug macros:
|
||||
*
|
||||
* [a-z]dbg() -- Outputs messages to the console similar to printf() except
|
||||
* that the output is not buffered. The first character indicates the
|
||||
* system system (e.g., n=network, f=filesystm, etc.). If the first
|
||||
* character is missing (i.e., dbg()), then it is common. The common
|
||||
* dbg() macro is enabled by CONFIG_DEBUG. Subsystem debug requires an
|
||||
* additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET
|
||||
* for the network, CONFIG_DEBUG_FS for the file system, etc).
|
||||
*
|
||||
* In general, error messages and output of importance use [a-z]dbg().
|
||||
* [a-z]dbg() is implementation dependent but usually uses file descriptors.
|
||||
* (that is a problem only because the interrupt task may have re-
|
||||
* directed stdout). Therefore [a-z]dbg() should not be used in interrupt
|
||||
* handlers.
|
||||
*
|
||||
* [a-z]vdbg() -- Identical to [a-z]dbg() except that it also requires that
|
||||
* CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug
|
||||
* output that you would normally want to suppress.
|
||||
*
|
||||
* [a-z]lldbg() -- Identical to [a-z]dbg() except this is uses special
|
||||
* interfaces provided by architecture-specific logic to talk directly
|
||||
* to the underlying console hardware. If the architecture provides such
|
||||
* logic, it should define CONFIG_ARCH_LOWPUTC.
|
||||
*
|
||||
* [a-z]lldbg() should not be used in normal code because the implementation
|
||||
* probably disables interrupts and does things that are not consistent with
|
||||
* good real-time performance. However, [a-z]lldbg() is particularly useful
|
||||
* in low-level code where it is inappropriate to use file descriptors. For
|
||||
* example, only [a-z]lldbg() should be used in interrupt handlers.
|
||||
*
|
||||
* [a-z]llvdbg() -- Identical to [a-z]lldbg() except that it also requires that
|
||||
* CONFIG_DEBUG_VERBOSE be defined. This is intended for general debug
|
||||
* output that you would normally want to suppress.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HAVE_FUNCTIONNAME
|
||||
# define EXTRA_FMT "%s: "
|
||||
# define EXTRA_ARG ,__FUNCTION__
|
||||
#else
|
||||
# define EXTRA_FMT
|
||||
# define EXTRA_ARG
|
||||
#endif
|
||||
|
||||
/* Debug macros will differ depending upon if the toolchain supports
|
||||
* macros with a variable number of arguments or not.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
|
||||
/* C-99 style variadic macros are supported */
|
||||
|
||||
/* The actual logger function may be overridden in arch/debug.h if needed.
|
||||
* (Currently only if the pre-processor supports variadic macros)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
# define dbg(format, ...) \
|
||||
syslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||
|
||||
# ifdef CONFIG_ARCH_LOWPUTC
|
||||
# define lldbg(format, ...) \
|
||||
lowsyslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||
# else
|
||||
# define lldbg(x...)
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define vdbg(format, ...) \
|
||||
syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||
|
||||
# ifdef CONFIG_ARCH_LOWPUTC
|
||||
# define llvdbg(format, ...) \
|
||||
lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||
# else
|
||||
# define llvdbg(x...)
|
||||
# endif
|
||||
|
||||
# else
|
||||
# define vdbg(x...)
|
||||
# define llvdbg(x...)
|
||||
# endif
|
||||
|
||||
#else /* CONFIG_DEBUG */
|
||||
|
||||
# define dbg(x...)
|
||||
# define lldbg(x...)
|
||||
# define vdbg(x...)
|
||||
# define llvdbg(x...)
|
||||
|
||||
#endif /* CONFIG_DEBUG */
|
||||
|
||||
/* Subsystem specific debug */
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
# define fdbg(format, ...) dbg(format, ##__VA_ARGS__)
|
||||
# define flldbg(format, ...) lldbg(format, ##__VA_ARGS__)
|
||||
# define fvdbg(format, ...) vdbg(format, ##__VA_ARGS__)
|
||||
# define fllvdbg(format, ...) llvdbg(format, ##__VA_ARGS__)
|
||||
# define finfo(format, ...) vdbg(format, ##__VA_ARGS__)
|
||||
# define ferr(format, ...) dbg(format, ##__VA_ARGS__)
|
||||
# define fwarn(format, ...) dbg(format, ##__VA_ARGS__)
|
||||
#else
|
||||
# define fdbg(x...)
|
||||
# define flldbg(x...)
|
||||
# define fvdbg(x...)
|
||||
# define fllvdbg(x...)
|
||||
# define finfo(x...)
|
||||
# define ferr(x...)
|
||||
# define fwarn(x...)
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_CPP_HAVE_VARARGS */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __INCLUDE_DEBUG_H */
|
||||
@@ -1,696 +0,0 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/compiler.h
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012-2013, 2015-2017 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_COMPILER_H
|
||||
#define __INCLUDE_NUTTX_COMPILER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* GCC-specific definitions *************************************************/
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/* Pre-processor */
|
||||
|
||||
# define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */
|
||||
# define CONFIG_CPP_HAVE_WARNING 1 /* Supports #warning */
|
||||
|
||||
/* Intriniscs. GCC supports __func__ but provides __FUNCTION__ for backward
|
||||
* compatibility with older versions of GCC.
|
||||
*/
|
||||
|
||||
# define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */
|
||||
# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
/* Built-in functions */
|
||||
|
||||
/* GCC 4.x have __builtin_ctz(|l|ll) and __builtin_clz(|l|ll). These count
|
||||
* trailing/leading zeros of input number and typically will generate few
|
||||
* fast bit-counting instructions. Inputting zero to these functions is
|
||||
* undefined and needs to be taken care of by the caller. */
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
# define CONFIG_HAVE_BUILTIN_CTZ 1
|
||||
# define CONFIG_HAVE_BUILTIN_CLZ 1
|
||||
#endif
|
||||
|
||||
/* C++ support */
|
||||
|
||||
#if defined(__cplusplus) && __cplusplus >= 201402L
|
||||
# define CONFIG_HAVE_CXX14 1
|
||||
#else
|
||||
# undef CONFIG_HAVE_CXX14
|
||||
#endif
|
||||
|
||||
/* Attributes
|
||||
*
|
||||
* GCC supports weak symbols which can be used to reduce code size because
|
||||
* unnecessary "weak" functions can be excluded from the link.
|
||||
*/
|
||||
|
||||
# if !defined(__CYGWIN__) && !defined(CONFIG_ARCH_GNU_NO_WEAKFUNCTIONS)
|
||||
# define CONFIG_HAVE_WEAKFUNCTIONS 1
|
||||
# ifndef weak_alias
|
||||
# define weak_alias(name, aliasname) \
|
||||
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
|
||||
# endif
|
||||
# define weak_function __attribute__ ((weak))
|
||||
# define weak_const_function __attribute__ ((weak, __const__))
|
||||
# else
|
||||
# undef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
# define weak_alias(name, aliasname)
|
||||
# define weak_function
|
||||
# define weak_const_function
|
||||
# endif
|
||||
|
||||
/* The noreturn attribute informs GCC that the function will not return.
|
||||
* C11 adds _Noreturn keyword (see stdnoreturn.h)
|
||||
*/
|
||||
|
||||
# define noreturn_function __attribute__ ((noreturn))
|
||||
|
||||
/* The farcall_function attribute informs GCC that is should use long calls
|
||||
* (even though -mlong-calls does not appear in the compilation options)
|
||||
*/
|
||||
|
||||
# define farcall_function __attribute__ ((long_call))
|
||||
|
||||
/* Data alignment */
|
||||
|
||||
# define aligned_data(n) __attribute__ ((aligned(n)))
|
||||
|
||||
/* The packed attribute informs GCC that the structure elements are packed,
|
||||
* ignoring other alignment rules.
|
||||
*/
|
||||
|
||||
# define begin_packed_struct
|
||||
# define end_packed_struct __attribute__ ((packed))
|
||||
|
||||
/* GCC does not support the reentrant attribute */
|
||||
|
||||
# define reentrant_function
|
||||
|
||||
/* The naked attribute informs GCC that the programmer will take care of
|
||||
* the function prolog and epilog.
|
||||
*/
|
||||
|
||||
# define naked_function __attribute__ ((naked,no_instrument_function))
|
||||
|
||||
/* The inline_function attribute informs GCC that the function should always
|
||||
* be inlined, regardless of the level of optimization. The noinline_function
|
||||
* indicates that the function should never be inlined.
|
||||
*/
|
||||
|
||||
# define inline_function __attribute__ ((always_inline,no_instrument_function))
|
||||
# define noinline_function __attribute__ ((noinline))
|
||||
|
||||
/* GCC does not use storage classes to qualify addressing */
|
||||
|
||||
# define FAR
|
||||
# define NEAR
|
||||
# define DSEG
|
||||
# define CODE
|
||||
|
||||
/* Handle cases where sizeof(int) is 16-bits, sizeof(long) is 32-bits, and
|
||||
* pointers are 16-bits.
|
||||
*/
|
||||
|
||||
#if defined(__m32c__)
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
/* Select the small, 16-bit addressing model */
|
||||
|
||||
# define CONFIG_SMALL_MEMORY 1
|
||||
|
||||
/* Long and int are not the same size */
|
||||
|
||||
# define CONFIG_LONG_IS_NOT_INT 1
|
||||
|
||||
/* Pointers and int are the same size */
|
||||
|
||||
# undef CONFIG_PTR_IS_NOT_INT
|
||||
|
||||
#elif defined(__AVR__)
|
||||
# if defined(CONFIG_AVR_HAS_MEMX_PTR)
|
||||
/* I-space access qualifiers needed by Harvard architecture */
|
||||
|
||||
# define IOBJ __flash
|
||||
# define IPTR __memx
|
||||
|
||||
# else
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
# endif
|
||||
|
||||
/* Select the small, 16-bit addressing model (for D-Space) */
|
||||
|
||||
# define CONFIG_SMALL_MEMORY 1
|
||||
|
||||
/* Long and int are not the same size */
|
||||
|
||||
# define CONFIG_LONG_IS_NOT_INT 1
|
||||
|
||||
/* Pointers and int are the same size */
|
||||
|
||||
# undef CONFIG_PTR_IS_NOT_INT
|
||||
|
||||
/* Uses a 32-bit FAR pointer only from accessing data outside of the 16-bit
|
||||
* data space.
|
||||
*/
|
||||
|
||||
# define CONFIG_HAVE_FARPOINTER 1
|
||||
|
||||
#elif defined(__mc68hc1x__)
|
||||
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
/* Select the small, 16-bit addressing model */
|
||||
|
||||
# define CONFIG_SMALL_MEMORY 1
|
||||
|
||||
/* Normally, mc68hc1x code is compiled with the -mshort option
|
||||
* which results in a 16-bit integer. If -mnoshort is defined
|
||||
* then an integer is 32-bits. GCC will defined __INT__ accordingly:
|
||||
*/
|
||||
|
||||
# if __INT__ == 16
|
||||
/* int is 16-bits, long is 32-bits */
|
||||
|
||||
# define CONFIG_LONG_IS_NOT_INT 1
|
||||
|
||||
/* Pointers and int are the same size (16-bits) */
|
||||
|
||||
# undef CONFIG_PTR_IS_NOT_INT
|
||||
# else
|
||||
/* int and long are both 32-bits */
|
||||
|
||||
# undef CONFIG_LONG_IS_NOT_INT
|
||||
|
||||
/* Pointers and int are NOT the same size */
|
||||
|
||||
# define CONFIG_PTR_IS_NOT_INT 1
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
/* Select the large, 32-bit addressing model */
|
||||
|
||||
# undef CONFIG_SMALL_MEMORY
|
||||
|
||||
/* Long and int are (probably) the same size (32-bits) */
|
||||
|
||||
# undef CONFIG_LONG_IS_NOT_INT
|
||||
|
||||
/* Pointers and int are the same size (32-bits) */
|
||||
|
||||
# undef CONFIG_PTR_IS_NOT_INT
|
||||
#endif
|
||||
|
||||
/* GCC supports inlined functions for C++ and for C version C99 and above */
|
||||
|
||||
# if defined(__cplusplus) || !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199901L
|
||||
# define CONFIG_HAVE_INLINE 1
|
||||
# else
|
||||
# undef CONFIG_HAVE_INLINE
|
||||
# define inline
|
||||
# endif
|
||||
|
||||
/* ISO C11 supports anonymous (unnamed) structures and unions, added in
|
||||
* GCC 4.6 (but might be suppressed with -std= option). ISO C++11 also
|
||||
* adds un-named unions, but NOT unnamed structures (although compilers
|
||||
* may support them).
|
||||
*
|
||||
* CAREFUL: This can cause issues for shared data structures shared between
|
||||
* C and C++ if the two versions do not support the same features. Structures
|
||||
* and unions can lose binary compatibility!
|
||||
*
|
||||
* NOTE: The NuttX coding standard forbids the use of unnamed structures and
|
||||
* unions within the OS.
|
||||
*/
|
||||
|
||||
# undef CONFIG_HAVE_ANONYMOUS_STRUCT
|
||||
# undef CONFIG_HAVE_ANONYMOUS_UNION
|
||||
|
||||
# if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||
# define CONFIG_HAVE_ANONYMOUS_STRUCT 1
|
||||
# define CONFIG_HAVE_ANONYMOUS_UNION 1
|
||||
# endif
|
||||
|
||||
/* GCC supports both types double and long long */
|
||||
|
||||
# ifndef __clang__
|
||||
# define CONFIG_HAVE_LONG_LONG 1
|
||||
# endif
|
||||
# define CONFIG_HAVE_FLOAT 1
|
||||
# define CONFIG_HAVE_DOUBLE 1
|
||||
# define CONFIG_HAVE_LONG_DOUBLE 1
|
||||
|
||||
/* Structures and unions can be assigned and passed as values */
|
||||
|
||||
# define CONFIG_CAN_PASS_STRUCTS 1
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
/* SDCC-specific definitions ************************************************/
|
||||
|
||||
#elif defined(SDCC) || defined(__SDCC)
|
||||
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
/* Pre-processor */
|
||||
|
||||
# define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */
|
||||
# define CONFIG_CPP_HAVE_WARNING 1 /* Supports #warning */
|
||||
|
||||
/* Intriniscs */
|
||||
|
||||
# define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */
|
||||
# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */
|
||||
# define __FUNCTION__ __func__ /* SDCC supports on __func__ */
|
||||
|
||||
/* Pragmas
|
||||
*
|
||||
* Disable warnings for unused function arguments */
|
||||
|
||||
# pragma disable_warning 85
|
||||
|
||||
/* C++ support */
|
||||
|
||||
# undef CONFIG_HAVE_CXX14
|
||||
|
||||
/* Attributes
|
||||
*
|
||||
* SDCC does not support weak symbols */
|
||||
|
||||
# undef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
# ifndef weak_alias
|
||||
# define weak_alias(name, aliasname)
|
||||
# endif
|
||||
# define weak_function
|
||||
# define weak_const_function
|
||||
# define restrict /* REVISIT */
|
||||
|
||||
/* SDCC does not support the noreturn or packed attributes */
|
||||
/* Current SDCC supports noreturn via C11 _Noreturn keyword (see
|
||||
* stdnoreturn.h).
|
||||
*/
|
||||
|
||||
# define noreturn_function
|
||||
# define aligned_data(n)
|
||||
# define begin_packed_struct
|
||||
# define end_packed_struct
|
||||
|
||||
/* REVISIT: */
|
||||
|
||||
# define farcall_function
|
||||
|
||||
/* SDCC does support "naked" functions */
|
||||
|
||||
# define naked_function __naked
|
||||
|
||||
/* SDCC does not support forced inlining. */
|
||||
|
||||
# define inline_function
|
||||
# define noinline_function
|
||||
|
||||
/* The reentrant attribute informs SDCC that the function
|
||||
* must be reentrant. In this case, SDCC will store input
|
||||
* arguments on the stack to support reentrancy.
|
||||
*
|
||||
* SDCC functions are always reentrant (except for the mcs51,
|
||||
* ds390, hc08 and s08 backends)
|
||||
*/
|
||||
|
||||
# define reentrant_function __reentrant
|
||||
|
||||
/* ISO C11 supports anonymous (unnamed) structures and unions. Does SDCC? */
|
||||
|
||||
# undef CONFIG_HAVE_ANONYMOUS_STRUCT
|
||||
# undef CONFIG_HAVE_ANONYMOUS_UNION
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
/* It is assumed that the system is build using the small
|
||||
* data model with storage defaulting to internal RAM.
|
||||
* The NEAR storage class can also be used to address data
|
||||
* in internal RAM; FAR can be used to address data in
|
||||
* external RAM.
|
||||
*/
|
||||
|
||||
#if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_gbz80)
|
||||
# define FAR
|
||||
# define NEAR
|
||||
# define CODE
|
||||
# define DSEG
|
||||
#else
|
||||
# define FAR __xdata
|
||||
# define NEAR __data
|
||||
# define CODE __code
|
||||
# if defined(SDCC_MODEL_SMALL)
|
||||
# define DSEG __data
|
||||
# else
|
||||
# define DSEG __xdata
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Select small, 16-bit address model */
|
||||
|
||||
# define CONFIG_SMALL_MEMORY 1
|
||||
|
||||
/* Long and int are not the same size */
|
||||
|
||||
# define CONFIG_LONG_IS_NOT_INT 1
|
||||
|
||||
/* The generic pointer and int are not the same size (for some SDCC
|
||||
* architectures). REVISIT: SDCC now has more backends where pointers are
|
||||
* the same size as int than just z80 and z180.
|
||||
*/
|
||||
|
||||
#if !defined(__z80) && !defined(__gbz80)
|
||||
# define CONFIG_PTR_IS_NOT_INT 1
|
||||
#endif
|
||||
|
||||
/* New versions of SDCC supports inline function */
|
||||
|
||||
# define CONFIG_HAVE_INLINE 1
|
||||
|
||||
/* SDCC does types long long and float, but not types double and long
|
||||
* double.
|
||||
*/
|
||||
|
||||
# define CONFIG_HAVE_LONG_LONG 1
|
||||
# define CONFIG_HAVE_FLOAT 1
|
||||
# undef CONFIG_HAVE_DOUBLE
|
||||
# undef CONFIG_HAVE_LONG_DOUBLE
|
||||
|
||||
/* Structures and unions cannot be passed as values or used
|
||||
* in assignments.
|
||||
*/
|
||||
|
||||
# undef CONFIG_CAN_PASS_STRUCTS
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
/* Zilog-specific definitions ***********************************************/
|
||||
|
||||
#elif defined(__ZILOG__)
|
||||
|
||||
/* At present, only the following Zilog compilers are recognized */
|
||||
|
||||
# if !defined(__ZNEO__) && !defined(__EZ8__) && !defined(__EZ80__)
|
||||
# warning "Unrecognized Zilog compiler"
|
||||
# endif
|
||||
|
||||
/* Pre-processor */
|
||||
|
||||
# undef CONFIG_CPP_HAVE_VARARGS /* No variable argument macros */
|
||||
# undef CONFIG_CPP_HAVE_WARNING /* Does not support #warning */
|
||||
|
||||
/* Intrinsics */
|
||||
|
||||
# define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */
|
||||
# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */
|
||||
|
||||
/* No I-space access qualifiers */
|
||||
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
/* C++ support */
|
||||
|
||||
# undef CONFIG_HAVE_CXX14
|
||||
|
||||
/* Attributes
|
||||
*
|
||||
* The Zilog compiler does not support weak symbols
|
||||
*/
|
||||
|
||||
# undef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
# ifndef weak_alias
|
||||
# define weak_alias(name, aliasname)
|
||||
# endif
|
||||
# define weak_function
|
||||
# define weak_const_function
|
||||
# define restrict
|
||||
|
||||
/* The Zilog compiler does not support the noreturn, packed, naked
|
||||
* attributes.
|
||||
*/
|
||||
|
||||
# define noreturn_function
|
||||
# define aligned_data(n)
|
||||
# define begin_packed_struct
|
||||
# define end_packed_struct
|
||||
# define naked_function
|
||||
# define inline_function
|
||||
# define noinline_function
|
||||
|
||||
/* REVISIT: */
|
||||
|
||||
# define farcall_function
|
||||
|
||||
/* The Zilog compiler does not support the reentrant attribute */
|
||||
|
||||
# define reentrant_function
|
||||
|
||||
/* Addressing.
|
||||
*
|
||||
* Z16F ZNEO: Far is 24-bits; near is 16-bits of address.
|
||||
* The supported model is (1) all code on ROM, and (2) all data
|
||||
* and stacks in external (far) RAM.
|
||||
* Z8Encore!: Far is 16-bits; near is 8-bits of address.
|
||||
* The supported model is (1) all code on ROM, and (2) all data
|
||||
* and stacks in internal (far) RAM.
|
||||
* Z8Acclaim: In Z80 mode, all pointers are 16-bits. In ADL mode, all pointers
|
||||
* are 24 bits.
|
||||
*/
|
||||
|
||||
# if defined(__ZNEO__)
|
||||
# define FAR _Far
|
||||
# define NEAR _Near
|
||||
# define DSEG _Far
|
||||
# define CODE _Erom
|
||||
# undef CONFIG_SMALL_MEMORY /* Select the large, 32-bit addressing model */
|
||||
# undef CONFIG_LONG_IS_NOT_INT /* Long and int are the same size */
|
||||
# undef CONFIG_PTR_IS_NOT_INT /* FAR pointers and int are the same size */
|
||||
# elif defined(__EZ8__)
|
||||
# define FAR far
|
||||
# define NEAR near
|
||||
# define DSEG far
|
||||
# define CODE rom
|
||||
# define CONFIG_SMALL_MEMORY 1 /* Select small, 16-bit address model */
|
||||
# define CONFIG_LONG_IS_NOT_INT 1 /* Long and int are not the same size */
|
||||
# undef CONFIG_PTR_IS_NOT_INT /* FAR pointers and int are the same size */
|
||||
# elif defined(__EZ80__)
|
||||
# define FAR
|
||||
# define NEAR
|
||||
# define DSEG
|
||||
# define CODE
|
||||
# undef CONFIG_SMALL_MEMORY /* Select the large, 32-bit addressing model */
|
||||
# define CONFIG_LONG_IS_NOT_INT 1 /* Long and int are not the same size */
|
||||
# ifdef CONFIG_EZ80_Z80MODE
|
||||
# define CONFIG_PTR_IS_NOT_INT 1 /* Pointers and int are not the same size */
|
||||
# else
|
||||
# undef CONFIG_PTR_IS_NOT_INT /* Pointers and int are the same size */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* The Zilog compiler does not support inline functions */
|
||||
|
||||
# undef CONFIG_HAVE_INLINE
|
||||
# define inline
|
||||
|
||||
/* ISO C11 supports anonymous (unnamed) structures and unions. Zilog does
|
||||
* not support C11
|
||||
*/
|
||||
|
||||
# undef CONFIG_HAVE_ANONYMOUS_STRUCT
|
||||
# undef CONFIG_HAVE_ANONYMOUS_UNION
|
||||
|
||||
/* Older Zilog compilers support both types double and long long, but the size
|
||||
* is 32-bits (same as long and single precision) so it is safer to say that
|
||||
* they are not supported. Later versions are more ANSII compliant and
|
||||
* simply do not support long long or double.
|
||||
*/
|
||||
|
||||
# undef CONFIG_HAVE_LONG_LONG
|
||||
# define CONFIG_HAVE_FLOAT 1
|
||||
# undef CONFIG_HAVE_DOUBLE
|
||||
# undef CONFIG_HAVE_LONG_DOUBLE
|
||||
|
||||
/* Structures and unions can be assigned and passed as values */
|
||||
|
||||
# define CONFIG_CAN_PASS_STRUCTS 1
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
/* ICCARM-specific definitions ***********************************************/
|
||||
|
||||
#elif defined(__ICCARM__)
|
||||
|
||||
# define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */
|
||||
# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */
|
||||
# define CONFIG_HAVE_FLOAT 1
|
||||
|
||||
/* Indicate that a local variable is not used */
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
# ifndef weak_alias
|
||||
# define weak_alias(name, aliasname)
|
||||
# endif
|
||||
# define weak_function __weak
|
||||
# define weak_const_function
|
||||
# define noreturn_function
|
||||
# define farcall_function
|
||||
# define aligned_data(n)
|
||||
# define begin_packed_struct __packed
|
||||
# define end_packed_struct
|
||||
# define reentrant_function
|
||||
# define naked_function
|
||||
# define inline_function
|
||||
# define noinline_function
|
||||
|
||||
# define FAR
|
||||
# define NEAR
|
||||
# define DSEG
|
||||
# define CODE
|
||||
# define IOBJ
|
||||
# define IPTR
|
||||
|
||||
# define __asm__ asm
|
||||
# define __volatile__ volatile
|
||||
|
||||
/* For operatots __sfb() and __sfe() */
|
||||
|
||||
# pragma section = ".bss"
|
||||
# pragma section = ".data"
|
||||
# pragma section = ".data_init"
|
||||
# pragma section = ".text"
|
||||
|
||||
/* C++ support */
|
||||
|
||||
# undef CONFIG_HAVE_CXX14
|
||||
|
||||
/* ISO C11 supports anonymous (unnamed) structures and unions. Does ICCARM? */
|
||||
|
||||
# undef CONFIG_HAVE_ANONYMOUS_STRUCT
|
||||
# undef CONFIG_HAVE_ANONYMOUS_UNION
|
||||
|
||||
/* Unknown compiler *********************************************************/
|
||||
|
||||
#else
|
||||
|
||||
# undef CONFIG_CPP_HAVE_VARARGS
|
||||
# undef CONFIG_CPP_HAVE_WARNING
|
||||
# undef CONFIG_HAVE_FUNCTIONNAME
|
||||
# undef CONFIG_HAVE_FILENAME
|
||||
# undef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
# undef CONFIG_HAVE_CXX14
|
||||
# ifndef weak_alias
|
||||
# define weak_alias(name, aliasname)
|
||||
# endif
|
||||
# define weak_function
|
||||
# define weak_const_function
|
||||
# define restrict
|
||||
# define noreturn_function
|
||||
# define farcall_function
|
||||
# define aligned_data(n)
|
||||
# define begin_packed_struct
|
||||
# define end_packed_struct
|
||||
# define reentrant_function
|
||||
# define naked_function
|
||||
# define inline_function
|
||||
# define noinline_function
|
||||
|
||||
# define FAR
|
||||
# define NEAR
|
||||
# define DSEG
|
||||
# define CODE
|
||||
|
||||
# undef CONFIG_SMALL_MEMORY
|
||||
# undef CONFIG_LONG_IS_NOT_INT
|
||||
# undef CONFIG_PTR_IS_NOT_INT
|
||||
# undef CONFIG_HAVE_INLINE
|
||||
# define inline
|
||||
# undef CONFIG_HAVE_LONG_LONG
|
||||
# define CONFIG_HAVE_FLOAT 1
|
||||
# undef CONFIG_HAVE_DOUBLE
|
||||
# undef CONFIG_HAVE_LONG_DOUBLE
|
||||
# undef CONFIG_CAN_PASS_STRUCTS
|
||||
# undef CONFIG_HAVE_ANONYMOUS_STRUCT
|
||||
# undef CONFIG_HAVE_ANONYMOUS_UNION
|
||||
|
||||
# define UNUSED(a) ((void)(a))
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_COMPILER_H */
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "sys/types.h"
|
||||
#include "stdint.h"
|
||||
#include "dirent.h"
|
||||
#include "fs/fs.h"
|
||||
#include "vnode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -243,9 +243,7 @@ struct fs_dirent_s
|
||||
|
||||
/* At present, only mountpoints require special handling flags */
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
unsigned int fd_flags;
|
||||
#endif
|
||||
|
||||
/* This keeps track of the current directory position for telldir */
|
||||
|
||||
|
||||
@@ -42,12 +42,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "vfs_config.h"
|
||||
#include "compiler.h"
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "stdarg.h"
|
||||
#include "stdint.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#include "semaphore.h"
|
||||
|
||||
@@ -65,12 +63,10 @@ extern "C" {
|
||||
* pseudo-file system.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
struct statfs; /* Forward reference */
|
||||
typedef int (*foreach_mountpoint_t)(const char *mountpoint,
|
||||
struct statfs *statbuf,
|
||||
void *arg);
|
||||
#endif
|
||||
|
||||
struct filelist *sched_getfiles(void);
|
||||
|
||||
@@ -112,34 +108,6 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count);
|
||||
extern int get_path_from_fd(int fd, char **path);
|
||||
bool get_bit(int i);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: foreach_mountpoint
|
||||
*
|
||||
* Description:
|
||||
* Visit each mountpoint in the pseudo-file system. The traversal is
|
||||
* terminated when the callback 'handler' returns a non-zero value, or when
|
||||
* all of the mountpoints have been visited.
|
||||
*
|
||||
* This is just a front end "filter" to foreach_vnode() that forwards only
|
||||
* mountpoint vnodes. It is intended to support the mount() command to
|
||||
* when the mount command is used to enumerate mounts.
|
||||
*
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
* real work issue.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handler - Operation function when find a mount point.
|
||||
* arg - Private data.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
+2
-1032
File diff suppressed because it is too large
Load Diff
+34
-35
@@ -42,7 +42,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "compiler.h"
|
||||
#include "los_vm_map.h"
|
||||
|
||||
#define CONFIG_FB_CMAP
|
||||
@@ -325,7 +324,7 @@ struct fb_videoinfo_s
|
||||
|
||||
struct fb_planeinfo_s
|
||||
{
|
||||
FAR void *fbmem; /* Start of frame buffer memory */
|
||||
void *fbmem; /* Start of frame buffer memory */
|
||||
size_t fblen; /* Length of frame buffer memory in bytes */
|
||||
fb_coord_t stride; /* Length of a line in bytes */
|
||||
uint8_t display; /* Display number */
|
||||
@@ -355,8 +354,8 @@ struct fb_area_s
|
||||
|
||||
struct fb_overlayinfo_s
|
||||
{
|
||||
FAR void *fbmem; /* Start of frame buffer virtual memory */
|
||||
FAR void *memphys; /* Start of frame buffer physical memory */
|
||||
void *fbmem; /* Start of frame buffer virtual memory */
|
||||
void *memphys; /* Start of frame buffer physical memory */
|
||||
size_t fblen; /* Length of frame buffer memory in bytes */
|
||||
fb_coord_t stride; /* Length of a line in bytes */
|
||||
uint8_t overlay; /* Overlay number */
|
||||
@@ -491,20 +490,20 @@ struct fb_vtable_s
|
||||
* configuration of each color plane.
|
||||
*/
|
||||
|
||||
int (*getvideoinfo)(FAR struct fb_vtable_s *vtable,
|
||||
FAR struct fb_videoinfo_s *vinfo);
|
||||
int (*getplaneinfo)(FAR struct fb_vtable_s *vtable, int planeno,
|
||||
FAR struct fb_planeinfo_s *pinfo);
|
||||
int (*getvideoinfo)(struct fb_vtable_s *vtable,
|
||||
struct fb_videoinfo_s *vinfo);
|
||||
int (*getplaneinfo)(struct fb_vtable_s *vtable, int planeno,
|
||||
struct fb_planeinfo_s *pinfo);
|
||||
|
||||
#ifdef CONFIG_FB_CMAP
|
||||
/* The following are provided only if the video hardware supports RGB
|
||||
* color mapping
|
||||
*/
|
||||
|
||||
int (*getcmap)(FAR struct fb_vtable_s *vtable,
|
||||
FAR struct fb_cmap_s *cmap);
|
||||
int (*putcmap)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_cmap_s *cmap);
|
||||
int (*getcmap)(struct fb_vtable_s *vtable,
|
||||
struct fb_cmap_s *cmap);
|
||||
int (*putcmap)(struct fb_vtable_s *vtable,
|
||||
const struct fb_cmap_s *cmap);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FB_HWCURSOR
|
||||
@@ -512,10 +511,10 @@ struct fb_vtable_s
|
||||
* hardware cursor.
|
||||
*/
|
||||
|
||||
int (*getcursor)(FAR struct fb_vtable_s *vtable,
|
||||
FAR struct fb_cursorattrib_s *attrib);
|
||||
int (*setcursor)(FAR struct fb_vtable_s *vtable,
|
||||
FAR struct fb_setcursor_s *settings);
|
||||
int (*getcursor)(struct fb_vtable_s *vtable,
|
||||
struct fb_cursorattrib_s *attrib);
|
||||
int (*setcursor)(struct fb_vtable_s *vtable,
|
||||
struct fb_setcursor_s *settings);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FB_SYNC
|
||||
@@ -523,7 +522,7 @@ struct fb_vtable_s
|
||||
* vertical snyc.
|
||||
*/
|
||||
|
||||
int (*waitforvsync)(FAR struct fb_vtable_s *vtable);
|
||||
int (*waitforvsync)(struct fb_vtable_s *vtable);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FB_OVERLAY
|
||||
@@ -531,56 +530,56 @@ struct fb_vtable_s
|
||||
* configuration of each overlay.
|
||||
*/
|
||||
|
||||
int (*getoverlayinfo)(FAR struct fb_vtable_s *vtable, int overlayno,
|
||||
FAR struct fb_overlayinfo_s *oinfo);
|
||||
int (*getoverlayinfo)(struct fb_vtable_s *vtable, int overlayno,
|
||||
struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
/* The following are provided only if the video hardware supports
|
||||
* transparency
|
||||
*/
|
||||
|
||||
int (*settransp)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayinfo_s *oinfo);
|
||||
int (*settransp)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
/* The following are provided only if the video hardware supports
|
||||
* chromakey
|
||||
*/
|
||||
|
||||
int (*setchromakey)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayinfo_s *oinfo);
|
||||
int (*setchromakey)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
/* The following are provided only if the video hardware supports
|
||||
* filling the overlay with a color.
|
||||
*/
|
||||
|
||||
int (*setcolor)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayinfo_s *oinfo);
|
||||
int (*setcolor)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
/* The following allows to switch the overlay on or off */
|
||||
|
||||
int (*setblank)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayinfo_s *oinfo);
|
||||
int (*setblank)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
/* The following allows to set the active area for subsequently overlay
|
||||
* operations.
|
||||
*/
|
||||
|
||||
int (*setarea)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayinfo_s *oinfo);
|
||||
int (*setarea)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayinfo_s *oinfo);
|
||||
|
||||
# ifdef CONFIG_FB_OVERLAY_BLIT
|
||||
/* The following are provided only if the video hardware supports
|
||||
* blit operation between overlays.
|
||||
*/
|
||||
|
||||
int (*blit)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayblit_s *blit);
|
||||
int (*blit)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayblit_s *blit);
|
||||
|
||||
/* The following are provided only if the video hardware supports
|
||||
* blend operation between overlays.
|
||||
*/
|
||||
|
||||
int (*blend)(FAR struct fb_vtable_s *vtable,
|
||||
FAR const struct fb_overlayblend_s *blend);
|
||||
int (*blend)(struct fb_vtable_s *vtable,
|
||||
const struct fb_overlayblend_s *blend);
|
||||
# endif
|
||||
#endif
|
||||
int (*fb_open)(struct fb_vtable_s *vtable);
|
||||
@@ -591,7 +590,7 @@ struct fb_vtable_s
|
||||
int (*fb_ioctl)(struct fb_vtable_s *vtable, int cmd, unsigned long arg);
|
||||
int (*fb_check_var)(struct fb_vtable_s *vtable, unsigned long arg);
|
||||
int (*fb_set_par)(struct fb_vtable_s *vtable);
|
||||
ssize_t (*fb_mmap)(FAR struct fb_vtable_s *vtable, FAR LosVmMapRegion *region);
|
||||
ssize_t (*fb_mmap)(struct fb_vtable_s *vtable, LosVmMapRegion *region);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -655,7 +654,7 @@ int up_fbinitialize(int display);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane);
|
||||
struct fb_vtable_s *up_fbgetvplane(int display, int vplane);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_fbuninitialize
|
||||
|
||||
Reference in New Issue
Block a user