Add mount and umount

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@214 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-05-12 20:08:39 +00:00
parent f6ad8c9fea
commit 1f9a015bcf
2 changed files with 114 additions and 5 deletions

View File

@ -59,12 +59,22 @@
struct file;
struct file_operations
{
/* The device driver open method differs from the mountpoint open method */
int (*open)(FAR struct file *filp);
/* The following methods must be identical in signature and position because
* the struct file_operations and struct mountp_operations are treated like
* unions.
*/
int (*close)(FAR struct file *filp);
ssize_t (*read)(FAR struct file *filp, char *buffer, size_t buflen);
ssize_t (*write)(FAR struct file *filp, const char *buffer, size_t buflen);
off_t (*seek)(FAR struct file *filp, off_t offset, int whence);
int (*ioctl)(FAR struct file *filp, int cmd, unsigned long arg);
/* The two structures need not be common after this point */
};
/* This structure provides information about the state of a block driver */
@ -98,14 +108,33 @@ struct block_operations
* struct file_operations or struct mountpt_operations
*/
struct inode;
struct mountpt_operations
{
/* The mountpoint open method differs from the driver open method
* because it receives the relative path into the mountpoint.
*/
int (*open)(FAR struct file *filp, const char *rel_path);
/* The following methods must be identical in signature and position because
* the struct file_operations and struct mountp_operations are treated like
* unions.
*/
int (*close)(FAR struct file *filp);
ssize_t (*read)(FAR struct file *filp, char *buffer, size_t buflen);
ssize_t (*write)(FAR struct file *filp, const char *buffer, size_t buflen);
off_t (*seek)(FAR struct file *filp, off_t offset, int whence);
int (*ioctl)(FAR struct file *filp, int cmd, unsigned long arg);
/* The two structures need not be common after this point. For the
* case of struct mountpt_operations, additional operations are included
* that used only for mounting and unmounting the volume.
*/
int (*bind)(FAR struct inode *blkdriver, const void *data, void **handle);
int (*unbind)(void *handle);
};
/* This structure represents one inode in the Nuttx psuedo-file system */
@ -125,7 +154,7 @@ struct inode
#ifdef CONFIG_FILE_MODE
mode_t i_mode; /* Access mode flags */
#endif
FAR void *i_private; /* Driver private data */
FAR void *i_private; /* Per inode driver private data */
char i_name[1]; /* Name of inode (variable) */
};
#define FSNODE_SIZE(n) (sizeof(struct inode) + (n))
@ -220,11 +249,13 @@ EXTERN STATUS register_blockdriver(const char *path,
const struct block_operations *bops,
mode_t mode, void *private);
/* fs_inoderemove.c *********************************************************/
/* fs_unregisterdriver.c ****************************************************/
EXTERN STATUS inode_remove(const char *path);
#define unregister_driver(p) inode_remove(p)
#define unregister_blockdriver(p) inode_remove(p)
EXTERN STATUS unregister_driver(const char *path);
/* fs_unregisterblockdriver.c ***********************************************/
EXTERN STATUS unregister_blockdriver(const char *path);
/* fs_open.c ****************************************************************/

78
include/sys/mount.h Normal file
View File

@ -0,0 +1,78 @@
/****************************************************************************
* sys/mount.h
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __SYS_MOUNT_H
#define __SYS_MOUNT_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
/****************************************************************************
* Definitions
****************************************************************************/
/* Mount flags */
#define MS_RDONLY 1 /* Mount file system read-only */
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
EXTERN int umount(const char *target);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __SYS_MOUNT_H */