Contiki 2.5
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
core
cfs
cfs-coffee.h
Go to the documentation of this file.
1
/**
2
* \addtogroup cfs
3
* @{
4
*/
5
6
/*
7
* Copyright (c) 2008, Swedish Institute of Computer Science
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
* 3. Neither the name of the Institute nor the names of its contributors
19
* may be used to endorse or promote products derived from this software
20
* without specific prior written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32
* SUCH DAMAGE.
33
*
34
* This file is part of the Contiki operating system.
35
*
36
*/
37
38
#ifndef CFS_COFFEE_H
39
#define CFS_COFFEE_H
40
41
#include "
cfs.h
"
42
43
/**
44
* Instruct Coffee that the access pattern to this file is adapted to
45
* flash I/O semantics by design, and Coffee should therefore not
46
* invoke its own micro logs when file modifications occur.
47
*
48
* This semantical I/O setting is useful when implementing flash storage
49
* algorithms on top of Coffee.
50
*
51
* \sa cfs_coffee_set_io_semantics()
52
*/
53
#define CFS_COFFEE_IO_FLASH_AWARE 0x1
54
55
/**
56
* Instruct Coffee not to attempt to extend the file when there is
57
* an attempt to write past the reserved file size.
58
*
59
* A case when this is necessary is when the file has a firm size limit,
60
* and a safeguard is needed to protect against writes beyond this limit.
61
*
62
* \sa cfs_coffee_set_io_semantics()
63
*/
64
#define CFS_COFFEE_IO_FIRM_SIZE 0x2
65
66
/**
67
* \file
68
* Header for the Coffee file system.
69
* \author
70
* Nicolas Tsiftes <nvt@sics.se>
71
*
72
* \name Functions called from application programs
73
* @{
74
*/
75
76
/**
77
* \brief Reserve space for a file.
78
* \param name The filename.
79
* \param size The size of the file.
80
* \return 0 on success, -1 on failure.
81
*
82
* Coffee uses sequential page structures for files. The sequential
83
* structure can be reserved with a certain size. If a file has not
84
* been reserved when it is opened for the first time, it will be
85
* allocated with a default size.
86
*/
87
int
cfs_coffee_reserve
(
const
char
*name, cfs_offset_t size);
88
89
/**
90
* \brief Configure the on-demand log file.
91
* \param file The filename.
92
* \param log_size The total log size.
93
* \param log_entry_size The log entry size.
94
* \return 0 on success, -1 on failure.
95
*
96
* When file data is first modified, Coffee creates a micro log for the
97
* file. The micro log stores a table of modifications whose
98
* parameters--the log size and the log entry size--can be modified
99
* through the cfs_coffee_configure_log function.
100
*/
101
int
cfs_coffee_configure_log
(
const
char
*file,
unsigned
log_size,
102
unsigned
log_entry_size);
103
104
/**
105
* \brief Set the I/O semantics for accessing a file.
106
*
107
* \param fd The file descriptor through which the file is accessed.
108
* \param flags A bit vector of flags.
109
*
110
* Coffee is used on a wide range of storage types, and the default
111
* I/O file semantics may not be optimal for the access pattern
112
* of a certain file. Hence, this functions allows programmers to
113
* switch the /O semantics on a file that is accessed through a
114
* particular file descriptor.
115
*
116
*/
117
int
cfs_coffee_set_io_semantics
(
int
fd,
unsigned
flags
);
118
119
/**
120
* \brief Format the storage area assigned to Coffee.
121
* \return 0 on success, -1 on failure.
122
*
123
* Coffee formats the underlying storage by setting all bits to zero.
124
* Formatting must be done before using Coffee for the first time in
125
* a mote.
126
*/
127
int
cfs_coffee_format
(
void
);
128
129
/**
130
* \brief Points out a memory region that may not be altered during
131
* checkpointing operations that use the file system.
132
* \param size
133
* \return A pointer to the protected memory.
134
*
135
* This function returns the protected memory pointer and writes its size
136
* to the given parameter. Mainly used by sensornet checkpointing to protect
137
* the coffee state during CFS-based checkpointing operations.
138
*/
139
void
*
cfs_coffee_get_protected_mem
(
unsigned
*size);
140
141
/** @} */
142
/** @} */
143
144
#endif
/* !COFFEE_H */
Generated on Fri Aug 30 2013 12:34:04 for Contiki 2.5 by
1.8.3.1