Browse Source

[components][dfs]格式化代码

tangyuxin 6 years ago
parent
commit
e71ec65549

+ 10 - 10
components/dfs/filesystems/devfs/devfs.c

@@ -97,7 +97,7 @@ int dfs_device_fs_close(struct dfs_fd *file)
 
         root_dirent = (struct device_dirent *)file->data;
         RT_ASSERT(root_dirent != RT_NULL);
-        
+
         /* release dirent */
         rt_free(root_dirent);
         return RT_EOK;
@@ -133,7 +133,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
         struct rt_object_information *information;
         struct device_dirent *root_dirent;
         rt_uint32_t count = 0;
-        
+
         /* lock scheduler */
         rt_enter_critical();
 
@@ -145,8 +145,8 @@ int dfs_device_fs_open(struct dfs_fd *file)
             count ++;
         }
 
-        root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) + 
-            count * sizeof(rt_device_t));
+        root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) +
+                      count * sizeof(rt_device_t));
         if (root_dirent != RT_NULL)
         {
             root_dirent->devices = (rt_device_t *)(root_dirent + 1);
@@ -165,7 +165,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
 
         /* set data */
         file->data = root_dirent;
-        
+
         return RT_EOK;
     }
 
@@ -178,7 +178,7 @@ int dfs_device_fs_open(struct dfs_fd *file)
     {
         /* use device fops */
         file->fops = device->fops;
-        file->data = (void*)device;
+        file->data = (void *)device;
 
         /* use fops */
         if (file->fops->open)
@@ -214,7 +214,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
         st->st_dev = 0;
 
         st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH |
-            S_IWUSR | S_IWGRP | S_IWOTH;
+                      S_IWUSR | S_IWGRP | S_IWOTH;
         st->st_mode &= ~S_IFREG;
         st->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
 
@@ -233,7 +233,7 @@ int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat
             st->st_dev = 0;
 
             st->st_mode = S_IRUSR | S_IRGRP | S_IROTH |
-                S_IWUSR | S_IWGRP | S_IWOTH;
+                          S_IWUSR | S_IWGRP | S_IWOTH;
 
             if (dev_id->type == RT_Device_Class_Char)
                 st->st_mode |= S_IFCHR;
@@ -293,7 +293,7 @@ static int dfs_device_fs_poll(struct dfs_fd *fd, struct rt_pollreq *req)
     return mask;
 }
 
-static const struct dfs_file_ops _device_fops = 
+static const struct dfs_file_ops _device_fops =
 {
     dfs_device_fs_open,
     dfs_device_fs_close,
@@ -306,7 +306,7 @@ static const struct dfs_file_ops _device_fops =
     dfs_device_fs_poll,
 };
 
-static const struct dfs_filesystem_ops _device_fs = 
+static const struct dfs_filesystem_ops _device_fs =
 {
     "devfs",
     DFS_FS_FLAG_DEFAULT,

+ 24 - 22
components/dfs/filesystems/elmfat/dfs_elm.c

@@ -101,7 +101,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
     FRESULT result;
     int index;
     struct rt_device_blk_geometry geometry;
-    char logic_nbr[2] = {'0',':'};
+    char logic_nbr[2] = {'0', ':'};
 
     /* get an empty position */
     index = get_disk(RT_NULL);
@@ -129,7 +129,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
     }
 
     /* mount fatfs, always 0 logic driver */
