* fs/tmpfs/fs_tmpfs.h
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
****************************************************************************/
#ifndef __FS_TMPFS_FS_TMPFS_H
#define __FS_TMPFS_FS_TMPFS_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/fs/fs.h>
#include <nuttx/mutex.h>
* Pre-processor Definitions
****************************************************************************/
#define TFO_FLAG_UNLINKED (1 << 0)
* Public Types
****************************************************************************/
enum tmpfs_objtype_e
{
TMPFS_DIRECTORY = 0,
TMPFS_REGULAR
};
enum tmpfs_foreach_e
{
TMPFS_CONTINUE = 0,
TMPFS_HALT,
TMPFS_DELETED,
TMPFS_UNLINKED
};
struct tmpfs_dirent_s
{
FAR struct tmpfs_object_s *tde_object;
FAR char *tde_name;
};
struct tmpfs_object_s
{
rmutex_t to_lock;
size_t to_alloc;
uint8_t to_type;
uint8_t to_refs;
FAR struct tmpfs_directory_s *to_parent;
struct timespec to_atime;
struct timespec to_mtime;
struct timespec to_ctime;
};
struct tmpfs_directory_s
{
rmutex_t tdo_lock;
size_t tdo_alloc;
uint8_t tdo_type;
uint8_t tdo_refs;
FAR struct tmpfs_directory_s *tdo_parent;
struct timespec tdo_atime;
struct timespec tdo_mtime;
struct timespec tdo_ctime;
uint16_t tdo_nentries;
FAR struct tmpfs_dirent_s *tdo_entry;
};
#define SIZEOF_TMPFS_DIRECTORY(n) ((n) * sizeof(struct tmpfs_dirent_s))
*
* NOTE that in this very simplified implementation, there is no per-open
* state. The file memory object also serves as the open file object,
* saving an allocation. This has the negative side effect that no per-
* open state can be retained (such as open flags).
*/
struct tmpfs_file_s
{
rmutex_t tfo_lock;
size_t tfo_alloc;
uint8_t tfo_type;
uint8_t tfo_refs;
FAR struct tmpfs_directory_s *tfo_parent;
struct timespec tfo_atime;
struct timespec tfo_mtime;
struct timespec tfo_ctime;
uint8_t tfo_flags;
size_t tfo_size;
FAR uint8_t *tfo_data;
};
struct tmpfs_s
{
FAR struct tmpfs_dirent_s tfs_root;
rmutex_t tfs_lock;
};
* usage
*/
struct tmpfs_statfs_s
{
size_t tsf_alloc;
size_t tsf_avail;
off_t tsf_files;
off_t tsf_ffree;
};
typedef int (*tmpfs_foreach_t)(FAR struct tmpfs_directory_s *tdo,
unsigned int index, FAR void *arg);
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
EXTERN const struct mountpt_operations g_tmpfs_operations;
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif