2014-09-29 21:14:38 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* fs/driver/driver.h
|
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-09-29 21:14:38 +08:00
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-09-29 21:14:38 +08:00
|
|
|
*
|
2021-02-03 21:47:23 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-09-29 21:14:38 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __FS_DRIVER_DRIVER_H
|
|
|
|
#define __FS_DRIVER_DRIVER_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <nuttx/compiler.h>
|
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
|
2015-06-12 01:24:20 +08:00
|
|
|
#include "inode/inode.h"
|
|
|
|
|
2014-09-29 21:14:38 +08:00
|
|
|
/****************************************************************************
|
2015-10-03 06:30:35 +08:00
|
|
|
* Public Data
|
2014-09-29 21:14:38 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-05-19 20:16:26 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: register_partition_with_inode
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Register a block partition driver inode the pseudo file system.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* partition - The path to the partition inode
|
|
|
|
* parent - the parent inode
|
|
|
|
* firstsector - The offset in sectors to the partition
|
|
|
|
* nsectors - The number of sectors in the partition
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on success (with the inode point in 'inode'); A negated errno
|
|
|
|
* value is returned on a failure (all error values returned by
|
|
|
|
* inode_reserve):
|
|
|
|
*
|
|
|
|
* EINVAL - 'path' is invalid for this operation
|
|
|
|
* EEXIST - An inode already exists at 'path'
|
|
|
|
* ENOMEM - Failed to allocate in-memory resources for the operation
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
|
|
|
int register_partition_with_inode(FAR const char *partition,
|
|
|
|
mode_t mode, FAR struct inode *parent,
|
|
|
|
off_t firstsector, off_t nsectors);
|
|
|
|
#endif
|
|
|
|
|
2015-11-22 01:24:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: block_proxy
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Create a temporary char driver using drivers/bch to mediate character
|
|
|
|
* oriented accessed to the block driver.
|
|
|
|
*
|
2018-02-02 00:00:02 +08:00
|
|
|
* Input Parameters:
|
2021-01-22 21:25:03 +08:00
|
|
|
* filep - The caller provided location in which to return the 'struct
|
|
|
|
* file' instance.
|
2015-11-22 01:24:55 +08:00
|
|
|
* blkdev - The path to the block driver
|
|
|
|
* oflags - Character driver open flags
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2021-01-22 21:25:03 +08:00
|
|
|
* Zero (OK) is returned on success. On failure, a negated errno value is
|
|
|
|
* returned.
|
2015-11-22 01:24:55 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-10-22 22:25:01 +08:00
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
2020-10-01 19:21:36 +08:00
|
|
|
int block_proxy(FAR struct file *filep, FAR const char *blkdev, int oflags);
|
2015-11-22 01:24:55 +08:00
|
|
|
#endif
|
2023-05-19 20:16:26 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: register_partition_with_mtd
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Register a mtd partition driver inode the pseudo file system.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* partition - The path to the partition inode
|
|
|
|
* parent - The parent mtd instance
|
|
|
|
* firstblock - The offset in block to the partition
|
|
|
|
* nblocks - The number of block in the partition
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on success (with the inode point in 'inode'); A negated errno
|
|
|
|
* value is returned on a failure (all error values returned by
|
|
|
|
* inode_reserve):
|
|
|
|
*
|
|
|
|
* EINVAL - 'path' is invalid for this operation
|
|
|
|
* EEXIST - An inode already exists at 'path'
|
|
|
|
* ENOMEM - Failed to allocate in-memory resources for the operation
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_MTD
|
|
|
|
int register_partition_with_mtd(FAR const char *partition,
|
|
|
|
mode_t mode, FAR struct mtd_dev_s *parent,
|
|
|
|
off_t firstblock, off_t nblocks);
|
|
|
|
#endif
|
2014-09-29 21:14:38 +08:00
|
|
|
|
2018-11-08 23:59:18 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: mtd_proxy
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Create a temporary block driver using drivers/mtd/ftl to mediate block
|
|
|
|
* oriented accessed to the mtd driver.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mtddev - The path to the mtd driver
|
|
|
|
* mountflags - if MS_RDONLY is not set, then driver must support write
|
|
|
|
* operations (see include/sys/mount.h)
|
|
|
|
* ppinode - address of the location to return the inode reference
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* If zero, non-zero inode pointer is returned on success. This
|
|
|
|
* is the inode pointer of the nameless block driver that mediates
|
2021-01-22 21:36:58 +08:00
|
|
|
* accesses to the mtd driver. A negated errno value is returned on
|
|
|
|
* any failure.
|
2018-11-08 23:59:18 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_MTD
|
|
|
|
int mtd_proxy(FAR const char *mtddev, int mountflags,
|
|
|
|
FAR struct inode **ppinode);
|
|
|
|
#endif
|
|
|
|
|
2014-09-29 21:14:38 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __FS_DRIVER_DRIVER_H */
|