-    result = f_mount(fat, (const TCHAR*)logic_nbr, 1);
+    result = f_mount(fat, (const TCHAR *)logic_nbr, 1);
     if (result == FR_OK)
     {
         char drive[8];
@@ -139,7 +139,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
         dir = (DIR *)rt_malloc(sizeof(DIR));
         if (dir == RT_NULL)
         {
-            f_mount(RT_NULL, (const TCHAR*)logic_nbr, 1);
+            f_mount(RT_NULL, (const TCHAR *)logic_nbr, 1);
             disk[index] = RT_NULL;
             rt_free(fat);
             return -ENOMEM;
@@ -157,7 +157,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
     }
 
 __err:
-    f_mount(RT_NULL, (const TCHAR*)logic_nbr, 1);
+    f_mount(RT_NULL, (const TCHAR *)logic_nbr, 1);
     disk[index] = RT_NULL;
     rt_free(fat);
     return elm_result_to_dfs(result);
@@ -168,7 +168,7 @@ int dfs_elm_unmount(struct dfs_filesystem *fs)
     FATFS *fat;
     FRESULT result;
     int  index;
-    char logic_nbr[2] = {'0',':'};
+    char logic_nbr[2] = {'0', ':'};
 
     fat = (FATFS *)fs->data;
 
@@ -180,7 +180,7 @@ int dfs_elm_unmount(struct dfs_filesystem *fs)
         return -ENOENT;
 
     logic_nbr[0] = '0' + index;
-    result = f_mount(RT_NULL, logic_nbr, (BYTE)1); 
+    result = f_mount(RT_NULL, logic_nbr, (BYTE)1);
     if (result != FR_OK)
         return elm_result_to_dfs(result);
 
@@ -200,10 +200,11 @@ int dfs_elm_mkfs(rt_device_t dev_id)
     int flag;
     FRESULT result;
     int index;
-    char logic_nbr[2] = {'0',':'};
-    
+    char logic_nbr[2] = {'0', ':'};
+
     work = rt_malloc(_MAX_SS);
-    if(RT_NULL == work) {
+    if (RT_NULL == work)
+    {
         return -ENOMEM;
     }
 
@@ -265,14 +266,15 @@ int dfs_elm_mkfs(rt_device_t dev_id)
     /* [IN] Size of the allocation unit */
     /* [-]  Working buffer */
     /* [IN] Size of working buffer */
-    result = f_mkfs(logic_nbr, FM_ANY|FM_SFD, 0, work, _MAX_SS);
-    rt_free(work); work = RT_NULL;
+    result = f_mkfs(logic_nbr, FM_ANY | FM_SFD, 0, work, _MAX_SS);
+    rt_free(work);
+    work = RT_NULL;
 
     /* check flag status, we need clear the temp driver stored in disk[] */
     if (flag == FSM_STATUS_USE_TEMP_DRIVER)
     {
         rt_free(fat);
-        f_mount(RT_NULL, logic_nbr,(BYTE)index);
+        f_mount(RT_NULL, logic_nbr, (BYTE)index);
         disk[index] = RT_NULL;
         /* close device */
         rt_device_close(dev_id);
@@ -778,7 +780,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
     return elm_result_to_dfs(result);
 }
 
-static const struct dfs_file_ops dfs_elm_fops = 
+static const struct dfs_file_ops dfs_elm_fops =
 {
     dfs_elm_open,
     dfs_elm_close,
@@ -834,7 +836,7 @@ DSTATUS disk_status(BYTE drv)
 }
 
 /* Read Sector(s) */
-DRESULT disk_read (BYTE drv, BYTE* buff, DWORD sector, UINT count)
+DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
 {
     rt_size_t result;
     rt_device_t device = disk[drv];
@@ -849,7 +851,7 @@ DRESULT disk_read (BYTE drv, BYTE* buff, DWORD sector, UINT count)
 }
 
 /* Write Sector(s) */
-DRESULT disk_write (BYTE drv, const BYTE* buff, DWORD sector, UINT count)
+DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, UINT count)
 {
     rt_size_t result;
     rt_device_t device = disk[drv];
@@ -916,7 +918,7 @@ DWORD get_fattime(void)
 {
     DWORD fat_time = 0;
 
-#ifdef RT_USING_LIBC 
+#ifdef RT_USING_LIBC
     time_t now;
     struct tm *p_tm;
     struct tm tm_now;
@@ -933,12 +935,12 @@ DWORD get_fattime(void)
     /* unlock scheduler. */
     rt_exit_critical();
 
-    fat_time =  (DWORD)(tm_now.tm_year - 80) << 25 |
-                (DWORD)(tm_now.tm_mon + 1)   << 21 |
-                (DWORD)tm_now.tm_mday        << 16 |
-                (DWORD)tm_now.tm_hour        << 11 |
-                (DWORD)tm_now.tm_min         <<  5 |
-                (DWORD)tm_now.tm_sec / 2 ;
+    fat_time = (DWORD)(tm_now.tm_year - 80) << 25 |
+               (DWORD)(tm_now.tm_mon + 1)   << 21 |
+               (DWORD)tm_now.tm_mday        << 16 |
+               (DWORD)tm_now.tm_hour        << 11 |
+               (DWORD)tm_now.tm_min         <<  5 |
+               (DWORD)tm_now.tm_sec / 2 ;
 #endif /* RT_USING_LIBC  */
 
     return fat_time;

+ 53 - 49
components/dfs/filesystems/nfs/dfs_nfs.c

@@ -6,7 +6,7 @@
  * Change Logs:
  * Date           Author       Notes
  */
- 
+
 #include <stdio.h>
 #include <rtthread.h>
 #include <dfs_fs.h>
@@ -65,9 +65,9 @@ typedef struct nfs_dir nfs_dir;
 
 nfs_dir *nfs_opendir(nfs_filesystem *nfs, const char *path);
 
-static int nfs_parse_host_export(const char *host_export, 
+static int nfs_parse_host_export(const char *host_export,
                                  char       *host,
-                                 size_t      host_len, 
+                                 size_t      host_len,
                                  char       *export,
                                  size_t      export_len)
 {
@@ -99,7 +99,7 @@ static int nfs_parse_host_export(const char *host_export,
     /* copy export path */
     for (index = host_len; index < host_len + export_len; index ++)
     {
-        if (host_export[index] == 0) 
+        if (host_export[index] == 0)
         {
             export[index - host_len] = '\0';
 
@@ -133,11 +133,11 @@ static nfs_fh3 *get_handle(nfs_filesystem *nfs, const char *name)
     char *path;
     char *init;
 
-    init = path = rt_malloc(strlen(name)+1);
+    init = path = rt_malloc(strlen(name) + 1);
     if (init == NULL)
         return NULL;
 
-    memcpy(init, name, strlen(name)+1);
+    memcpy(init, name, strlen(name) + 1);
 
     handle = rt_malloc(sizeof(nfs_fh3));
     if (handle == NULL)
@@ -202,10 +202,10 @@ static nfs_fh3 *get_dir_handle(nfs_filesystem *nfs, const char *name)
     char *path;
     char *init;
 
-    init = path = rt_malloc(strlen(name)+1);
+    init = path = rt_malloc(strlen(name) + 1);
     if (init == NULL)
         return NULL;
-    memcpy(init, name, strlen(name)+1);
+    memcpy(init, name, strlen(name) + 1);
 
     handle = rt_malloc(sizeof(nfs_fh3));
     if (handle == NULL)
@@ -274,7 +274,7 @@ static size_t nfs_get_filesize(nfs_filesystem *nfs, nfs_fh3 *handle)
 
     memset(&res, '\0', sizeof(res));
 
-    if ((nfsproc3_getattr_3(args, &res, nfs->nfs_client)!=RPC_SUCCESS) ||
+    if ((nfsproc3_getattr_3(args, &res, nfs->nfs_client) != RPC_SUCCESS) ||
         res.status != NFS3_OK)
     {
         rt_kprintf("GetAttr failed: %d\n", res.status);
@@ -285,7 +285,7 @@ static size_t nfs_get_filesize(nfs_filesystem *nfs, nfs_fh3 *handle)
     info = &res.GETATTR3res_u.resok.obj_attributes;
     size = info->size;
     xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res);
-    
+
     return size;
 }
 
@@ -319,7 +319,7 @@ rt_bool_t nfs_is_directory(nfs_filesystem *nfs, const char *name)
         return RT_FALSE;
     }
 
-    info=&res.GETATTR3res_u.resok.obj_attributes;
+    info = &res.GETATTR3res_u.resok.obj_attributes;
 
     if (info->type == NFS3DIR)
         result = RT_TRUE;
@@ -327,7 +327,7 @@ rt_bool_t nfs_is_directory(nfs_filesystem *nfs, const char *name)
     xdr_free((xdrproc_t)xdr_GETATTR3res, (char *)&res);
     xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
     rt_free(handle);
-    
+
     return result;
 }
 
@@ -427,7 +427,7 @@ int nfs_mkdir(nfs_filesystem *nfs, const char *name, mode_t mode)
     xdr_free((xdrproc_t)xdr_MKDIR3res, (char *)&res);
     xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
     rt_free(handle);
-    
+
     return ret;
 }
 
@@ -441,13 +441,13 @@ int nfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
     memset(nfs, 0, sizeof(nfs_filesystem));
 
     if (nfs_parse_host_export((const char *)data, nfs->host, HOST_LENGTH,
-        nfs->export, EXPORT_PATH_LENGTH) < 0)
+                              nfs->export, EXPORT_PATH_LENGTH) < 0)
     {
         rt_kprintf("host or export path error\n");
         goto __return;
     }
 
-    nfs->mount_client=clnt_create((char *)nfs->host, MOUNT_PROGRAM, MOUNT_V3, "udp");
+    nfs->mount_client = clnt_create((char *)nfs->host, MOUNT_PROGRAM, MOUNT_V3, "udp");
     if (nfs->mount_client == NULL)
     {
         rt_kprintf("create mount client failed\n");
@@ -465,7 +465,7 @@ int nfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
         rt_kprintf("nfs mount failed\n");
         goto __return;
     }
-    nfs->nfs_client=clnt_create((char *)nfs->host, NFS_PROGRAM, NFS_V3, "udp");
+    nfs->nfs_client = clnt_create((char *)nfs->host, NFS_PROGRAM, NFS_V3, "udp");
     if (nfs->nfs_client == NULL)
     {
         rt_kprintf("creat nfs client failed\n");
@@ -555,7 +555,7 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
 {
     READ3args args;
     READ3res res;
-    ssize_t bytes, total=0;
+    ssize_t bytes, total = 0;
     nfs_file *fd;
     nfs_filesystem *nfs;
 
@@ -564,8 +564,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
 
 
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
     fd = (nfs_file *)(nfs->data);
     RT_ASSERT(fd != NULL);
 
@@ -577,7 +577,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
         return 0;
 
     args.file = fd->handle;
-    do {
+    do
+    {
         args.offset = fd->offset;
         args.count = count > DFS_NFS_MAX_MTU ? DFS_NFS_MAX_MTU : count;
         count -= args.count;
@@ -612,7 +613,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
             }
         }
         xdr_free((xdrproc_t)xdr_READ3res, (char *)&res);
-    } while(count > 0);
+    }
+    while (count > 0);
 
     xdr_free((xdrproc_t)xdr_READ3res, (char *)&res);
 
@@ -623,7 +625,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
 {
     WRITE3args args;
     WRITE3res res;
-    ssize_t bytes, total=0;
+    ssize_t bytes, total = 0;
     nfs_file *fd;
     nfs_filesystem *nfs;
 
@@ -631,8 +633,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
         return -EISDIR;
 
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
     fd = (nfs_file *)(nfs->data);
     RT_ASSERT(fd != NULL);
 
@@ -642,11 +644,12 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
     args.file = fd->handle;
     args.stable = FILE_SYNC;
 
-    do {
+    do
+    {
         args.offset = fd->offset;
 
         memset(&res, 0, sizeof(res));
-        args.data.data_val=(void *)buf;
+        args.data.data_val = (void *)buf;
         args.count = count > DFS_NFS_MAX_MTU ? DFS_NFS_MAX_MTU : count;
         args.data.data_len = args.count;
         count -= args.count;
@@ -676,7 +679,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
             file->size = fd->size;
         }
         xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
-    } while (count > 0);
+    }
+    while (count > 0);
 
     xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
 
@@ -692,8 +696,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
         return -EISDIR;
 
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
     fd = (nfs_file *)(nfs->data);
     RT_ASSERT(fd != NULL);
 
@@ -711,8 +715,8 @@ int nfs_close(struct dfs_fd *file)
 {
     nfs_filesystem *nfs;
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
 
     if (file->type == FT_DIRECTORY)
     {
@@ -741,14 +745,14 @@ int nfs_open(struct dfs_fd *file)
 {
     nfs_filesystem *nfs;
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
 
 
     if (file->flags & O_DIRECTORY)
     {
         nfs_dir *dir;
-    
+
         if (file->flags & O_CREAT)
         {
             if (nfs_mkdir(nfs, file->path, 0755) < 0)
@@ -930,7 +934,7 @@ char *nfs_readdir(nfs_filesystem *nfs, nfs_dir *dir)
         return NULL;
 
     dir->cookie = dir->entry->cookie;
-    strncpy(name, dir->entry->name, NAME_MAX-1);
+    strncpy(name, dir->entry->name, NAME_MAX - 1);
     dir->entry = dir->entry->nextentry;
     name[NAME_MAX - 1] = '\0';
 
@@ -1013,7 +1017,7 @@ int nfs_unlink(struct dfs_filesystem *fs, const char *path)
 
         xdr_free((xdrproc_t)xdr_RMDIR3res, (char *)&res);
         xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)handle);
-        rt_free(handle);    
+        rt_free(handle);
     }
 
     return ret;
@@ -1083,8 +1087,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
 
 
     RT_ASSERT(file->data != NULL);
-    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem*)(file->data));
-    nfs = (struct nfs_filesystem *)(dfs_nfs->data); 
+    struct dfs_filesystem *dfs_nfs  = ((struct dfs_filesystem *)(file->data));
+    nfs = (struct nfs_filesystem *)(dfs_nfs->data);
     dir = (nfs_dir *)(nfs->data);
     RT_ASSERT(dir != NULL);
 
@@ -1118,18 +1122,18 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
 
 static const struct dfs_file_ops nfs_fops =
 {
-        nfs_open,
-        nfs_close,
-        nfs_ioctl,
-        nfs_read,
-        nfs_write,
-        NULL, /* flush */
-        nfs_lseek,
-        nfs_getdents,
-        NULL, /* poll */
+    nfs_open,
+    nfs_close,
+    nfs_ioctl,
+    nfs_read,
+    nfs_write,
+    NULL, /* flush */
+    nfs_lseek,
+    nfs_getdents,
+    NULL, /* poll */
 };
 
-static const struct dfs_filesystem_ops _nfs = 
+static const struct dfs_filesystem_ops _nfs =
 {
     "nfs",
     DFS_FS_FLAG_DEFAULT,
@@ -1138,7 +1142,7 @@ static const struct dfs_filesystem_ops _nfs =
     nfs_unmount,
     NULL, /* mkfs */
     NULL, /* statfs */
-    nfs_unlink, 
+    nfs_unlink,
     nfs_stat,
     nfs_rename,
 };

+ 9 - 9
components/dfs/filesystems/ramfs/dfs_ramfs.c

@@ -21,14 +21,14 @@ int dfs_ramfs_mount(struct dfs_filesystem *fs,
                     unsigned long          rwflag,
                     const void            *data)
 {
-    struct dfs_ramfs* ramfs;
+    struct dfs_ramfs *ramfs;
 
     if (data == NULL)
         return -EIO;
 
     ramfs = (struct dfs_ramfs *)data;
     fs->data = ramfs;
-    
+
     return RT_EOK;
 }
 
@@ -48,8 +48,8 @@ int dfs_ramfs_statfs(struct dfs_filesystem *fs, struct statfs *buf)
     RT_ASSERT(buf != NULL);
 
     buf->f_bsize  = 512;
-    buf->f_blocks = ramfs->memheap.pool_size/512;
-    buf->f_bfree  = ramfs->memheap.available_size/512;
+    buf->f_blocks = ramfs->memheap.pool_size / 512;
+    buf->f_bfree  = ramfs->memheap.available_size / 512;
 
     return RT_EOK;
 }
@@ -119,7 +119,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
     struct ramfs_dirent *dirent;
     struct dfs_ramfs *ramfs;
 
-    dirent = (struct ramfs_dirent*)fd->data;
+    dirent = (struct ramfs_dirent *)fd->data;
     RT_ASSERT(dirent != NULL);
 
     ramfs = dirent->fs;
@@ -260,7 +260,7 @@ int dfs_ramfs_open(struct dfs_fd *file)
     file->size = dirent->size;
     if (file->flags & O_APPEND)
         file->pos = file->size;
-    else 
+    else
         file->pos = 0;
 
     return 0;
@@ -381,7 +381,7 @@ int dfs_ramfs_rename(struct dfs_filesystem *fs,
     return RT_EOK;
 }
 
-static const struct dfs_file_ops _ram_fops = 
+static const struct dfs_file_ops _ram_fops =
 {
     dfs_ramfs_open,
     dfs_ramfs_close,
@@ -418,7 +418,7 @@ int dfs_ramfs_init(void)
 }
 INIT_COMPONENT_EXPORT(dfs_ramfs_init);
 
-struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
+struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
 {
     struct dfs_ramfs *ramfs;
     rt_uint8_t *data_ptr;
@@ -435,7 +435,7 @@ struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
     if (result != RT_EOK)
         return NULL;
     /* detach this memheap object from the system */
-    rt_object_detach((rt_object_t)&(ramfs->memheap));
+    rt_object_detach((rt_object_t) & (ramfs->memheap));
 
     /* initialize ramfs object */
     ramfs->magic = RAMFS_MAGIC;

+ 2 - 2
components/dfs/filesystems/ramfs/dfs_ramfs.h

@@ -24,7 +24,7 @@ struct ramfs_dirent
     struct dfs_ramfs *fs;       /* file system ref */
 
     char name[RAMFS_NAME_MAX];  /* dirent name */
-    rt_uint8_t* data;
+    rt_uint8_t *data;
 
     rt_size_t size;             /* file size */
 };
@@ -41,7 +41,7 @@ struct dfs_ramfs
 };
 
 int dfs_ramfs_init(void);
-struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t* pool, rt_size_t size);
+struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);
 
 #endif
 

