[components][dfs]格式化代码

This commit is contained in:
tangyuxin
2019-04-08 14:51:01 +08:00
parent 583f8c3073
commit e71ec65549
21 changed files with 248 additions and 238 deletions
+10 -10
View File
@@ -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
View File
@@ -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;
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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,
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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));