2011-10-08 22:50:08 +08:00
|
|
|
/*
|
|
|
|
* File : dfs_fs.h
|
|
|
|
* This file is part of Device File System in RT-Thread RTOS
|
2012-12-26 09:12:13 +08:00
|
|
|
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
2011-10-08 22:50:08 +08:00
|
|
|
*
|
2013-06-26 22:30:40 +08:00
|
|
|
* 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.
|
2011-10-08 22:50:08 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2005-02-22 Bernard The first version.
|
|
|
|
*/
|
2011-12-23 10:11:55 +08:00
|
|
|
|
2011-10-08 22:50:08 +08:00
|
|
|
#ifndef __DFS_FS_H__
|
|
|
|
#define __DFS_FS_H__
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
#include <dfs.h>
|
2011-10-08 22:50:08 +08:00
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2012-01-01 21:37:21 +08:00
|
|
|
|
2011-10-08 22:50:08 +08:00
|
|
|
/* Pre-declaration */
|
|
|
|
struct dfs_filesystem;
|
|
|
|
struct dfs_fd;
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
/* File system operations */
|
|
|
|
struct dfs_filesystem_ops
|
2011-10-08 22:50:08 +08:00
|
|
|
{
|
2012-12-26 09:12:13 +08:00
|
|
|
char *name;
|
2017-10-15 22:44:53 +08:00
|
|
|
uint32_t flags; /* flags for file system operations */
|
|
|
|
|
|
|
|
/* operations for file */
|
|
|
|
const struct dfs_file_ops *fops;
|
2012-12-26 09:12:13 +08:00
|
|
|
|
|
|
|
/* mount and unmount file system */
|
|
|
|
int (*mount) (struct dfs_filesystem *fs, unsigned long rwflag, const void *data);
|
|
|
|
int (*unmount) (struct dfs_filesystem *fs);
|
|
|
|
|
|
|
|
/* make a file system */
|
2013-01-08 18:58:45 +08:00
|
|
|
int (*mkfs) (rt_device_t devid);
|
2012-12-26 09:12:13 +08:00
|
|
|
int (*statfs) (struct dfs_filesystem *fs, struct statfs *buf);
|
|
|
|
|
|
|
|
int (*unlink) (struct dfs_filesystem *fs, const char *pathname);
|
|
|
|
int (*stat) (struct dfs_filesystem *fs, const char *filename, struct stat *buf);
|
|
|
|
int (*rename) (struct dfs_filesystem *fs, const char *oldpath, const char *newpath);
|
2011-10-08 22:50:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Mounted file system */
|
|
|
|
struct dfs_filesystem
|
|
|
|
{
|
2012-12-26 09:12:13 +08:00
|
|
|
rt_device_t dev_id; /* Attached device */
|
2011-10-08 22:50:08 +08:00
|
|
|
|
2012-12-26 09:12:13 +08:00
|
|
|
char *path; /* File system mount point */
|
2017-10-15 22:44:53 +08:00
|
|
|
const struct dfs_filesystem_ops *ops; /* Operations for file system type */
|
2011-10-08 22:50:08 +08:00
|
|
|
|
2012-12-26 09:12:13 +08:00
|
|
|
void *data; /* Specific file system data */
|
2011-10-08 22:50:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* file system partition table */
|
|
|
|
struct dfs_partition
|
|
|
|
{
|
2017-10-15 22:44:53 +08:00
|
|
|
uint8_t type; /* file system type */
|
|
|
|
off_t offset; /* partition start offset */
|
|
|
|
size_t size; /* partition size */
|
2012-12-26 09:12:13 +08:00
|
|
|
rt_sem_t lock;
|
2011-10-08 22:50:08 +08:00
|
|
|
};
|
|
|
|
|
2013-07-22 07:46:10 +08:00
|
|
|
/* mount table */
|
|
|
|
struct dfs_mount_tbl
|
|
|
|
{
|
2017-10-15 22:44:53 +08:00
|
|
|
const char *device_name;
|
|
|
|
const char *path;
|
|
|
|
const char *filesystemtype;
|
|
|
|
unsigned long rwflag;
|
|
|
|
const void *data;
|
2013-07-22 07:46:10 +08:00
|
|
|
};
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
int dfs_register(const struct dfs_filesystem_ops *ops);
|
2011-12-23 10:11:55 +08:00
|
|
|
struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
|
2014-06-26 13:59:26 +08:00
|
|
|
const char* dfs_filesystem_get_mounted_path(struct rt_device* device);
|
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
int dfs_filesystem_get_partition(struct dfs_partition *part,
|
|
|
|
uint8_t *buf,
|
|
|
|
uint32_t pindex);
|
2012-12-26 09:12:13 +08:00
|
|
|
|
|
|
|
int dfs_mount(const char *device_name,
|
|
|
|
const char *path,
|
|
|
|
const char *filesystemtype,
|
2017-10-15 22:44:53 +08:00
|
|
|
unsigned long rwflag,
|
2012-12-26 09:12:13 +08:00
|
|
|
const void *data);
|
2011-10-08 22:50:08 +08:00
|
|
|
int dfs_unmount(const char *specialfile);
|
|
|
|
|
2013-05-17 20:03:24 +08:00
|
|
|
int dfs_mkfs(const char *fs_name, const char *device_name);
|
2011-12-23 10:11:55 +08:00
|
|
|
int dfs_statfs(const char *path, struct statfs *buffer);
|
2011-10-08 22:50:08 +08:00
|
|
|
|
2017-10-15 22:44:53 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-10-08 22:50:08 +08:00
|
|
|
#endif
|