+ 2 - 2
components/dfs/filesystems/romfs/dfs_romfs.c

@@ -105,7 +105,7 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
                 if (dirent[index].type == ROMFS_DIRENT_DIR)
                 {
                     /* enter directory */
-                    dirent = (struct romfs_dirent*)dirent[index].data;
+                    dirent = (struct romfs_dirent *)dirent[index].data;
                     found = 1;
                     break;
                 }
@@ -226,7 +226,7 @@ int dfs_romfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
 
     st->st_dev = 0;
     st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH |
-    S_IWUSR | S_IWGRP | S_IWOTH;
+                  S_IWUSR | S_IWGRP | S_IWOTH;
 
     if (dirent->type == ROMFS_DIRENT_DIR)
     {

+ 2 - 2
components/dfs/filesystems/romfs/dfs_romfs.h

@@ -13,8 +13,8 @@
 
 #include <rtthread.h>
 
-#define ROMFS_DIRENT_FILE	0x00
-#define ROMFS_DIRENT_DIR	0x01
+#define ROMFS_DIRENT_FILE   0x00
+#define ROMFS_DIRENT_DIR    0x01
 
 struct romfs_dirent
 {

+ 4 - 4
components/dfs/filesystems/romfs/romfs.c

@@ -12,7 +12,7 @@
 
 const static unsigned char _dummy_dummy_txt[] =
 {
-    0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,0x0a,
+    0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x21, 0x0d, 0x0a,
 };
 
 const static struct romfs_dirent _dummy[] =
@@ -22,17 +22,17 @@ const static struct romfs_dirent _dummy[] =
 
 const static unsigned char _dummy_txt[] =
 {
-    0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,0x0a,
+    0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x21, 0x0d, 0x0a,
 };
 
 RT_WEAK const struct romfs_dirent _root_dirent[] =
 {
-    {ROMFS_DIRENT_DIR, "dummy", (rt_uint8_t *)_dummy, sizeof(_dummy)/sizeof(_dummy[0])},
+    {ROMFS_DIRENT_DIR, "dummy", (rt_uint8_t *)_dummy, sizeof(_dummy) / sizeof(_dummy[0])},
     {ROMFS_DIRENT_FILE, "dummy.txt", _dummy_txt, sizeof(_dummy_txt)},
 };
 
 RT_WEAK const struct romfs_dirent romfs_root =
 {
-    ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_root_dirent, sizeof(_root_dirent)/sizeof(_root_dirent[0])
+    ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_root_dirent, sizeof(_root_dirent) / sizeof(_root_dirent[0])
 };
 

+ 10 - 10
components/dfs/filesystems/skeleton/skeleton.c

@@ -14,52 +14,52 @@
 
 #include "dfs_skt_fs.h"
 
-int dfs_skt_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void* data)
+int dfs_skt_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
 {
     return RT_EOK;
 }
 
-int dfs_skt_unmount(struct dfs_filesystem* fs)
+int dfs_skt_unmount(struct dfs_filesystem *fs)
 {
     return RT_EOK;
 }
 
-int dfs_skt_ioctl(struct dfs_fd* file, int cmd, void* args)
+int dfs_skt_ioctl(struct dfs_fd *file, int cmd, void *args)
 {
     return -RT_EIO;
 }
 
-int dfs_skt_read(struct dfs_fd* file, void *buf, rt_size_t count)
+int dfs_skt_read(struct dfs_fd *file, void *buf, rt_size_t count)
 {
     return count;
 }
 
-int dfs_skt_lseek(struct dfs_fd* file, rt_off_t offset)
+int dfs_skt_lseek(struct dfs_fd *file, rt_off_t offset)
 {
     return -RT_EIO;
 }
 
-int dfs_skt_close(struct dfs_fd* file)
+int dfs_skt_close(struct dfs_fd *file)
 {
     return RT_EOK;
 }
 
-int dfs_skt_open(struct dfs_fd* file)
+int dfs_skt_open(struct dfs_fd *file)
 {
     return RT_EOK;
 }
 
-int dfs_skt_stat(struct dfs_filesystem* fs, const char *path, struct stat *st)
+int dfs_skt_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
 {
     return RT_EOK;
 }
 
-int dfs_skt_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count)
+int dfs_skt_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
 {
     return count * sizeof(struct dirent);
 }
 
