4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-30 06:40:25 +08:00

Embedded GPLv2 license in dfs

This commit is contained in:
yiyue.fang 2013-06-26 22:30:40 +08:00
parent cb517cecc9
commit 773990abdb
27 changed files with 1759 additions and 1353 deletions

View File

@ -1,7 +1,26 @@
/*
* RT-Thread Console Device File
* File : console.c
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#include <rtthread.h>
struct console_device

View File

@ -1,3 +1,26 @@
/*
* File : devfs.c
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#include <rtthread.h>
#include <dfs.h>
#include <dfs_fs.h>

View File

@ -1,3 +1,26 @@
/*
* File : devfs.h
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#ifndef __DEVICE_FS_H__
#define __DEVICE_FS_H__

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2008-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@ -64,8 +74,10 @@ typedef struct nfs_dir nfs_dir;
nfs_dir *nfs_opendir(struct nfs_filesystem *nfs, const char *path);
static int nfs_parse_host_export(const char *host_export,
char *host, size_t host_len,
char *export, size_t export_len)
char *host,
size_t host_len,
char *export,
size_t export_len)
{
int index;
@ -98,6 +110,7 @@ static int nfs_parse_host_export(const char *host_export,
if (host_export[index] == 0)
{
export[index - host_len] = '\0';
return 0;
}
@ -114,6 +127,7 @@ static void copy_handle(nfs_fh3 *dest, const nfs_fh3 *source)
if (dest->data.data_val == RT_NULL)
{
dest->data.data_len = 0;
return;
}
@ -137,6 +151,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
if (handle == RT_NULL)
{
rt_free(init);
return RT_NULL;
}
@ -165,6 +180,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
rt_free(init);
rt_free(handle);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)&args.what.dir);
return RT_NULL;
}
else if (res.status != NFS3_OK)
@ -174,6 +190,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
rt_free(handle);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)&args.what.dir);
xdr_free((xdrproc_t)xdr_LOOKUP3res, (char *)&res);
return RT_NULL;
}
copy_handle(handle, &res.LOOKUP3res_u.resok.object);
@ -182,6 +199,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
}
rt_free(init);
return handle;
}
@ -201,6 +219,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
if (handle == RT_NULL)
{
rt_free(init);
return RT_NULL;
}
@ -229,6 +248,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
rt_free(init);
rt_free(handle);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)&args.what.dir);
return RT_NULL;
}
else if (res.status != NFS3_OK)
@ -238,6 +258,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
rt_free(handle);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)&args.what.dir);
xdr_free((xdrproc_t)xdr_LOOKUP3res, (char *)&res);
return RT_NULL;
}
copy_handle(handle, &res.LOOKUP3res_u.resok.object);
@ -246,6 +267,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
}
rt_free(init);
return handle;
}
@ -264,6 +286,7 @@ static size_t nfs_get_filesize(struct nfs_filesystem *nfs, nfs_fh3 *handle)
res.status != NFS3_OK)
{
rt_kprintf("GetAttr failed: %d\n", res.status);
return 0;
}
@ -294,11 +317,13 @@ rt_bool_t nfs_is_directory(struct nfs_filesystem *nfs, const char *name)
if (nfsproc3_getattr_3(args, &res, nfs->nfs_client) != RPC_SUCCESS)
{
rt_kprintf("GetAttr failed\n");
return RT_FALSE;
}
else if (res.status != NFS3_OK)
{
rt_kprintf("Getattr failed: %d\n", res.status);
return RT_FALSE;
}
@ -495,6 +520,7 @@ int nfs_unmount(struct dfs_filesystem *fs)
mountproc3_umnt_3((char *)nfs->export, RT_NULL, nfs->mount_client) != RPC_SUCCESS)
{
rt_kprintf("umount failed\n");
return -1;
}
@ -596,6 +622,7 @@ int nfs_read(struct dfs_fd *file, void *buf, rt_size_t count)
} while(count > 0);
xdr_free((xdrproc_t)xdr_READ3res, (char *)&res);
return total;
}
@ -657,6 +684,7 @@ int nfs_write(struct dfs_fd *file, const void *buf, rt_size_t count)
} while (count > 0);
xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
return total;
}
@ -673,6 +701,7 @@ int nfs_lseek(struct dfs_fd *file, rt_off_t offset)
if (offset <= fd->size)
{
fd->offset = offset;
return offset;
}
@ -734,7 +763,8 @@ int nfs_open(struct dfs_fd *file)
/* create file */
if (file->flags & DFS_O_CREAT)
{
if (nfs_create(nfs, file->path, 0664) < 0) return -1;
if (nfs_create(nfs, file->path, 0664) < 0)
return -1;
}
/* open file (get file handle ) */
@ -746,6 +776,7 @@ int nfs_open(struct dfs_fd *file)
if (handle == RT_NULL)
{
rt_free(fp);
return -1;
}
@ -839,6 +870,7 @@ nfs_dir *nfs_opendir(struct nfs_filesystem *nfs, const char *path)
if (handle == RT_NULL)
{
rt_free(dir);
return RT_NULL;
}
@ -877,11 +909,13 @@ char *nfs_readdir(struct nfs_filesystem *nfs, nfs_dir *dir)
if (nfsproc3_readdir_3(args, &dir->res, nfs->nfs_client) != RPC_SUCCESS)
{
rt_kprintf("Readdir failed\n");
return RT_NULL;
}
else if (dir->res.status != NFS3_OK)
{
rt_kprintf("Readdir failed: %d\n", dir->res.status);
return RT_NULL;
}
@ -896,6 +930,7 @@ char *nfs_readdir(struct nfs_filesystem *nfs, nfs_dir *dir)
strncpy(name, dir->entry->name, NAME_MAX-1);
dir->entry = dir->entry->nextentry;
name[NAME_MAX - 1] = '\0';
return name;
}
@ -1031,6 +1066,7 @@ int nfs_rename(struct dfs_filesystem *fs, const char *src, const char *dest)
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)sHandle);
xdr_free((xdrproc_t)xdr_nfs_fh3, (char *)dHandle);
xdr_free((xdrproc_t)xdr_RENAME3res, (char *)&res);
return ret;
}

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -1,9 +1,21 @@
/*
* File : dfs_ramfs.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, Shanghai Real-Thread Technology Co., Ltd
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2013, RT-Thread Development Team
*
* All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@ -17,11 +29,14 @@
#include <dfs_fs.h>
#include "dfs_ramfs.h"
int dfs_ramfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
int dfs_ramfs_mount(struct dfs_filesystem *fs,
unsigned long rwflag,
const void *data)
{
struct dfs_ramfs* ramfs;
if (data == RT_NULL) return -DFS_STATUS_EIO;
if (data == RT_NULL)
return -DFS_STATUS_EIO;
ramfs = (struct dfs_ramfs*) data;
fs->data = ramfs;
@ -55,7 +70,9 @@ int dfs_ramfs_ioctl(struct dfs_fd *file, int cmd, void *args)
return -DFS_STATUS_EIO;
}
struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs* ramfs, const char *path, rt_size_t *size)
struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs *ramfs,
const char *path,
rt_size_t *size)
{
const char *subpath;
struct ramfs_dirent *dirent;
@ -65,6 +82,7 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs* ramfs, const char *path,
if (! *subpath) /* is root directory */
{
*size = 0;
return &(ramfs->root);
}
@ -75,6 +93,7 @@ struct ramfs_dirent *dfs_ramfs_lookup(struct dfs_ramfs* ramfs, const char *path,
if (rt_strcmp(dirent->name, subpath) == 0)
{
*size = dirent->size;
return dirent;
}
}
@ -122,6 +141,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, rt_size_t count)
if (ptr == RT_NULL)
{
rt_set_errno(-RT_ENOMEM);
return 0;
}
@ -145,6 +165,7 @@ int dfs_ramfs_lseek(struct dfs_fd *file, rt_off_t offset)
if (offset <= (rt_off_t)file->size)
{
file->pos = offset;
return file->pos;
}
@ -154,6 +175,7 @@ int dfs_ramfs_lseek(struct dfs_fd *file, rt_off_t offset)
int dfs_ramfs_close(struct dfs_fd *file)
{
file->data = RT_NULL;
return DFS_STATUS_OK;
}
@ -195,8 +217,7 @@ int dfs_ramfs_open(struct dfs_fd *file)
if (dirent == RT_NULL)
{
if (file->flags & DFS_O_CREAT ||
file->flags & DFS_O_WRONLY)
if (file->flags & DFS_O_CREAT || file->flags & DFS_O_WRONLY)
{
char *name_ptr;
@ -209,7 +230,8 @@ int dfs_ramfs_open(struct dfs_fd *file)
/* remove '/' separator */
name_ptr = file->path;
while (*name_ptr == '/' && *name_ptr) name_ptr ++;
while (*name_ptr == '/' && *name_ptr)
name_ptr ++;
strncpy(dirent->name, name_ptr, RAMFS_NAME_MAX);
rt_list_init(&(dirent->list));
@ -218,7 +240,8 @@ int dfs_ramfs_open(struct dfs_fd *file)
/* add to the root directory */
rt_list_insert_after(&(ramfs->root.list), &(dirent->list));
}
else return -DFS_STATUS_ENOENT;
else
return -DFS_STATUS_ENOENT;
}
/* Creates a new file. If the file is existing, it is truncated and overwritten. */
@ -312,7 +335,8 @@ int dfs_ramfs_unlink(struct dfs_filesystem *fs, const char *path)
RT_ASSERT(ramfs != RT_NULL);
dirent = dfs_ramfs_lookup(ramfs, path, &size);
if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
if (dirent == RT_NULL)
return -DFS_STATUS_ENOENT;
rt_list_remove(&(dirent->list));
if (dirent->data != RT_NULL)
@ -322,7 +346,9 @@ int dfs_ramfs_unlink(struct dfs_filesystem *fs, const char *path)
return DFS_STATUS_OK;
}
int dfs_ramfs_rename(struct dfs_filesystem *fs, const char *oldpath, const char *newpath)
int dfs_ramfs_rename(struct dfs_filesystem *fs,
const char *oldpath,
const char *newpath)
{
struct ramfs_dirent *dirent;
struct dfs_ramfs *ramfs;
@ -332,10 +358,12 @@ int dfs_ramfs_rename(struct dfs_filesystem *fs, const char *oldpath, const char
RT_ASSERT(ramfs != RT_NULL);
dirent = dfs_ramfs_lookup(ramfs, newpath, &size);
if (dirent != RT_NULL) return -DFS_STATUS_EEXIST;
if (dirent != RT_NULL)
return -DFS_STATUS_EEXIST;
dirent = dfs_ramfs_lookup(ramfs, oldpath, &size);
if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
if (dirent == RT_NULL)
return -DFS_STATUS_ENOENT;
strncpy(dirent->name, newpath, RAMFS_NAME_MAX);
@ -368,6 +396,7 @@ int dfs_ramfs_init(void)
{
/* register ram file system */
dfs_register(&_ramfs);
return 0;
}
@ -385,7 +414,8 @@ struct dfs_ramfs* dfs_ramfs_create(rt_uint8_t* pool, rt_size_t size)
size = RT_ALIGN_DOWN(size, RT_ALIGN_SIZE);
result = rt_memheap_init(&ramfs->memheap, "ramfs", data_ptr, size);
if (result != RT_EOK) return RT_NULL;
if (result != RT_EOK)
return RT_NULL;
/* detach this memheap object from the system */
rt_object_detach((rt_object_t)&(ramfs->memheap));

View File

@ -1,9 +1,21 @@
/*
* File : dfs_ramfs.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2011, Shanghai Real-Thread Technology Co., Ltd
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2013, RT-Thread Development Team
*
* All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -1,23 +1,51 @@
/*
* File : romfs.c
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#include <dfs_romfs.h>
const static unsigned char _dummy_dummy_txt[] = {
0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,
0x0a,
const static unsigned char _dummy_dummy_txt[] =
{
0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,0x0a,
};
const static struct romfs_dirent _dummy[] = {
const static struct romfs_dirent _dummy[] =
{
{ROMFS_DIRENT_FILE, "dummy.txt", _dummy_dummy_txt, sizeof(_dummy_dummy_txt)},
};
const static unsigned char _dummy_txt[] = {
0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,
0x0a,
const static unsigned char _dummy_txt[] =
{
0x74,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x66,0x69,0x6c,0x65,0x21,0x0d,0x0a,
};
const struct romfs_dirent _root_dirent[] = {
const struct romfs_dirent _root_dirent[] =
{
{ROMFS_DIRENT_DIR, "dummy", (rt_uint8_t *)_dummy, sizeof(_dummy)/sizeof(_dummy[0])},
{ROMFS_DIRENT_FILE, "dummy.txt", _dummy_txt, sizeof(_dummy_txt)},
};
const struct romfs_dirent romfs_root = {ROMFS_DIRENT_DIR, "/", (rt_uint8_t*) _root_dirent, sizeof(_root_dirent)/sizeof(_root_dirent[0])};
const struct romfs_dirent romfs_root =
{
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_root_dirent, sizeof(_root_dirent)/sizeof(_root_dirent[0])
};

View File

@ -1,6 +1,26 @@
/*
* A skeleton of file system in Device File System
* File : skeleton.c
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#include <rtthread.h>
#include <dfs.h>
#include <dfs_fs.h>

View File

@ -1,3 +1,26 @@
/*
* File : skeleton.h
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
*/
#ifndef __SKELETON_H__
#define __SKELETON_H__

View File

@ -1,11 +1,21 @@
/*
* File : rtthread.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2012, RT-Thread Development Team
* File : dfs_uffs.c
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@ -13,6 +23,7 @@
* 2012-03-28 prife use mtd device interface
* 2012-04-05 prife update uffs with official repo and use uffs_UnMount/Mount
*/
#include <rtthread.h>
#include <dfs_fs.h>

View File

@ -1,8 +1,25 @@
/*
* dfs_uffs.h
* File : dfs_uffs.h
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* Created on: 2012-3-30
* Author: prife
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2012-03-30 prife the first version
*/
#ifndef DFS_UFFS_H_

View File

@ -18,7 +18,9 @@ static int nand_release_flash(uffs_Device *dev)
static int nand_erase_block(uffs_Device *dev, unsigned block)
{
int res;
res = rt_mtd_nand_erase_block(RT_MTD_NAND_DEVICE(dev->_private), block);
return res == RT_EOK ? UFFS_FLASH_NO_ERR : UFFS_FLASH_IO_ERR;
}
@ -26,26 +28,31 @@ static int nand_erase_block(uffs_Device *dev, unsigned block)
static int nand_check_block(uffs_Device *dev, unsigned block)
{
int res;
res = rt_mtd_nand_check_block(RT_MTD_NAND_DEVICE(dev->_private), block);
return res == RT_EOK ? UFFS_FLASH_NO_ERR : UFFS_FLASH_BAD_BLK;
}
static int nand_mark_badblock(uffs_Device *dev, unsigned block)
{
int res;
res = rt_mtd_nand_mark_badblock(RT_MTD_NAND_DEVICE(dev->_private), block);
return res == RT_EOK ? UFFS_FLASH_NO_ERR : UFFS_FLASH_IO_ERR;
}
#endif
#if (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE) || (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT)
static int nand_read_page(
uffs_Device *dev,
u32 block, u32 page,
u8 *data, int data_len,
static int nand_read_page(uffs_Device *dev,
u32 block,
u32 page,
u8 *data,
int data_len,
u8 *ecc,
rt_uint8_t *spare, int spare_len)
rt_uint8_t *spare,
int spare_len)
{
int res;
@ -66,6 +73,7 @@ static int nand_read_page(
res = spare[dev->attr->block_status_offs] == 0xFF ?
UFFS_FLASH_NO_ERR : UFFS_FLASH_BAD_BLK;
return res;
#endif
}
@ -76,11 +84,13 @@ static int nand_read_page(
return UFFS_FLASH_NO_ERR;
}
static int nand_write_page(
uffs_Device *dev,
u32 block, u32 page,
const u8 *data, int data_len,
const u8 *spare, int spare_len)
static int nand_write_page(uffs_Device *dev,
u32 block,
u32 page,
const u8 *data,
int data_len,
const u8 *spare,
int spare_len)
{
int res;
@ -136,8 +146,7 @@ const uffs_FlashOps nand_ops =
nand_erase_block, /* EraseBlock() */
};
void uffs_setup_storage(
struct uffs_StorageAttrSt *attr,
void uffs_setup_storage(struct uffs_StorageAttrSt *attr,
struct rt_mtd_nand_device *nand)
{
rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt));
@ -153,10 +162,11 @@ void uffs_setup_storage(
}
#elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO
static int WritePageWithLayout(
uffs_Device *dev, u32 block, u32 page,
const u8 *data, int data_len,
static int WritePageWithLayout(uffs_Device *dev,
u32 block,
u32 page,
const u8 *data,
int data_len,
const u8 *ecc, //NULL
const uffs_TagStore *ts)
{
@ -186,7 +196,6 @@ static int WritePageWithLayout(
dev->st.io_write++;
return UFFS_FLASH_NO_ERR;
#endif
}
@ -216,9 +225,11 @@ __error:
return UFFS_FLASH_IO_ERR;
}
static URET ReadPageWithLayout(
uffs_Device *dev, u32 block, u32 page,
u8* data, int data_len,
static URET ReadPageWithLayout(uffs_Device *dev,
u32 block,
u32 page,
u8 *data,
int data_len,
u8 *ecc, //NULL
uffs_TagStore *ts,
u8 *ecc_store) //NULL
@ -304,13 +315,16 @@ const uffs_FlashOps nand_ops =
};
static rt_uint8_t hw_flash_data_layout[UFFS_SPARE_LAYOUT_SIZE] =
{0x05, 0x08, 0xFF, 0x00};
{
0x05, 0x08, 0xFF, 0x00
};
static rt_uint8_t hw_flash_ecc_layout[UFFS_SPARE_LAYOUT_SIZE] =
{0x00, 0x04, 0xFF, 0x00};
{
0x00, 0x04, 0xFF, 0x00
};
void uffs_setup_storage(
struct uffs_StorageAttrSt *attr,
void uffs_setup_storage(struct uffs_StorageAttrSt *attr,
struct rt_mtd_nand_device *nand)
{
rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt));

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2008-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes

View File

@ -3,9 +3,19 @@
* This file is part of Device File System in RT-Thread RTOS
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes