diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 6de6b74a1e631a70cb381aaa808d94c408f6aa96..c87cd96c423057b499750ed59e591a0f720fde48 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -47,7 +47,6 @@ #include #include #include -#include #include "bch.h" /**************************************************************************** diff --git a/drivers/bch/bchdev_register.c b/drivers/bch/bchdev_register.c index 7e7dd5addbd0d1ec197a6f556498b4ef14975c4b..5c9a7b916d16fcdfd837b88ffb422a94affbd3db 100755 --- a/drivers/bch/bchdev_register.c +++ b/drivers/bch/bchdev_register.c @@ -39,7 +39,6 @@ #include #include #include -#include #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 */ diff --git a/drivers/bch/bchdev_unregister.c b/drivers/bch/bchdev_unregister.c index 9a4d7604ada984e36e928b65b708ded2a1928ee4..5554eb047f231b8f0735750e871d48c7d96163e5 100755 --- a/drivers/bch/bchdev_unregister.c +++ b/drivers/bch/bchdev_unregister.c @@ -43,9 +43,9 @@ #include #include #include -#include #include #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; diff --git a/drivers/bch/bchlib_cache.c b/drivers/bch/bchlib_cache.c index 2c5610a9c8171a367cb538e2ed02f62e19aaad95..1463f2f4775df6713bd748b25ca28b552b6fda3c 100755 --- a/drivers/bch/bchlib_cache.c +++ b/drivers/bch/bchlib_cache.c @@ -40,7 +40,6 @@ #include #include #include -#include #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); diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c index a9a7033fe20af8bda66ec095dc74e040e16d2935..338a1c9d3b39a9eae6da6b15be2f6edca04dcfdf 100755 --- a/drivers/bch/bchlib_read.c +++ b/drivers/bch/bchlib_read.c @@ -41,7 +41,6 @@ #include #include #include -#include #include "bch.h" #include @@ -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) { diff --git a/drivers/bch/bchlib_sem.c b/drivers/bch/bchlib_sem.c index fc0c4fd7a5d815b8040ea36c76f95e785b99b404..017cb155ebbb7bb5665a8a352183d0015611215a 100755 --- a/drivers/bch/bchlib_sem.c +++ b/drivers/bch/bchlib_sem.c @@ -38,7 +38,6 @@ ****************************************************************************/ #include #include -#include #include #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) { diff --git a/drivers/bch/bchlib_setup.c b/drivers/bch/bchlib_setup.c index 24bb1c7c33cf42f21ad260695fef74e3a438ccae..d983d3eded442b3c38b68aec53b8ef276a9a6bba 100644 --- a/drivers/bch/bchlib_setup.c +++ b/drivers/bch/bchlib_setup.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "bch.h" diff --git a/drivers/bch/bchlib_teardown.c b/drivers/bch/bchlib_teardown.c index 8564d81d3c3c2991910d252f9a5a34899f91be62..83b9fa19b2c09fea551fb7167d16517f7a0ff788 100644 --- a/drivers/bch/bchlib_teardown.c +++ b/drivers/bch/bchlib_teardown.c @@ -39,8 +39,6 @@ #include #include #include -#include -#include "fs/fs.h" #include "bch.h" /**************************************************************************** diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 6140633961d0c8b18ee6279d6113595e6a70a077..b60f0ecab4d625b1233466545addc7b10fc3f2f4 100755 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -42,7 +42,6 @@ #include #include #include -#include #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) { diff --git a/drivers/pipes/fifo.c b/drivers/pipes/fifo.c index c48985314f745ffe1b9a97196807a245205bd795..edb56c3dbc214421e75d68caa012cca89201257b 100644 --- a/drivers/pipes/fifo.c +++ b/drivers/pipes/fifo.c @@ -40,9 +40,7 @@ #include #include #include - -#include - +#include #include "pipe_common.h" #if CONFIG_DEV_FIFO_SIZE > 0 diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c index e6d5dfe872e8c235810587189f7ed2ccd23a16b8..a5690f85aec5755a1cfc5c9662fafe0eec5d6a75 100644 --- a/drivers/pipes/pipe.c +++ b/drivers/pipes/pipe.c @@ -44,8 +44,7 @@ #include #include #include -#include "fs/fs.h" -#include "fs/vnode.h" +#include "fs/driver.h" #include "los_init.h" #if CONFIG_DEV_PIPE_SIZE > 0 diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index e57dbc81a82add7ee114a9b2f401aa34641c5a49..40b7db663ff146b63071bdee48cbf52377a37cc3 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -49,25 +49,20 @@ #include #include #include -#include #include #include "linux/wait.h" -#include "fs/fs.h" -#include "fs_poll_pri.h" #include #ifdef CONFIG_DEBUG_FEATURES # include #endif #include -#include +#include #include "pipe_common.h" #include "los_printf.h" #include "user_copy.h" #ifdef LOSCFG_KERNEL_PIPE -#include "fs/vnode.h" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/drivers/pipes/pipe_common.h b/drivers/pipes/pipe_common.h index 0d26eec16eb49f82fbd25de6834157d63ac640f5..8b295200b4be745693cccef16478cd8ced2e37b2 100755 --- a/drivers/pipes/pipe_common.h +++ b/drivers/pipes/pipe_common.h @@ -39,8 +39,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ -#include "fs/fs.h" -#include "fs/vnode.h" +#include "vnode.h" #include #include #include @@ -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 diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 67890eb3ad8eec3124353e2eb920eee95a1e6e86..ab927be757223384a7a91eeae110da0368cbb2aa 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -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" diff --git a/fs/dirent/fs_closedir.c b/fs/dirent/fs_closedir.c index 5c9c2ad8f28078fbb48047c23fff34b22d5ef317..985665ae99e98085393a1ae33c2be165b141da1d 100644 --- a/fs/dirent/fs_closedir.c +++ b/fs/dirent/fs_closedir.c @@ -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 diff --git a/fs/dirent/fs_opendir.c b/fs/dirent/fs_opendir.c index 994d0e444fb33d37d5ed3181f3fb47f650e2c4fa..cd0c7bd4e5937805bd118c7543a4df5f5acc0c1c 100644 --- a/fs/dirent/fs_opendir.c +++ b/fs/dirent/fs_opendir.c @@ -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 diff --git a/fs/dirent/fs_readdir.c b/fs/dirent/fs_readdir.c index 81fd09eae2f5f318d3ae7a0b2d33c03961bc9d1e..07be16827b62bc03d796ee42587ca8bb6b387e28 100644 --- a/fs/dirent/fs_readdir.c +++ b/fs/dirent/fs_readdir.c @@ -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 diff --git a/fs/dirent/fs_rewinddir.c b/fs/dirent/fs_rewinddir.c index e2c5f3bb53fcc90aa9fc8418ec84f8d49de5345d..e62bc994275d27f0b5178088cfcb1e57f6221a2b 100644 --- a/fs/dirent/fs_rewinddir.c +++ b/fs/dirent/fs_rewinddir.c @@ -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 diff --git a/fs/dirent/fs_seekdir.c b/fs/dirent/fs_seekdir.c index 4154aa6ba2aacf99f6d546eef3eccabda07250ad..77a52637594269d8465606b247392090d042354e 100644 --- a/fs/dirent/fs_seekdir.c +++ b/fs/dirent/fs_seekdir.c @@ -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 diff --git a/fs/dirent/fs_telldir.c b/fs/dirent/fs_telldir.c index f82bd016af0cfb1e30c92913ed70a0f8edd503db..4fc0e5802cba43962fbab89668065f9df05c238b 100644 --- a/fs/dirent/fs_telldir.c +++ b/fs/dirent/fs_telldir.c @@ -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; diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c index 9bfedd4a1b050f79111a34247424914f4879fede..918374bba7514d8983bd44f6128d8deae295952b 100755 --- a/fs/driver/fs_blockproxy.c +++ b/fs/driver/fs_blockproxy.c @@ -47,12 +47,9 @@ #include #include #include -#include -#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 */ diff --git a/fs/driver/fs_closeblockdriver.c b/fs/driver/fs_closeblockdriver.c index cd3eab9596379bcc459692dcdd6e3fd7b455ffd3..e88569bfd40cdeebb4512664d734dfb1c800cc44 100644 --- a/fs/driver/fs_closeblockdriver.c +++ b/fs/driver/fs_closeblockdriver.c @@ -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" /**************************************************************************** diff --git a/fs/driver/fs_devsyslog.c b/fs/driver/fs_devsyslog.c index c3e6fb487074df22d740f50b0491a9511e689abd..59887a3d33223935b790d96c92fdb55e733f7584 100644 --- a/fs/driver/fs_devsyslog.c +++ b/fs/driver/fs_devsyslog.c @@ -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; diff --git a/fs/driver/fs_findblockdriver.c b/fs/driver/fs_findblockdriver.c index 775fe69b99f28c0759520a6e156cb28b62a89c59..26b6b0207374f32cc3b35397adbf31b16f8ce748 100644 --- a/fs/driver/fs_findblockdriver.c +++ b/fs/driver/fs_findblockdriver.c @@ -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; } diff --git a/fs/driver/fs_openblockdriver.c b/fs/driver/fs_openblockdriver.c index b363ae37297af2ea0efaf3f07ddd0806385a54fd..9b3f362c293eadee98e5903ffb196219883d38fa 100644 --- a/fs/driver/fs_openblockdriver.c +++ b/fs/driver/fs_openblockdriver.c @@ -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 @@ -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; } } diff --git a/fs/driver/fs_registerblockdriver.c b/fs/driver/fs_registerblockdriver.c index aa6fbb28d24f78da2dced1dab79758b65e6dda3a..4ccf4a436dd6b6a78760f140337246ff08db3cfb 100644 --- a/fs/driver/fs_registerblockdriver.c +++ b/fs/driver/fs_registerblockdriver.c @@ -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 */ diff --git a/fs/driver/fs_registerdriver.c b/fs/driver/fs_registerdriver.c index edbc90884d9573ccc44a221a6df3fa2c1b69f35e..1a3139096bc32d82fcb1f221326dd36581a7bea8 100644 --- a/fs/driver/fs_registerdriver.c +++ b/fs/driver/fs_registerdriver.c @@ -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. diff --git a/fs/driver/fs_unregisterblockdriver.c b/fs/driver/fs_unregisterblockdriver.c index cb1d456456a49f1099017f37a7963bcabc61901d..e77120c010ea0e1ceaec6b69eff5d6a5e5ada7db 100644 --- a/fs/driver/fs_unregisterblockdriver.c +++ b/fs/driver/fs_unregisterblockdriver.c @@ -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" diff --git a/fs/driver/fs_unregisterdriver.c b/fs/driver/fs_unregisterdriver.c index ca513b294cb5237a5902c7e6aea9251fb7837325..973cd8e5862ade8bd705a58fa2835ee67d03c86e 100644 --- a/fs/driver/fs_unregisterdriver.c +++ b/fs/driver/fs_unregisterdriver.c @@ -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; diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index b9504ed6bc9f82416f08a5e296037addd243c75b..8c6dd92bd2db853075dfcecd273c225c9f9e29d6 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -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; diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index 76f5a2747cb46b0dc66e5ffa0f7c9332c51bfb10..3e011add016eebb511b6365cc7c951d7c5f0b4f1 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -49,7 +49,6 @@ #include "string.h" #include "inode/inode.h" #include "capability_api.h" -#include "fs_other.h" /**************************************************************************** * Private Functions diff --git a/fs/inode/fs_inodesearch.c b/fs/inode/fs_inodesearch.c index 6864e0c081f12b82fdd98b9084aedb477c9085b3..5186fe1205cca2b3a5a73c7363d026542103a62e 100755 --- a/fs/inode/fs_inodesearch.c +++ b/fs/inode/fs_inodesearch.c @@ -45,7 +45,6 @@ #include "stdlib.h" #include "fs/fs.h" -#include "fs_other.h" #include "inode/inode.h" /**************************************************************************** * Public Data diff --git a/fs/inode/inode.h b/fs/inode/inode.h deleted file mode 100644 index 10ac0ab4f476275023aed8a6de1c4d4795a37d23..0000000000000000000000000000000000000000 --- a/fs/inode/inode.h +++ /dev/null @@ -1,437 +0,0 @@ -/**************************************************************************** - * fs/inode/inode.h - * - * Copyright (C) 2007, 2009, 2012, 2014, 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - * , 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 */ diff --git a/fs/mount/fs_foreachmountpoint.c b/fs/mount/fs_foreachmountpoint.c index 6080d9f1394401d22cb81c11933015f8842c4bfd..db4282b8f168f72f844399e6402eb8c9b5c444eb 100644 --- a/fs/mount/fs_foreachmountpoint.c +++ b/fs/mount/fs_foreachmountpoint.c @@ -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 diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index 837be74c7e84cefb01b2cbc0e3f89bc62f95c3a8..a100e14e637ab3a5d4cf49fb0ee9bae1fb8ef986 100755 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -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)) diff --git a/fs/mount/fs_umount.c b/fs/mount/fs_umount.c index c3688250869f3fb35f3f54de7d63b9add728b219..ad54fe6ab60854768297a190f3980e61161d139e 100755 --- a/fs/mount/fs_umount.c +++ b/fs/mount/fs_umount.c @@ -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 diff --git a/fs/nfs/nfs.h b/fs/nfs/nfs.h index b6328e78bc60c05e191405873c748d4b86a8f982..42dee2bf700dd5808d2e5ab51ffdbe7b28bb923a 100755 --- a/fs/nfs/nfs.h +++ b/fs/nfs/nfs.h @@ -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); diff --git a/fs/nfs/nfs_adapter.c b/fs/nfs/nfs_adapter.c index 42173219598db769ac8ec411a0a9ce5ea8883c0b..daa4e7f52412300325702378673a3059658a44fd 100644 --- a/fs/nfs/nfs_adapter.c +++ b/fs/nfs/nfs_adapter.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #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; } diff --git a/fs/nfs/nfs_util.c b/fs/nfs/nfs_util.c index 19e198412f7028e4a724bf662c2f58c2db38ba58..39c3c6b3acce37b17c04fb0e6a9236295da26480 100644 --- a/fs/nfs/nfs_util.c +++ b/fs/nfs/nfs_util.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #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; } diff --git a/fs/nfs/rpc.h b/fs/nfs/rpc.h index 20b875e2a6e77c91dfec774ad58d4dc522ee3c2a..82e1fe534e548173121d2b1e77fcf422b26d67ad 100755 --- a/fs/nfs/rpc.h +++ b/fs/nfs/rpc.h @@ -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 diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c index b855ffcff3a35fdd799917c946850b2ff999f5aa..0fee1f1bae0fa329ab5da6e73c77db206f39fb33 100644 --- a/fs/nfs/rpc_clnt.c +++ b/fs/nfs/rpc_clnt.c @@ -80,7 +80,6 @@ #include #include -#include #include #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; } diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c index daa2dc964c31df7239e18e77810f9ab8c2da8bec..46230451756880b5620721a8921e6b9f0eb0f01f 100755 --- a/fs/tmpfs/fs_tmpfs.c +++ b/fs/tmpfs/fs_tmpfs.c @@ -40,13 +40,16 @@ #include #include #include -#include #include #include #include #include #include +#include #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 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 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 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 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(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; - - FAR char *copy; + 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; + + 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 { diff --git a/fs/tmpfs/fs_tmpfs.h b/fs/tmpfs/fs_tmpfs.h index 57a8a8f9b4e58c38256d22c715919b6bf576ca59..2c2f20d58ddeb612bc4d6a6fa65553a1ac824aeb 100755 --- a/fs/tmpfs/fs_tmpfs.h +++ b/fs/tmpfs/fs_tmpfs.h @@ -41,7 +41,6 @@ ****************************************************************************/ #include -#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 diff --git a/fs/vfs/fs_close.c b/fs/vfs/fs_close.c index 7d518fa8e3a5ab57917968ccde2f5c0b77d1ef3b..d2517becea04803c147d0c5a589f849903c6e762 100644 --- a/fs/vfs/fs_close.c +++ b/fs/vfs/fs_close.c @@ -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 diff --git a/fs/vfs/fs_dup.c b/fs/vfs/fs_dup.c index accbf50d0d8c8e816b2102dfc1a1dd8247267b57..bd56289a418f8bf4e6abb0b731694fa29af2c86d 100755 --- a/fs/vfs/fs_dup.c +++ b/fs/vfs/fs_dup.c @@ -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 diff --git a/fs/vfs/fs_dup2.c b/fs/vfs/fs_dup2.c index c6a7c0faf9ec133bf9c4b65ab252a2db3edb101e..35042e73127d4334a22167da14f3695c4d0d77ae 100755 --- a/fs/vfs/fs_dup2.c +++ b/fs/vfs/fs_dup2.c @@ -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 diff --git a/fs/vfs/fs_dupfd.c b/fs/vfs/fs_dupfd.c index 3c663d6e6803ec206b4e9dc87cdfc20791e34579..dfef05b94c6512ee58ee2d25e4a05a1296d9a010 100644 --- a/fs/vfs/fs_dupfd.c +++ b/fs/vfs/fs_dupfd.c @@ -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 diff --git a/fs/vfs/fs_dupfd2.c b/fs/vfs/fs_dupfd2.c index a52c071027a1db57dff33ec6612cd1c19aed57e1..17f1ffaafa50b1ca807f3391d7ac1ab6120f266f 100644 --- a/fs/vfs/fs_dupfd2.c +++ b/fs/vfs/fs_dupfd2.c @@ -44,7 +44,7 @@ #include "unistd.h" #include "sched.h" -#include "fs/vnode.h" +#include "vnode.h" #if CONFIG_NFILE_DESCRIPTORS > 0 diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index 9b6c5a74cb9fdb1b3266fd972db0aaf1a26a7279..4a1aab3b7c5f1565a3cdee2af225925f9aee70bd 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -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" diff --git a/fs/vfs/fs_fsync.c b/fs/vfs/fs_fsync.c index d94adc3ff775a2d2acb4b48c7d1859706a7a9204..a4df0b5cf787094844a35b72c62b3a2e9ca4e3a6 100644 --- a/fs/vfs/fs_fsync.c +++ b/fs/vfs/fs_fsync.c @@ -45,10 +45,9 @@ #include "errno.h" #include "assert.h" -#include "fs/fs.h" -#include "fs/vnode.h" +#include "vnode.h" /**************************************************************************** * Public Functions diff --git a/fs/vfs/fs_getfilep.c b/fs/vfs/fs_getfilep.c index c0c6cb9e813ce4b1c853067a45a8e83b7140ff2b..556ae78cc98aba3518c60d5b2034ce0b3d732703 100644 --- a/fs/vfs/fs_getfilep.c +++ b/fs/vfs/fs_getfilep.c @@ -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" /**************************************************************************** diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 7f072cb4299e329e1fe32cff59d36bbc0ce48413..54bc5c7df4494e6bd95ea4bec198af3b2ea5ba25 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -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 diff --git a/fs/vfs/fs_link.c b/fs/vfs/fs_link.c index 59417b06435a18f3485fc029e9447ee5a9740ffb..d5c7de85acae3b4843dc5b6f4c0ed91f48aed0e1 100644 --- a/fs/vfs/fs_link.c +++ b/fs/vfs/fs_link.c @@ -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); -} \ No newline at end of file +} diff --git a/fs/vfs/fs_lseek.c b/fs/vfs/fs_lseek.c index ab2d532062470f7354cb40ee6ea40496154b548a..14113afcf08d7c66a8e178facb5f380c2c864de6 100644 --- a/fs/vfs/fs_lseek.c +++ b/fs/vfs/fs_lseek.c @@ -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 diff --git a/fs/vfs/fs_lseek64.c b/fs/vfs/fs_lseek64.c index 69fa50bca7edaf323d0e24b4a7af9c60fc1e42cc..f859316325bd07bf6c3735f4440cf6017f2f33ff 100644 --- a/fs/vfs/fs_lseek64.c +++ b/fs/vfs/fs_lseek64.c @@ -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 diff --git a/fs/vfs/fs_mkdir.c b/fs/vfs/fs_mkdir.c index 530e5746840420c016f9e222105f9fa89f54e046..f74e21a46e6f2ea87d59f268d6636abd2809e513 100644 --- a/fs/vfs/fs_mkdir.c +++ b/fs/vfs/fs_mkdir.c @@ -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 diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index 954370c56ea6d84d6eaf3422c97ca8050fb2394d..73f92303a22195132488555fb89d00cf1cf78cea 100755 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -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" /**************************************************************************** diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index 8830a59ee5d7e2505b644d5116bb6110c63893ce..86b12f81c7dad07b30b62c46caee3a1bfc66eb3c 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -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" diff --git a/fs/vfs/fs_pread.c b/fs/vfs/fs_pread.c index eff48af6afa45d367f91b3f5090af683c67240ad..27ce7cf5bf5e50942e6e81b13105ce1f2d6c847d 100755 --- a/fs/vfs/fs_pread.c +++ b/fs/vfs/fs_pread.c @@ -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. */ diff --git a/fs/vfs/fs_pread64.c b/fs/vfs/fs_pread64.c index b66b55608eb898686cfc73c4d8317a41e42ef231..fe0bf978f99c253ba58482a5fddd1b4f643087a1 100755 --- a/fs/vfs/fs_pread64.c +++ b/fs/vfs/fs_pread64.c @@ -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. */ diff --git a/fs/vfs/fs_pwrite.c b/fs/vfs/fs_pwrite.c index 3bc639ad579e063922ec719b5362643fc75c3463..9973cc5a079287629098fe12dc6fafee511e2545 100755 --- a/fs/vfs/fs_pwrite.c +++ b/fs/vfs/fs_pwrite.c @@ -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. */ diff --git a/fs/vfs/fs_pwrite64.c b/fs/vfs/fs_pwrite64.c index 358000dc9256a1a0809508c98003d183df2ad0ed..6098b9b75e62a51eb0bf7dd720c0c084310745d3 100755 --- a/fs/vfs/fs_pwrite64.c +++ b/fs/vfs/fs_pwrite64.c @@ -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. */ diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c index 9f4fc146f044175b9c171ea513bdc659e743f2d2..58631d0c0a40d64df764bfe3e32fd532263fc215 100644 --- a/fs/vfs/fs_read.c +++ b/fs/vfs/fs_read.c @@ -48,7 +48,7 @@ #include "assert.h" #include "errno.h" #include "user_copy.h" -#include "fs/vnode.h" +#include "vnode.h" /**************************************************************************** * Public Functions diff --git a/fs/vfs/fs_readlink.c b/fs/vfs/fs_readlink.c index d1623aa2036b3f956383b0162a8158e0f2ab4b44..39dc7ed4ad7a8ec7f354986da5c2f49d92d32919 100644 --- a/fs/vfs/fs_readlink.c +++ b/fs/vfs/fs_readlink.c @@ -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) { diff --git a/fs/vfs/fs_rename.c b/fs/vfs/fs_rename.c index 711bb2c1a53c3989e5059eb3e85888c2d8ed6ebf..06151801a59d97350d7dbe45c99aaeae8ab7b7d0 100644 --- a/fs/vfs/fs_rename.c +++ b/fs/vfs/fs_rename.c @@ -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 ****************************************************************************/ diff --git a/fs/vfs/fs_rmdir.c b/fs/vfs/fs_rmdir.c index 658285f1573b864c770b03c8f8ae567b94117236..b9fc71ad52373ef21d422f6276a51eecaf9dc0a4 100644 --- a/fs/vfs/fs_rmdir.c +++ b/fs/vfs/fs_rmdir.c @@ -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" /**************************************************************************** diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index 5e6bd85f860610e996174cb735b59a2dd402ce2e..dd51153b7e20563f91f5336b988c10dca12543b1 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -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" diff --git a/fs/vfs/fs_sendfile.c b/fs/vfs/fs_sendfile.c index e4fc6e776533a365723fd112c6a6294d39f134a3..47640f05c47d6680762afa54fec922834a3eb47b 100755 --- a/fs/vfs/fs_sendfile.c +++ b/fs/vfs/fs_sendfile.c @@ -46,7 +46,6 @@ #include #include -#include #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); diff --git a/fs/vfs/fs_stat.c b/fs/vfs/fs_stat.c index f7d78801c0aac4a6bd4b756a05a3e6d6415927be..50ac55e473a1cdd425eb96ff95c5da90f1424833 100644 --- a/fs/vfs/fs_stat.c +++ b/fs/vfs/fs_stat.c @@ -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 ****************************************************************************/ diff --git a/fs/vfs/fs_statfs.c b/fs/vfs/fs_statfs.c index c5a79f5f3e4e85cebf9d6e37b3a51718210ae1f8..95b9578ddd5eaca9f4a629eb4f369da67a4b815d 100644 --- a/fs/vfs/fs_statfs.c +++ b/fs/vfs/fs_statfs.c @@ -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" diff --git a/fs/vfs/fs_symlink.c b/fs/vfs/fs_symlink.c index e1e38c76aa6d54b23043cc2a0272411ee3887ea9..00409815f94800f9a675db67555e9235b45f132d 100644 --- a/fs/vfs/fs_symlink.c +++ b/fs/vfs/fs_symlink.c @@ -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) { diff --git a/fs/vfs/fs_truncate.c b/fs/vfs/fs_truncate.c index 57fc4c1c2b5c452855a08d9aca0135ebc1e0ad8d..09ba509490f02d6bb7adc1e772c19be834670fc0 100644 --- a/fs/vfs/fs_truncate.c +++ b/fs/vfs/fs_truncate.c @@ -45,7 +45,7 @@ #include "assert.h" #include "errno.h" -#include "fs/vnode.h" +#include "vnode.h" /**************************************************************************** * Name: file_truncate diff --git a/fs/vfs/fs_truncate64.c b/fs/vfs/fs_truncate64.c index ff4ead3fda5802a1d0e3c9a75c45f5597c0b927e..dc5f9fb4ad5d9c6232a664571fff34130d2c534d 100644 --- a/fs/vfs/fs_truncate64.c +++ b/fs/vfs/fs_truncate64.c @@ -45,7 +45,7 @@ #include "assert.h" #include "errno.h" -#include "fs/vnode.h" +#include "vnode.h" /**************************************************************************** * Name: file_truncate diff --git a/fs/vfs/fs_unlink.c b/fs/vfs/fs_unlink.c index e7e1590d1b32ca7aed0f81442be00825fb475c0f..36601a953e12ee25c7a1312a7782f92ed8b7709d 100644 --- a/fs/vfs/fs_unlink.c +++ b/fs/vfs/fs_unlink.c @@ -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 diff --git a/fs/vfs/fs_write.c b/fs/vfs/fs_write.c index 11a94a8d738cd4a15bbe04e2beb7f05efd3c7fb1..8a0d6502c263fd1313ea2c4c2905b2f3cd8331e6 100644 --- a/fs/vfs/fs_write.c +++ b/fs/vfs/fs_write.c @@ -48,7 +48,7 @@ #include "sys/socket.h" #include "console.h" #include "user_copy.h" -#include "fs/vnode.h" +#include "vnode.h" /**************************************************************************** * Public Functions diff --git a/include/debug.h b/include/debug.h deleted file mode 100755 index 69397e5f28b1e27618fb20517dc90b1ca822397d..0000000000000000000000000000000000000000 --- a/include/debug.h +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** - * include/debug.h - * - * Copyright (C) 2007-2011, 2014, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 */ diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h deleted file mode 100755 index 6bf90072dbdcafb9e90acd81188c4ffa08cde523..0000000000000000000000000000000000000000 --- a/include/nuttx/compiler.h +++ /dev/null @@ -1,696 +0,0 @@ -/**************************************************************************** - * include/nuttx/compiler.h - * - * Copyright (C) 2007-2009, 2012-2013, 2015-2017 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt - * - * 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 */ diff --git a/include/nuttx/fs/dirent_fs.h b/include/nuttx/fs/dirent_fs.h index 16baae5eff22f703fc286fefbe178736338396e3..077319770a34eb0b1f690b02a207f9621f2429bc 100644 --- a/include/nuttx/fs/dirent_fs.h +++ b/include/nuttx/fs/dirent_fs.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 */ diff --git a/include/nuttx/fs/file.h b/include/nuttx/fs/file.h index dfbb17abba2c4940baebf5ec0ecf8d35dd090c42..a3b8b7123515513b9e4f2f00f3d70006e180eedd 100644 --- a/include/nuttx/fs/file.h +++ b/include/nuttx/fs/file.h @@ -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 } diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 18f6def33bb3b7df40e3c0b1ae16d29b85f23955..b7eb00adfe09d88ac496e0d94f4a6ad14556c165 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -40,28 +40,8 @@ /**************************************************************************** * Included Files ****************************************************************************/ - -#include "vfs_config.h" -#include "compiler.h" - -#include "poll.h" -#include "sys/types.h" -#include "sys/stat.h" -#include "fcntl.h" - -#include "stdarg.h" -#include "stdint.h" - -#include "sys/vfs.h" -#include "los_vm_map.h" -#include "los_atomic.h" -#include "semaphore.h" -#include "los_spinlock.h" #include "mount.h" - -#ifndef CONFIG_DISABLE_MQUEUE -#include "mqueue.h" -#endif +#include "fs/driver.h" #ifdef __cplusplus #if __cplusplus @@ -69,312 +49,9 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -/* POSIX-like OS return values: */ - -#ifndef VFS_ERROR -#define VFS_ERROR -1 -#endif - -#undef OK -#define OK 0 - -#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR -#define MS_RDONLY 1 -#define MS_NOSYNC 2 -#define PROCFS_MOUNT_POINT "/proc" -#define PROCFS_MOUNT_POINT_SIZE (sizeof(PROCFS_MOUNT_POINT) - 1) - -#define RAMFS_MOUNT_POINT "/ramfs" -#define RAMFS_MOUNT_POINT_SIZE (sizeof(RAMFS_MOUNT_POINT) - 1) - -#define DEFAULT_DIR_MODE 0777 -#define DEFAULT_FILE_MODE 0666 -#define USER_MODE_SHIFT 6 -#define GROUP_MODE_SHIFT 3 -#define DEFAULT_MOUNT_DIR_MODE 0755 -/* Format options (3rd argument of format) */ -#define FMT_FAT 0x01 -#define FMT_FAT32 0x02 -#define FMT_ANY 0x07 -#define FMT_ERASE 0x08 - -/* system time flag for FAT */ -#define FAT_SYSTEM_TIME_ENABLE 0x01 -#define FAT_SYSTEM_TIME_DISABLE 0x00 - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Stream flags for the fs_flags field of in struct file_struct */ - -#define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */ -#define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */ -#define __FS_FLAG_LBF (1 << 2) /* Line buffered */ -#define __FS_FLAG_UBF (1 << 3) /* Buffer allocated by caller of setvbuf */ - -#define FALLOC_FL_KEEP_SIZE 1 /* extend size */ - -/* The struct file_operations open(0) normally returns zero on success and - * a negated errno value on failure. There is one case, however, where - * the open method will redirect to another driver and return a file - * descriptor instead. - * - * This case is when SUSv1 pseudo-terminals are used (CONFIG_PSEUDOTERM_SUSV1=y). - * In this case, the output is encoded and decoded using these macros in - * order to support (a) returning file descriptor 0 (which really should - * not happen), and (b) avoiding confusion if some other open method returns - * a positive, non-zero value which is not a file descriptor. - * - * OPEN_ISFD(r) tests if the return value from the open method is - * really a file descriptor. - * OPEN_SETFD(f) is used by an implementation of the open() method - * in order to encode a file descriptor in the return value. - * OPEN_GETFD(r) is use by the upper level open() logic to decode - * the file descriptor encoded in the return value. - * - * REVISIT: This only works for file descriptors in the in range 0-255. - */ - -#define OPEN_MAGIC 0x4200 -#define OPEN_MASK 0x00ff -#define OPEN_MAXFD 0x00ff - -#define OPEN_ISFD(r) (((r) & ~OPEN_MASK) == OPEN_MAGIC) -#define OPEN_SETFD(f) ((f) | OPEN_MAGIC) -#define OPEN_GETFD(r) ((r) & OPEN_MASK) - /**************************************************************************** * Public Type Definitions ****************************************************************************/ - -#define AT_REMOVEDIR 0x200 - -/* Attribute flags. */ -#define CHG_MODE 1 -#define CHG_UID 2 -#define CHG_GID 4 -#define CHG_SIZE 8 -#define CHG_ATIME 16 -#define CHG_MTIME 32 -#define CHG_CTIME 64 - -struct IATTR -{ - /* This structure is used for record vnode attr. */ - unsigned int attr_chg_valid; - unsigned int attr_chg_flags; - unsigned attr_chg_mode; - unsigned attr_chg_uid; - unsigned attr_chg_gid; - unsigned attr_chg_size; - unsigned attr_chg_atime; - unsigned attr_chg_mtime; - unsigned attr_chg_ctime; -}; - -/* Forward references */ - -struct file; -struct Vnode; -struct stat; -struct statfs; -struct pollfd; -struct fs_dirent_s; - -/* This structure is provided by devices when they are registered with the - * system. It is used to call back to perform device specific operations. - */ - -struct file_operations_vfs -{ - /* The device driver open method differs from the mountpoint open method */ - - int (*open)(struct file *filep); - - /* The following methods must be identical in signature and position because - * the struct file_operations and struct mountp_operations are treated like - * unions. - */ - - int (*close)(struct file *filep); - ssize_t (*read)(struct file *filep, char *buffer, size_t buflen); - ssize_t (*write)(struct file *filep, const char *buffer, size_t buflen); - off_t (*seek)(struct file *filep, off_t offset, int whence); - int (*ioctl)(struct file *filep, int cmd, unsigned long arg); - int (*mmap)(struct file* filep, struct VmMapRegion *region); - /* The two structures need not be common after this point */ - -#ifndef CONFIG_DISABLE_POLL - int (*poll)(struct file *filep, poll_table *fds); -#endif - int (*stat)(struct file *filep, struct stat* st); - int (*fallocate)(struct file* filep, int mode, off_t offset, off_t len); - int (*fallocate64)(struct file *filep, int mode, off64_t offset, off64_t len); - int (*fsync)(struct file *filep); - ssize_t (*readpage)(struct file *filep, char *buffer, size_t buflen); - int (*unlink)(struct Vnode *vnode); -}; - -/* This structure provides information about the state of a block driver */ - -#ifndef CONFIG_DISABLE_MOUNTPOINT -struct geometry -{ - bool geo_available; /* true: The device is available */ - bool geo_mediachanged; /* true: The media has changed since last query */ - bool geo_writeenabled; /* true: It is okay to write to this device */ - unsigned long long geo_nsectors; /* Number of sectors on the device */ - size_t geo_sectorsize; /* Size of one sector */ -}; - -/* This structure is provided by block devices when they register with the - * system. It is used by file systems to perform filesystem transfers. It - * differs from the normal driver vtable in several ways -- most notably in - * that it deals in struct Vnode vs. struct filep. - */ - -struct Vnode; -struct block_operations -{ - int (*open)(struct Vnode *vnode); - int (*close)(struct Vnode *vnode); - ssize_t (*read)(struct Vnode *vnode, unsigned char *buffer, - unsigned long long start_sector, unsigned int nsectors); - ssize_t (*write)(struct Vnode *vnode, const unsigned char *buffer, - unsigned long long start_sector, unsigned int nsectors); - int (*geometry)(struct Vnode *vnode, struct geometry *geometry); - int (*ioctl)(struct Vnode *vnode, int cmd, unsigned long arg); - int (*unlink)(struct Vnode *vnode); -}; - -struct mountpt_operations2 -{ - /* The mountpoint open method differs from the driver open method - * because it receives (1) the vnode that contains the mountpoint - * private data, (2) the relative path into the mountpoint, and (3) - * information to manage privileges. - */ - - int (*open)(struct file *filep, const char *relpath, - int oflags, mode_t mode); - - /* The following methods must be identical in signature and position - * because the struct file_operations and struct mountpt_operations are - * treated like unions. - */ - - int (*close)(struct file *filep); - ssize_t (*read)(struct file *filep, char *buffer, size_t buflen); - ssize_t (*write)(struct file *filep, const char *buffer, - size_t buflen); - off_t (*seek)(struct file *filep, off_t offset, int whence); - int (*ioctl)(struct file *filep, int cmd, unsigned long arg); - int (*mmap)(struct file* filep, LosVmMapRegion *region); - /* The two structures need not be common after this point. The following - * are extended methods needed to deal with the unique needs of mounted - * file systems. - * - * Additional open-file-specific mountpoint operations: - */ - - int (*sync)(struct file *filep); - int (*dup)(const struct file *oldp, struct file *newp); - int (*fstat)(const struct file *filep, struct stat *buf); - int (*truncate)(struct file *filep, off_t length); - - /* Directory operations */ - - int (*opendir)(struct Vnode *mountpt, const char *relpath, - struct fs_dirent_s *dir); - int (*closedir)(struct Vnode *mountpt, - struct fs_dirent_s *dir); - int (*readdir)(struct Vnode *mountpt, - struct fs_dirent_s *dir); - int (*rewinddir)(struct Vnode *mountpt, - struct fs_dirent_s *dir); - - /* General volume-related mountpoint operations: */ - - int (*bind)(struct Vnode *blkdriver, const void *data, void **handle, const char *realpath); - int (*unbind)(void *handle, struct Vnode **blkdriver); - int (*statfs)(struct Vnode *mountpt, struct statfs *buf); - int (*virstatfs)(struct Vnode *mountpt, const char* relpath, struct statfs *buf); - - /* Operations on paths */ - - int (*unlink)(struct Vnode *mountpt, const char *relpath); - int (*mkdir)(struct Vnode *mountpt, const char *relpath, - mode_t mode); - int (*rmdir)(struct Vnode *mountpt, const char *relpath); - int (*rename)(struct Vnode *mountpt, const char *oldrelpath, - const char *newrelpath); - int (*stat)(struct Vnode *mountpt, const char *relpath, - struct stat *buf); - int (*utime)(struct Vnode *mountpt, const char *relpath, - const struct tm *times); - int (*chattr)(struct Vnode *mountpt, const char *relpath, - struct IATTR *attr); - loff_t (*seek64)(struct file *filep, loff_t offset, int whence); - int (*getlabel)(void *handle, char* label); - int (*fallocate)(struct file *filep, int mode, off_t offset, off_t len); - int (*fallocate64)(struct file *filep, int mode, off64_t offset, off64_t len); - int (*truncate64)(struct file *filep, off64_t length); - int (*fscheck)(struct Vnode *mountpt, const char *relpath, - struct fs_dirent_s *dir); - int (*map_pages)(LosVmMapRegion *region, LosVmPgFault *pgFault); - ssize_t (*writepage)(struct file *filep, const char *buffer, size_t buflen); - /* NOTE: More operations will be needed here to support: disk usage - * stats file stat(), file attributes, file truncation, etc. - */ -}; - -struct drv_data -{ - const void *ops; - mode_t mode; - void *priv; -}; - -/* This structure is provided by a filesystem to describe a mount point. - * Note that this structure differs from file_operations ONLY in the form of - * the open method. Once the file is opened, it can be accessed either as a - * struct file_operations or struct mountpt_operations - */ - -/* file mapped in VMM pages */ -struct page_mapping { - LOS_DL_LIST page_list; /* all pages */ - SPIN_LOCK_S list_lock; /* lock protecting it */ - LosMux mux_lock; /* mutex lock */ - unsigned long nrpages; /* number of total pages */ - unsigned long flags; - Atomic ref; /* reference counting */ - struct file *host; /* owner of this mapping */ -}; - -/* map: full_path(owner) <-> mapping */ -struct file_map { - LOS_DL_LIST head; - LosMux lock; /* lock to protect this mapping */ - struct page_mapping mapping; - int name_len; - char *rename; - char owner[0]; /* owner: full path of file */ -}; -#endif /* CONFIG_DISABLE_MOUNTPOINT */ - -#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION -#define _MAX_ENTRYLENGTH 16 /* MAX virtual partition name length */ -#define _MAX_VIRVOLUMES 5 /* MAX virtual partition number */ -typedef struct virtual_partition_info -{ - char *devpartpath; /* need set virtual partition, e.g. /dev/mmcblk0p0 */ - int virpartnum; /* virtual partition numbers, MAX number is 5 */ - double virpartpercent[_MAX_VIRVOLUMES]; /* every virtual partition percent,e.g 0.6,0.3,0.1 */ - char virpartname[_MAX_VIRVOLUMES][_MAX_ENTRYLENGTH + 1]; /* every virtual partition name, MAX length is 16 */ -} virpartinfo; -#endif - struct fsmap_t { const char *fs_filesystemtype; @@ -392,119 +69,7 @@ struct fsmap_t _l LOS_HAL_TABLE_ENTRY(fsmap) = \ _is_bdfs \ } -/* Named OS resources are also maintained by the VFS. This includes: - * - * - Named semaphores: sem_open(), sem_close(), and sem_unlink() - * - POSIX Message Queues: mq_open() and mq_close() - * - Shared memory: shm_open() and shm_unlink(); - * - * These are a special case in that they do not follow quite the same - * pattern as the other file system types in that they have operations. - */ - -/* These are the various kinds of operations that can be associated with - * an vnode. - */ - -/* This structure represents one vnode in the NuttX pseudo-file system */ - -typedef enum mount_status -{ - STAT_UNMOUNTED = 0, - STAT_MOUNTED, -} MOUNT_STATE; - - -#define FSNODE_SIZE(n) (sizeof(struct Vnode) + (n)) - -/* This is the underlying representation of an open file. A file - * descriptor is an index into an array of such types. The type associates - * the file descriptor to the file state and to a set of vnode operations. - */ - -struct file -{ - unsigned int f_magicnum; /* file magic number */ - int f_oflags; /* Open mode flags */ - struct Vnode *f_vnode; /* Driver interface */ - loff_t f_pos; /* File position */ - unsigned long f_refcount; /* reference count */ - char *f_path; /* File fullpath */ - void *f_priv; /* Per file driver private data */ - const char *f_relpath; /* realpath */ - struct page_mapping *f_mapping; /* mapping file to memory */ - void *f_dir; /* DIR struct for iterate the directory if open a directory */ - const struct file_operations_vfs *ops; - int fd; -}; - -/* This defines a list of files indexed by the file descriptor */ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -struct filelist -{ - sem_t fl_sem; /* Manage access to the file list */ - struct file fl_files[CONFIG_NFILE_DESCRIPTORS]; -}; - -extern struct filelist tg_filelist; -#endif - -/* The following structure defines the list of files used for standard C I/O. - * Note that NuttX can support the standard C APIs with or without buffering - * - * When buffering is used, the following describes the usage of the I/O buffer. - * The buffer can be used for reading or writing -- but not both at the same time. - * An fflush is implied between each change in direction of access. - * - * The field fs_bufread determines whether the buffer is being used for reading or - * for writing as follows: - * - * BUFFER - * +----------------------+ <- fs_bufstart Points to the beginning of the buffer. - * | WR: Buffered data | WR: Start of buffered write data. - * | RD: Already read | RD: Start of already read data. - * +----------------------+ - * | WR: Available buffer | <- fs_bufpos Points to next byte: - * | RD: Read-ahead data | WR: End+1 of buffered write data. - * | | RD: Points to next char to return - * +----------------------+ - * | WR: Available | <- fs_bufread Top+1 of buffered read data - * | RD: Available | WR: bufstart buffer used for writing. - * | | RD: Pointer to last buffered read char+1 - * +----------------------+ - * <- fs_bufend Points to the end of the buffer+1 - */ - -#if CONFIG_NFILE_STREAMS > 0 -struct file_struct -{ - int fs_fd; /* File descriptor associated with stream */ -#if CONFIG_STDIO_BUFFER_SIZE > 0 - sem_t fs_sem; /* For thread safety */ - pid_t fs_holder; /* Holder of sem */ - int fs_counts; /* Number of times sem is held */ - unsigned char *fs_bufstart; /* Pointer to start of buffer */ - unsigned char *fs_bufend; /* Pointer to 1 past end of buffer */ - unsigned char *fs_bufpos; /* Current position in buffer */ - unsigned char *fs_bufread; /* Pointer to 1 past last buffered read char. */ -#endif - uint16_t fs_oflags; /* Open mode flags */ - uint8_t fs_flags; /* Stream flags */ -#if CONFIG_NUNGET_CHARS > 0 - uint8_t fs_nungotten; /* The number of characters buffered for ungetc */ - unsigned char fs_ungotten[CONFIG_NUNGET_CHARS]; -#endif -}; - -struct streamlist -{ - sem_t sl_sem; /* For thread safety */ - struct file_struct sl_streams[CONFIG_NFILE_STREAMS]; -}; - -extern struct streamlist tg_streamlist; -#endif /* CONFIG_NFILE_STREAMS */ +#define FAR /* for hdf compatibility, should remove later */ /**************************************************************************** * Name: fs_initialize @@ -517,601 +82,6 @@ extern struct streamlist tg_streamlist; void fs_initialize(void); -/**************************************************************************** - * Name: register_driver - * - * Description: - * Register a character driver vnode the pseudo file system. - * - * Input Parameters: - * path - The path to the vnode to create - * fops - The file operations structure - * mode - Access privileges (not used) - * priv - Private, user data that will be associated with the vnode. - * - * Returned Value: - * Zero on success (with the vnode point in 'vnode'); A negated errno - * value is returned on a failure (all error values returned by - * vnode_reserve): - * - * EINVAL - 'path' is invalid for this operation - * EEXIST - An vnode already exists at 'path' - * ENOMEM - Failed to allocate in-memory resources for the operation - * - * Attention: - * This function should be called after los_vfs_init has been called. - * The parameter path must point a valid string, which end with the terminating null byte. - * The total length of parameter path must less than the value defined by PATH_MAX. - * The prefix of the parameter path must be /dev/. - * The fops must pointed the right functions, otherwise the system will crash when the device is being operated. - * - ****************************************************************************/ - -int register_driver(const char *path, - const struct file_operations_vfs *fops, mode_t mode, - void *priv); - -/**************************************************************************** - * Name: register_blockdriver - * - * Description: - * Register a block driver vnode the pseudo file system. - * - * Attention: - * This function should be called after los_vfs_init has been called. - * The parameter path must point a valid string, which end with the terminating null byte. - * The length of parameter path must be less than the value defined by PATH_MAX. - * The prefix of the parameter path must be '/dev/'. - * The bops must pointed the right functions, otherwise the system will crash when the device is being operated. - * - * Input Parameters: - * path - The path to the vnode to create - * bops - The block driver operations structure - * mode - Access privileges (not used) - * priv - Private, user data that will be associated with the vnode. - * - * Returned Value: - * Zero on success (with the vnode point in 'vnode'); A negated errno - * value is returned on a failure (all error values returned by - * vnode_reserve): - * - * EINVAL - 'path' is invalid for this operation - * EEXIST - An vnode already exists at 'path' - * ENOMEM - Failed to allocate in-memory resources for the operation - * - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_MOUNTPOINT -int register_blockdriver(const char *path, - const struct block_operations *bops, - mode_t mode, void *priv); -#endif - -/**************************************************************************** - * Name: unregister_driver - * - * Description: - * Remove the character driver vnode at 'path' from the pseudo-file system - * - * Returned Value: - * Zero on success (with the vnode point in 'vnode'); A negated errno - * value is returned on a failure (all error values returned by - * vnode_reserve): - * - * EBUSY - Resource is busy ,not permit for this operation. - * ENOENT - 'path' is invalid for this operation. - * - * Attention: - * This function should be called after register_blockdriver has been called. - * The parameter path must point a valid string, which end with the terminating null byte. - * The total length of parameter path must less than the value defined by PATH_MAX. - * The block device node referred by parameter path must be really exist. - ****************************************************************************/ - -int unregister_driver(const char *path); - -/**************************************************************************** - * Name: unregister_blockdriver - * - * Description: - * Remove the block driver vnode at 'path' from the pseudo-file system - * - * Input Parameters: - * path - The path that the vnode to be destroyed. - * - * Returned Value: - * Zero on success (with the vnode point in 'vnode'); A negated errno - * value is returned on a failure (all error values returned by - * vnode_reserve): - * - * EBUSY - Resource is busy ,not permit for this operation. - * ENOENT - 'path' is invalid for this operation. - * - * Attention: - * This function should be called after register_blockdriver has been called. - * The parameter path must point a valid string, which end with the terminating null byte. - * The total length of parameter path must less than the value defined by PATH_MAX. - * The block device node referred by parameter path must be really exist. - * - ****************************************************************************/ - -int unregister_blockdriver(const char *path); - -/**************************************************************************** - * Name: files_initlist - * - * Description: - * Initializes the list of files for a new task - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -void files_initlist(struct filelist *list); -#endif - -/**************************************************************************** - * Name: files_releaselist - * - * Description: - * Release a reference to the file list - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -void files_releaselist(struct filelist *list); -#endif - -/**************************************************************************** - * Name: file_dup2 - * - * Description: - * Assign an vnode to a specific files structure. This is the heart of - * dup2. - * - * Equivalent to the non-standard fs_dupfd2() function except that it - * accepts struct file instances instead of file descriptors and it does - * not set the errno variable. - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is return on - * any failure. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int file_dup2(struct file *filep1, struct file *filep2); -#endif - -/**************************************************************************** - * Name: fs_dupfd OR dup - * - * Description: - * Clone a file descriptor 'fd' to an arbitrary descriptor number (any value - * greater than or equal to 'minfd'). If socket descriptors are - * implemented, then this is called by dup() for the case of file - * descriptors. If socket descriptors are not implemented, then this - * function IS dup(). - * - * This alternative naming is used when dup could operate on both file and - * socket descriptors to avoid drawing unused socket support into the link. - * - * Returned Value: - * fs_dupfd is sometimes an OS internal function and sometimes is a direct - * substitute for dup(). So it must return an errno value as though it - * were dup(). - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int fs_dupfd(int fd, int minfd); -#endif - -/**************************************************************************** - * Name: file_dup - * - * Description: - * Equivalent to the non-standard fs_dupfd() function except that it - * accepts a struct file instance instead of a file descriptor and does - * not set the errno variable. - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * any failure. - * - ****************************************************************************/ - -int file_dup(struct file *filep, int minfd); - -/**************************************************************************** - * Name: fs_dupfd2 OR dup2 - * - * Description: - * Clone a file descriptor to a specific descriptor number. If socket - * descriptors are implemented, then this is called by dup2() for the - * case of file descriptors. If socket descriptors are not implemented, - * then this function IS dup2(). - * - * This alternative naming is used when dup2 could operate on both file and - * socket descriptors to avoid drawing unused socket support into the link. - * - * Returned Value: - * fs_dupfd2 is sometimes an OS internal function and sometimes is a direct - * substitute for dup2(). So it must return an errno value as though it - * were dup2(). - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int fs_dupfd2(int fd1, int fd2); -#endif - - -/**************************************************************************** - * Name: open_blockdriver - * - * Description: - * Return the vnode of the block driver specified by 'pathname' - * - * Input Parameters: - * pathname - the full path to the block driver to be opened - * mountflags - if MS_RDONLY is not set, then driver must support write - * operations (see include/sys/mount.h) - * ppvnode - address of the location to return the vnode reference - * - * Returned Value: - * Returns zero on success or a negated errno on failure: - * - * EINVAL - pathname or pvnode is NULL - * ENOENT - No block driver of this name is registered - * ENOTBLK - The vnode associated with the pathname is not a block driver - * EACCESS - The MS_RDONLY option was not set but this driver does not - * support write access - * - * Aattention: - * The parameter path must point a valid string, which end with the terminating null byte. - * The total length of parameter path must less than the value defined by PATH_MAX. - * The parameter ppvnode must point a valid memory, which size must be enough for storing struct Vnode. - - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int open_blockdriver(const char *pathname, int mountflags, - struct Vnode **ppvnode); -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: find_blockdriver - * - * Description: - * Return the inode of the block driver specified by 'pathname' - * - * Input Parameters: - * pathname - The full path to the block driver to be located - * mountflags - If MS_RDONLY is not set, then driver must support write - * operations (see include/sys/mount.h) - * ppinode - Address of the location to return the inode reference - * - * Returned Value: - * Returns zero on success or a negated errno on failure: - * - * ENOENT - No block driver of this name is registered - * ENOTBLK - The inode associated with the pathname is not a block driver - * EACCESS - The MS_RDONLY option was not set but this driver does not - * support write access - * - ****************************************************************************/ - -int find_blockdriver(const char *pathname, int mountflags, - struct Vnode **vpp); - - -/**************************************************************************** - * Name: close_blockdriver - * - * Description: - * Call the close method and release the vnode - * - * Input Parameters: - * vnode - reference to the vnode of a block driver opened by open_blockdriver - * - * Returned Value: - * Returns zero on success or a negated errno on failure: - * - * EINVAL - vnode is NULL - * ENOTBLK - The vnode is not a block driver - * - * Attention: - * This function should be called after open_blockdriver has been called. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int close_blockdriver(struct Vnode *vnode); -#endif - -/**************************************************************************** - * Name: fs_ioctl - * - * Description: - * Perform device specific operations. - * - * Input Parameters: - * fd File/socket descriptor of device - * req The ioctl command - * arg The argument of the ioctl cmd - * - * Returned Value: - * >=0 on success (positive non-zero values are cmd-specific) - * -1 on failure with errno set properly: - * - * EBADF - * 'fd' is not a valid descriptor. - * EFAULT - * 'arg' references an inaccessible memory area. - * EINVAL - * 'cmd' or 'arg' is not valid. - * ENOTTY - * 'fd' is not associated with a character special device. - * ENOTTY - * The specified request does not apply to the kind of object that the - * descriptor 'fd' references. - * - ****************************************************************************/ - -#ifdef CONFIG_LIBC_IOCTL_VARIADIC -int fs_ioctl(int fd, int req, unsigned long arg); -#endif - -/**************************************************************************** - * Name: fs_fdopen - * - * Description: - * This function does the core operations for fopen and fdopen. It is - * used by the OS to clone stdin, stdout, stderr - * - ****************************************************************************/ - -#if CONFIG_NFILE_STREAMS > 0 -struct tcb_s; /* Forward reference */ -struct file_struct *fs_fdopen(int fd, int oflags); -#endif - -/**************************************************************************** - * Name: lib_flushall - * - * Description: - * Called either (1) by the OS when a task exits, or (2) from fflush() - * when a NULL stream argument is provided. - * - ****************************************************************************/ - -#if CONFIG_NFILE_STREAMS > 0 -int lib_flushall(struct streamlist *list); -#endif - -/**************************************************************************** - * Name: lib_sendfile - * - * Description: - * Transfer a file - * - ****************************************************************************/ - -#ifdef CONFIG_NET_SENDFILE -ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count); -#endif - -/**************************************************************************** - * Name: fs_getfilep - * - * Description: - * Given a file descriptor, return the corresponding instance of struct - * file. NOTE that this function will currently fail if it is provided - * with a socket descriptor. - * - * Input Parameters: - * fd - The file descriptor - * filep - The location to return the struct file instance - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * any failure. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int fs_getfilep(int fd, struct file **filep); -#endif - -/**************************************************************************** - * Name: file_read - * - * Description: - * file_read() is an internal OS interface. It is functionally similar to - * the standard read() interface except: - * - * - It does not modify the errno variable, - * - It is not a cancellation point, - * - It does not handle socket descriptors, and - * - It accepts a file structure instance instead of file descriptor. - * - * Input Parameters: - * filep - File structure instance - * buf - User-provided to save the data - * nbytes - The maximum size of the user-provided buffer - * - * Returned Value: - * The positive non-zero number of bytes read on success, 0 on if an - * end-of-file condition, or a negated errno value on any failure. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -ssize_t file_read(struct file *filep, void *buf, size_t nbytes); -#endif - -/**************************************************************************** - * Name: file_write - * - * Description: - * Equivalent to the standard write() function except that is accepts a - * struct file instance instead of a file descriptor. Currently used - * only by aio_write(); - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -ssize_t file_write(struct file *filep, const void *buf, size_t nbytes); -#endif - -/**************************************************************************** - * Name: file_pread - * - * Description: - * Equivalent to the standard pread function except that is accepts a - * struct file instance instead of a file descriptor. Currently used - * only by aio_read(); - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -ssize_t file_pread(struct file *filep, void *buf, size_t nbytes, - off_t offset); -#endif - -/**************************************************************************** - * Name: file_pwrite - * - * Description: - * Equivalent to the standard pwrite function except that is accepts a - * struct file instance instead of a file descriptor. Currently used - * only by aio_write(); - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -ssize_t file_pwrite(struct file *filep, const void *buf, - size_t nbytes, off_t offset); -#endif - -/**************************************************************************** - * Name: file_seek - * - * Description: - * Equivalent to the standard lseek() function except that is accepts a - * struct file instance instead of a file descriptor. Currently used - * only by net_sendfile() - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -off_t file_seek(struct file *filep, off_t offset, int whence); -#endif - -/**************************************************************************** - * Name: file_fsync - * - * Description: - * Equivalent to the standard fsync() function except that is accepts a - * struct file instance instead of a file descriptor and it does not set - * the errno variable. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int file_fsync(struct file *filep); -#endif - -/**************************************************************************** - * Name: file_vfcntl - * - * Description: - * Similar to the standard vfcntl function except that is accepts a struct - * struct file instance instead of a file descriptor. - * - * Input Parameters: - * filep - Instance for struct file for the opened file. - * cmd - Indentifies the operation to be performed. - * ap - Variable argument following the command. - * - * Returned Value: - * The nature of the return value depends on the command. Non-negative - * values indicate success. Failures are reported as negated errno - * values. - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -int file_vfcntl(struct file *filep, int cmd, va_list ap); -#endif - -/**************************************************************************** - * Name: file_seek64 - * - * Description: - * Equivalent to the standard lseek64() function except that is accepts a - * struct file instance instead of a file descriptor. Currently used - * only by net_sendfile() - * - ****************************************************************************/ - -#if CONFIG_NFILE_DESCRIPTORS > 0 -off64_t file_seek64(struct file *filep, off64_t offset, int whence); -#endif - -/**************************************************************************** - * Name: files_allocate - * - * Description: - * Allocate a struct files instance and associate it with an vnode instance. - * Returns the file descriptor == index into the files array. - * - ****************************************************************************/ - -int files_allocate(struct Vnode *vnode, int oflags, off_t pos,void *priv, int minfd); - -/**************************************************************************** - * Name: files_close - * - * Description: - * Close an vnode (if open) - * - * Assumuptions: - * Caller holds the list semaphore because the file descriptor will be freed. - * - ****************************************************************************/ - -int files_close(int fd); - -/**************************************************************************** - * Name: files_release - * - * Assumuptions: - * Similar to files_close(). Called only from open() logic on error - * conditions. - * - ****************************************************************************/ - -void files_release(int fd); - -/**************************************************************************** - * Name: files_initialize - * - * Description: - * This is called from the FS initialization logic to configure the files. - * - ****************************************************************************/ - -void weak_function files_initialize(void); - -int vfs_normalize_path(const char *directory, const char *filename, char **pathname); -int vfs_normalize_pathat(int fd, const char *filename, char **pathname); -int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **fullpath); - #ifdef __cplusplus #if __cplusplus } diff --git a/include/nuttx/video/fb.h b/include/nuttx/video/fb.h index 1c8a06a4bbaae5eab459372e2522d67437cf074c..2a212d189accb131df23b27ae7525a9609bf7fd9 100755 --- a/include/nuttx/video/fb.h +++ b/include/nuttx/video/fb.h @@ -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