-static const struct dfs_file_ops _skt_fops = 
+static const struct dfs_file_ops _skt_fops =
 {
     dfs_skt_open,
     dfs_skt_close,

+ 67 - 67
components/dfs/filesystems/uffs/dfs_uffs.c

@@ -33,12 +33,12 @@
 
 struct _nand_dev
 {
-    struct rt_mtd_nand_device * dev;
+    struct rt_mtd_nand_device *dev;
     struct uffs_StorageAttrSt storage;
     uffs_Device uffs_dev;
     uffs_MountTable mount_table;
     char mount_path[UFFS_MOUNT_PATH_MAX];
-    void * data;  /* when uffs use static buf, it will save ptr here */ 
+    void *data;   /* when uffs use static buf, it will save ptr here */
 };
 /* make sure the following struct var had been initilased to 0! */
 static struct _nand_dev nand_part[UFFS_DEVICE_MAX] = {0};
@@ -109,11 +109,11 @@ static URET _device_release(uffs_Device *dev)
 }
 
 static int init_uffs_fs(
-    struct _nand_dev * nand_part)
+    struct _nand_dev *nand_part)
 {
-    uffs_MountTable * mtb;
-    struct rt_mtd_nand_device * nand;
-    struct uffs_StorageAttrSt * flash_storage;
+    uffs_MountTable *mtb;
+    struct rt_mtd_nand_device *nand;
+    struct uffs_StorageAttrSt *flash_storage;
 
     mtb = &nand_part->mount_table;
     nand = nand_part->dev;
@@ -123,7 +123,7 @@ static int init_uffs_fs(
     uffs_setup_storage(flash_storage, nand);
 
     /* register mount table */
-    if(mtb->dev)
+    if (mtb->dev)
     {
         /* set memory allocator for uffs */
 #if CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR > 0
@@ -141,15 +141,15 @@ static int init_uffs_fs(
 }
 
 static int dfs_uffs_mount(
-    struct dfs_filesystem* fs,
+    struct dfs_filesystem *fs,
     unsigned long rwflag,
-    const void* data)
+    const void *data)
 {
     rt_base_t index;
-    uffs_MountTable * mount_part;
-    struct rt_mtd_nand_device * dev;
-    
-    RT_ASSERT(rt_strlen(fs->path) < (UFFS_MOUNT_PATH_MAX-1));
+    uffs_MountTable *mount_part;
+    struct rt_mtd_nand_device *dev;
+
+    RT_ASSERT(rt_strlen(fs->path) < (UFFS_MOUNT_PATH_MAX - 1));
     dev = RT_MTD_NAND_DEVICE(fs->dev_id);
 
     /*1. find a empty entry in partition table */
@@ -184,7 +184,7 @@ static int dfs_uffs_mount(
     return 0;
 }
 
-static int dfs_uffs_unmount(struct dfs_filesystem* fs)
+static int dfs_uffs_unmount(struct dfs_filesystem *fs)
 {
     rt_base_t index;
     int result;
@@ -210,7 +210,7 @@ static int dfs_uffs_mkfs(rt_device_t dev_id)
 {
     rt_base_t index;
     rt_uint32_t block;
-    struct rt_mtd_nand_device * mtd;
+    struct rt_mtd_nand_device *mtd;
 
     /*1. find the device index */
     for (index = 0; index < UFFS_DEVICE_MAX; index++)
@@ -249,11 +249,11 @@ static int dfs_uffs_mkfs(rt_device_t dev_id)
     return RT_EOK;
 }
 
-static int dfs_uffs_statfs(struct dfs_filesystem* fs,
-                    struct statfs *buf)
+static int dfs_uffs_statfs(struct dfs_filesystem *fs,
+                           struct statfs *buf)
 {
     rt_base_t index;
-    struct rt_mtd_nand_device * mtd = RT_MTD_NAND_DEVICE(fs->dev_id);
+    struct rt_mtd_nand_device *mtd = RT_MTD_NAND_DEVICE(fs->dev_id);
 
     RT_ASSERT(mtd != RT_NULL);
 
@@ -265,24 +265,24 @@ static int dfs_uffs_statfs(struct dfs_filesystem* fs,
     }
     if (index == UFFS_DEVICE_MAX)
         return -ENOENT;
-    
-    buf->f_bsize = mtd->page_size*mtd->pages_per_block;
+
+    buf->f_bsize = mtd->page_size * mtd->pages_per_block;
     buf->f_blocks = (mtd->block_end - mtd->block_start + 1);
-    buf->f_bfree = uffs_GetDeviceFree(&nand_part[index].uffs_dev)/buf->f_bsize ;
-    
+    buf->f_bfree = uffs_GetDeviceFree(&nand_part[index].uffs_dev) / buf->f_bsize ;
+
     return 0;
 }
 
-static int dfs_uffs_open(struct dfs_fd* file)
+static int dfs_uffs_open(struct dfs_fd *file)
 {
     int fd;
     int oflag, mode;
-    char * file_path;
+    char *file_path;
 
     oflag = file->flags;
     if (oflag & O_DIRECTORY)   /* operations about dir */
     {
-        uffs_DIR * dir;
+        uffs_DIR *dir;
 
         if (oflag & O_CREAT)   /* create a dir*/
         {
@@ -291,8 +291,8 @@ static int dfs_uffs_open(struct dfs_fd* file)
         }
         /* open dir */
         file_path = rt_malloc(FILE_PATH_MAX);
-        if(file_path == RT_NULL)
-            return -ENOMEM;         
+        if (file_path == RT_NULL)
+            return -ENOMEM;
 
         if (file->path[0] == '/' && !(file->path[1] == 0))
             rt_snprintf(file_path, FILE_PATH_MAX, "%s/", file->path);
@@ -306,7 +306,7 @@ static int dfs_uffs_open(struct dfs_fd* file)
 
         if (dir == RT_NULL)
         {
-            rt_free(file_path);         
+            rt_free(file_path);
             return uffs_result_to_dfs(uffs_get_error());
         }
         /* save this pointer,will used by  dfs_uffs_getdents*/
@@ -349,7 +349,7 @@ static int dfs_uffs_open(struct dfs_fd* file)
     return 0;
 }
 
-static int dfs_uffs_close(struct dfs_fd* file)
+static int dfs_uffs_close(struct dfs_fd *file)
 {
     int oflag;
     int fd;
@@ -372,12 +372,12 @@ static int dfs_uffs_close(struct dfs_fd* file)
     return uffs_result_to_dfs(uffs_get_error());
 }
 
-static int dfs_uffs_ioctl(struct dfs_fd * file, int cmd, void* args)
+static int dfs_uffs_ioctl(struct dfs_fd *file, int cmd, void *args)
 {
     return -ENOSYS;
 }
 
-static int dfs_uffs_read(struct dfs_fd * file, void* buf, size_t len)
+static int dfs_uffs_read(struct dfs_fd *file, void *buf, size_t len)
 {
     int fd;
     int char_read;
@@ -392,9 +392,9 @@ static int dfs_uffs_read(struct dfs_fd * file, void* buf, size_t len)
     return char_read;
 }
 
-static int dfs_uffs_write(struct dfs_fd* file,
-                   const void* buf,
-                   size_t len)
+static int dfs_uffs_write(struct dfs_fd *file,
+                          const void *buf,
+                          size_t len)
 {
     int fd;
     int char_write;
@@ -410,7 +410,7 @@ static int dfs_uffs_write(struct dfs_fd* file,
     return char_write;
 }
 
-static int dfs_uffs_flush(struct dfs_fd* file)
+static int dfs_uffs_flush(struct dfs_fd *file)
 {
     int fd;
     int result;
@@ -418,7 +418,7 @@ static int dfs_uffs_flush(struct dfs_fd* file)
     fd = (int)(file->data);
 
     result = uffs_flush(fd);
-    if (result < 0 )
+    if (result < 0)
         return uffs_result_to_dfs(uffs_get_error());
     return 0;
 }
@@ -427,18 +427,18 @@ int uffs_seekdir(uffs_DIR *dir, long offset)
 {
     int i = 0;
 
-    while(i < offset)
-    {   
+    while (i < offset)
+    {
         if (uffs_readdir(dir) == RT_NULL)
             return -1;
         i++;
-    } 
+    }
     return 0;
 }
 
 
-static int dfs_uffs_seek(struct dfs_fd* file,
-                  rt_off_t offset)
+static int dfs_uffs_seek(struct dfs_fd *file,
+                         rt_off_t offset)
 {
     int result;
 
@@ -446,17 +446,17 @@ static int dfs_uffs_seek(struct dfs_fd* file,
     if (file->type == FT_DIRECTORY)
     {
         uffs_rewinddir((uffs_DIR *)(file->data));
-        result = uffs_seekdir((uffs_DIR *)(file->data), offset/sizeof(struct dirent));
+        result = uffs_seekdir((uffs_DIR *)(file->data), offset / sizeof(struct dirent));
         if (result >= 0)
         {
-            file->pos = offset; 
+            file->pos = offset;
             return offset;
         }
     }
     else if (file->type == FT_REGULAR)
     {
         result = uffs_seek((int)(file->data), offset, USEEK_SET);
-        if (result >= 0)    
+        if (result >= 0)
             return offset;
     }
 
@@ -465,19 +465,19 @@ static int dfs_uffs_seek(struct dfs_fd* file,
 
 /* return the size of struct dirent*/
 static int dfs_uffs_getdents(
-    struct dfs_fd* file,
-    struct dirent* dirp,
+    struct dfs_fd *file,
+    struct dirent *dirp,
     uint32_t count)
 {
     rt_uint32_t index;
-    char * file_path;
-    struct dirent* d;
-    uffs_DIR* dir;
-    struct uffs_dirent * uffs_d;
-    
-    dir = (uffs_DIR*)(file->data);
+    char *file_path;
+    struct dirent *d;
+    uffs_DIR *dir;
+    struct uffs_dirent *uffs_d;
+
+    dir = (uffs_DIR *)(file->data);
     RT_ASSERT(dir != RT_NULL);
-    
+
     /* round count, count is always 1 */
     count = (count / sizeof(struct dirent)) * sizeof(struct dirent);
     if (count == 0) return -EINVAL;
@@ -486,13 +486,13 @@ static int dfs_uffs_getdents(
     file_path = rt_malloc(FILE_PATH_MAX);
     if (file_path == RT_NULL)
         return -ENOMEM;
-        
+
     index = 0;
     /* usually, the while loop should only be looped only once! */
     while (1)
     {
         struct uffs_stat s;
-        
+
         d = dirp + index;
 
         uffs_d = uffs_readdir(dir);
@@ -507,8 +507,8 @@ static int dfs_uffs_getdents(
         else
             rt_strncpy(file_path, uffs_d->d_name, FILE_PATH_MAX);
 
-        uffs_stat(file_path, &s); 
-        switch(s.st_mode & US_IFMT)   /* file type mark */
+        uffs_stat(file_path, &s);
+        switch (s.st_mode & US_IFMT)  /* file type mark */
         {
         case US_IFREG: /* directory */
             d->d_type = DT_REG;
@@ -533,10 +533,10 @@ static int dfs_uffs_getdents(
         if (index * sizeof(struct dirent) >= count)
             break;
     }
-    
+
     /* free file name buf */
     rt_free(file_path);
-    
+
     if (index == 0)
         return uffs_result_to_dfs(uffs_get_error());
 
@@ -545,7 +545,7 @@ static int dfs_uffs_getdents(
     return index * sizeof(struct dirent);
 }
 
-static int dfs_uffs_unlink(struct dfs_filesystem* fs, const char* path)
+static int dfs_uffs_unlink(struct dfs_filesystem *fs, const char *path)
 {
     int result;
     struct uffs_stat s;
@@ -556,7 +556,7 @@ static int dfs_uffs_unlink(struct dfs_filesystem* fs, const char* path)
         return uffs_result_to_dfs(uffs_get_error());
     }
 
-    switch(s.st_mode & US_IFMT)
+    switch (s.st_mode & US_IFMT)
     {
     case US_IFREG:
         result = uffs_remove(path);
@@ -575,12 +575,12 @@ static int dfs_uffs_unlink(struct dfs_filesystem* fs, const char* path)
 }
 
 static int dfs_uffs_rename(
-    struct dfs_filesystem* fs,
-    const char* oldpath,
-    const char* newpath)
+    struct dfs_filesystem *fs,
+    const char *oldpath,
+    const char *newpath)
 {
     int result;
-    
+
     result = uffs_rename(oldpath, newpath);
     if (result < 0)
         return uffs_result_to_dfs(uffs_get_error());
@@ -588,7 +588,7 @@ static int dfs_uffs_rename(
     return 0;
 }
 
-static int dfs_uffs_stat(struct dfs_filesystem* fs, const char *path, struct stat *st)
+static int dfs_uffs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
 {
     int result;
     struct uffs_stat s;
@@ -607,7 +607,7 @@ static int dfs_uffs_stat(struct dfs_filesystem* fs, const char *path, struct sta
     return 0;
 }
 
-static const struct dfs_file_ops dfs_uffs_fops = 
+static const struct dfs_file_ops dfs_uffs_fops =
 {
     dfs_uffs_open,
     dfs_uffs_close,

+ 1 - 1
components/dfs/filesystems/uffs/dfs_uffs.h

@@ -83,7 +83,7 @@ extern const uffs_FlashOps nand_ops;
 
 extern void uffs_setup_storage(
     struct uffs_StorageAttrSt *attr,
-    struct rt_mtd_nand_device * nand);
+    struct rt_mtd_nand_device *nand);
 
 extern int dfs_uffs_init(void);
 #endif /* DFS_UFFS_H_ */

+ 1 - 1
components/dfs/include/dfs.h

@@ -102,7 +102,7 @@ struct dfs_fd *fd_get(int fd);
 void fd_put(struct dfs_fd *fd);
 int fd_is_open(const char *pathname);
 
-struct dfs_fdtable* dfs_fdtable_get(void);
+struct dfs_fdtable *dfs_fdtable_get(void);
 
 #ifdef __cplusplus
 }

+ 5 - 5
components/dfs/include/dfs_fs.h

@@ -7,7 +7,7 @@
  * Date           Author       Notes
  * 2005-02-22     Bernard      The first version.
  */
- 
+
 #ifndef __DFS_FS_H__
 #define __DFS_FS_H__
 
@@ -60,7 +60,7 @@ struct dfs_partition
     uint8_t type;        /* file system type */
     off_t  offset;       /* partition start offset */
     size_t size;         /* partition size */
-    rt_sem_t lock;  
+    rt_sem_t lock;
 };
 
 /* mount table */
@@ -75,11 +75,11 @@ struct dfs_mount_tbl
 
 int dfs_register(const struct dfs_filesystem_ops *ops);
 struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
-const char* dfs_filesystem_get_mounted_path(struct rt_device* device);
+const char *dfs_filesystem_get_mounted_path(struct rt_device *device);
 
 int dfs_filesystem_get_partition(struct dfs_partition *part,
-                                      uint8_t         *buf,
-                                      uint32_t        pindex);
+                                 uint8_t         *buf,
+                                 uint32_t        pindex);
 
 int dfs_mount(const char *device_name,
               const char *path,

+ 1 - 1
components/dfs/include/dfs_posix.h

@@ -36,7 +36,7 @@ struct dirent *readdir(DIR *d);
 long telldir(DIR *d);
 void seekdir(DIR *d, off_t offset);
 void rewinddir(DIR *d);
-int closedir(DIR* d);
+int closedir(DIR *d);
 
 /* file api*/
 int open(const char *file, int flags, ...);

+ 2 - 2
components/dfs/include/dfs_private.h

@@ -12,8 +12,8 @@
 
 #include <dfs.h>
 
-#define DBG_SECTION_NAME	"DFS"
-#define DBG_LEVEL			DBG_INFO
+#define DBG_SECTION_NAME    "DFS"
+#define DBG_LEVEL           DBG_INFO
 #include <rtdbg.h>
 
 #define NO_WORKING_DIR  "system does not support working directory\n"

+ 6 - 6
components/dfs/src/dfs.c

@@ -139,7 +139,7 @@ static int fd_alloc(struct dfs_fdtable *fdt, int startfd)
 
         /* increase the number of FD with 4 step length */
         cnt = fdt->maxfd + 4;
-        cnt = cnt > DFS_FD_MAX? DFS_FD_MAX : cnt;
+        cnt = cnt > DFS_FD_MAX ? DFS_FD_MAX : cnt;
 
         fds = rt_realloc(fdt->fds, cnt * sizeof(struct dfs_fd *));
         if (fds == NULL) goto __exit; /* return fdt->maxfd */
@@ -189,7 +189,7 @@ int fd_new(void)
     if (idx == fdt->maxfd)
     {
         idx = -(1 + DFS_FD_OFFSET);
-        LOG_E( "DFS fd new is failed! Could not found an empty fd entry.");
+        LOG_E("DFS fd new is failed! Could not found an empty fd entry.");
         goto __result;
     }
 
@@ -400,7 +400,7 @@ char *dfs_normalize_path(const char *directory, const char *filename)
 
         /* join path and file name */
         rt_snprintf(fullpath, strlen(directory) + strlen(filename) + 2,
-            "%s/%s", directory, filename);
+                    "%s/%s", directory, filename);
     }
     else
     {
@@ -499,7 +499,7 @@ RTM_EXPORT(dfs_normalize_path);
 /**
  * This function will get the file descriptor table of current process.
  */
-struct dfs_fdtable* dfs_fdtable_get(void)
+struct dfs_fdtable *dfs_fdtable_get(void)
 {
     struct dfs_fdtable *fdt;
 #ifdef RT_USING_LWP
@@ -523,12 +523,12 @@ int list_fd(void)
 {
     int index;
     struct dfs_fdtable *fd_table;
-    
+
     fd_table = dfs_fdtable_get();
     if (!fd_table) return -1;
 
     rt_enter_critical();
-    
+
     rt_kprintf("fd type    ref magic  path\n");
     rt_kprintf("-- ------  --- ----- ------\n");
     for (index = 0; index < (int)fd_table->maxfd; index ++)

+ 17 - 13
components/dfs/src/dfs_file.c

@@ -2,7 +2,7 @@
  * Copyright (c) 2006-2018, RT-Thread Development Team
  *
  * SPDX-License-Identifier: Apache-2.0
- * 
+ *
  * Change Logs:
  * Date           Author       Notes
  * 2005-02-22     Bernard      The first version.
@@ -543,7 +543,8 @@ void ls(const char *pathname)
                     rt_kprintf("BAD file: %s\n", dirent.d_name);
                 rt_free(fullpath);
             }
-        }while(length > 0);
+        }
+        while (length > 0);
 
         dfs_file_close(&fd);
     }
@@ -565,7 +566,7 @@ void rm(const char *filename)
 }
 FINSH_FUNCTION_EXPORT(rm, remove files or directories);
 
-void cat(const char* filename)
+void cat(const char *filename)
 {
     uint32_t length;
     char buffer[81];
@@ -580,12 +581,13 @@ void cat(const char* filename)
     do
     {
         memset(buffer, 0, sizeof(buffer));
-        length = dfs_file_read(&fd, buffer, sizeof(buffer)-1 );
+        length = dfs_file_read(&fd, buffer, sizeof(buffer) - 1);
         if (length > 0)
         {
             rt_kprintf("%s", buffer);
         }
-    }while (length > 0);
+    }
+    while (length > 0);
 
     dfs_file_close(&fd);
 }
@@ -638,7 +640,8 @@ static void copyfile(const char *src, const char *dst)
                 break;
             }
         }
-    } while (read_bytes > 0);
+    }
+    while (read_bytes > 0);
 
     dfs_file_close(&src_fd);
     dfs_file_close(&fd);
@@ -646,7 +649,7 @@ static void copyfile(const char *src, const char *dst)
 }
 
 extern int mkdir(const char *path, mode_t mode);
-static void copydir(const char * src, const char * dst)
+static void copydir(const char *src, const char *dst)
 {
     struct dirent dirent;
     struct stat stat;
@@ -665,8 +668,8 @@ static void copydir(const char * src, const char * dst)
         length = dfs_file_getdents(&cpfd, &dirent, sizeof(struct dirent));
         if (length > 0)
         {
-            char * src_entry_full = NULL;
-            char * dst_entry_full = NULL;
+            char *src_entry_full = NULL;
+            char *dst_entry_full = NULL;
 
             if (strcmp(dirent.d_name, "..") == 0 || strcmp(dirent.d_name, ".") == 0)
                 continue;
@@ -703,14 +706,15 @@ static void copydir(const char * src, const char * dst)
             rt_free(src_entry_full);
             rt_free(dst_entry_full);
         }
-    }while(length > 0);
+    }
+    while (length > 0);
 
     dfs_file_close(&cpfd);
 }
 
 static const char *_get_path_lastname(const char *path)
 {
-    char * ptr;
+    char *ptr;
     if ((ptr = strrchr(path, '/')) == NULL)
         return path;
 
@@ -767,7 +771,7 @@ void copy(const char *src, const char *dst)
     {
         if (flag & FLAG_DST_IS_DIR)
         {
-            char * fdst;
+            char *fdst;
             fdst = dfs_normalize_path(dst, _get_path_lastname(src));
             if (fdst == NULL)
             {
@@ -786,7 +790,7 @@ void copy(const char *src, const char *dst)
     {
         if (flag & FLAG_DST_IS_DIR)
         {
-            char * fdst;
+            char *fdst;
             fdst = dfs_normalize_path(dst, _get_path_lastname(src));
             if (fdst == NULL)
             {

+ 21 - 21
components/dfs/src/dfs_fs.c

@@ -38,7 +38,7 @@ int dfs_register(const struct dfs_filesystem_ops *ops)
     dfs_lock();
     /* check if this filesystem was already registered */
     for (iter = &filesystem_operation_table[0];
-           iter < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; iter ++)
+            iter < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; iter ++)
     {
         /* find out an empty filesystem type entry */
         if (*iter == NULL)
@@ -120,9 +120,9 @@ struct dfs_filesystem *dfs_filesystem_lookup(const char *path)
  *
  * @return the mounted path or NULL if none device mounted.
  */
-const char* dfs_filesystem_get_mounted_path(struct rt_device* device)
+const char *dfs_filesystem_get_mounted_path(struct rt_device *device)
 {
-    const char* path = NULL;
+    const char *path = NULL;
     struct dfs_filesystem *iter;
 
     dfs_lock();
@@ -154,8 +154,8 @@ const char* dfs_filesystem_get_mounted_path(struct rt_device* device)
  * @return RT_EOK on successful or -RT_ERROR on failed.
  */
 int dfs_filesystem_get_partition(struct dfs_partition *part,
-                                      uint8_t         *buf,
-                                      uint32_t        pindex)
+                                 uint8_t         *buf,
+                                 uint32_t        pindex)
 {
 #define DPT_ADDRESS     0x1be       /* device partition offset in Boot Sector */
 #define DPT_ITEM_SIZE   16          /* partition item size */
@@ -173,28 +173,28 @@ int dfs_filesystem_get_partition(struct dfs_partition *part,
         return -EIO;
 
     /* get partition type */
-    type = *(dpt+4);
+    type = *(dpt + 4);
     if (type == 0)
         return -EIO;
 
     /* set partition information
      *    size is the number of 512-Byte */
     part->type = type;
-    part->offset = *(dpt+8) | *(dpt+9)<<8 | *(dpt+10)<<16 | *(dpt+11)<<24;
-    part->size = *(dpt+12) | *(dpt+13)<<8 | *(dpt+14)<<16 | *(dpt+15)<<24;
+    part->offset = *(dpt + 8) | *(dpt + 9) << 8 | *(dpt + 10) << 16 | *(dpt + 11) << 24;
+    part->size = *(dpt + 12) | *(dpt + 13) << 8 | *(dpt + 14) << 16 | *(dpt + 15) << 24;
 
     rt_kprintf("found part[%d], begin: %d, size: ",
-               pindex, part->offset*512);
-    if ((part->size>>11) == 0)
-        rt_kprintf("%d%s",part->size>>1,"KB\n");     /* KB */
+               pindex, part->offset * 512);
+    if ((part->size >> 11) == 0)
+        rt_kprintf("%d%s", part->size >> 1, "KB\n"); /* KB */
     else
     {
         unsigned int part_size;
         part_size = part->size >> 11;                /* MB */
-        if ((part_size>>10) == 0)
-            rt_kprintf("%d.%d%s",part_size,(part->size>>1)&0x3FF,"MB\n");
+        if ((part_size >> 10) == 0)
+            rt_kprintf("%d.%d%s", part_size, (part->size >> 1) & 0x3FF, "MB\n");
         else
-            rt_kprintf("%d.%d%s",part_size>>10,part_size&0x3FF,"GB\n");
+            rt_kprintf("%d.%d%s", part_size >> 10, part_size & 0x3FF, "GB\n");
     }
 
     return RT_EOK;
@@ -240,7 +240,7 @@ int dfs_mount(const char   *device_name,
     dfs_lock();
 
     for (ops = &filesystem_operation_table[0];
-           ops < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; ops++)
+            ops < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; ops++)
         if ((*ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0))
             break;
 
@@ -503,13 +503,13 @@ int dfs_mount_table(void)
         if (mount_table[index].path == NULL) break;
 
         if (dfs_mount(mount_table[index].device_name,
-                mount_table[index].path,
-                mount_table[index].filesystemtype,
-                mount_table[index].rwflag,
-                mount_table[index].data) != 0)
+                      mount_table[index].path,
+                      mount_table[index].filesystemtype,
+                      mount_table[index].rwflag,
+                      mount_table[index].data) != 0)
         {
             rt_kprintf("mount fs[%s] on %s failed.\n", mount_table[index].filesystemtype,
-                mount_table[index].path);
+                       mount_table[index].path);
             return -RT_ERROR;
         }
 
@@ -555,7 +555,7 @@ int df(const char *path)
     }
 
     rt_kprintf("disk free: %d.%d %s [ %d block, %d bytes per block ]\n",
-        (unsigned long)cap, minor, unit_str[unit_index], buffer.f_bfree, buffer.f_bsize);
+               (unsigned long)cap, minor, unit_str[unit_index], buffer.f_bfree, buffer.f_bsize);
     return 0;
 }
 FINSH_FUNCTION_EXPORT(df, get disk free);

+ 8 - 8
components/dfs/src/dfs_posix.c

@@ -423,11 +423,11 @@ int fcntl(int fildes, int cmd, ...)
     d = fd_get(fildes);
     if (d)
     {
-        void* arg;
+        void *arg;
         va_list ap;
 
         va_start(ap, cmd);
-        arg = va_arg(ap, void*);
+        arg = va_arg(ap, void *);
         va_end(ap);
 
         ret = dfs_file_ioctl(d, cmd, arg);
@@ -459,11 +459,11 @@ RTM_EXPORT(fcntl);
  */
 int ioctl(int fildes, int cmd, ...)
 {
-    void* arg;
+    void *arg;
     va_list ap;
 
     va_start(ap, cmd);
-    arg = va_arg(ap, void*);
+    arg = va_arg(ap, void *);
     va_end(ap);
 
     /* we use fcntl for this API. */
@@ -645,8 +645,8 @@ struct dirent *readdir(DIR *d)
 
     if (d->num)
     {
-        struct dirent* dirent_ptr;
-        dirent_ptr = (struct dirent*)&d->buf[d->cur];
+        struct dirent *dirent_ptr;
+        dirent_ptr = (struct dirent *)&d->buf[d->cur];
         d->cur += dirent_ptr->d_reclen;
     }
 
@@ -654,7 +654,7 @@ struct dirent *readdir(DIR *d)
     {
         /* get a new entry */
         result = dfs_file_getdents(fd,
-                                   (struct dirent*)d->buf,
+                                   (struct dirent *)d->buf,
                                    sizeof(d->buf) - 1);
         if (result <= 0)
         {
@@ -670,7 +670,7 @@ struct dirent *readdir(DIR *d)
 
     fd_put(fd);
 
-    return (struct dirent *)(d->buf+d->cur);
+    return (struct dirent *)(d->buf + d->cur);
 }
 RTM_EXPORT(readdir);
 

+ 1 - 1
components/dfs/src/poll.c

@@ -132,7 +132,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req)
             mask = POLLMASK_DEFAULT;
             if (f->fops->poll)
             {
-                req->_key = pollfd->events | POLLERR| POLLHUP;
+                req->_key = pollfd->events | POLLERR | POLLHUP;
 
                 mask = f->fops->poll(f, req);
             }

+ 2 - 2
components/dfs/src/select.c

@@ -18,12 +18,12 @@ static void fdszero(fd_set *set, int nfds)
 {
     fd_mask *m;
     int n;
-    
+
     /*
       The 'sizeof(fd_set)' of the system space may differ from user space,
       so the actual size of the 'fd_set' is determined here with the parameter 'nfds'
     */
-    m = (fd_mask*)set;
+    m = (fd_mask *)set;
     for (n = 0; n < nfds; n += (sizeof(fd_mask) * 8))
     {
         rt_memset(m, 0, sizeof(fd_mask));