Linux Kernel
3.7.1
|
Go to the source code of this file.
int ubifs_bg_wbufs_sync | ( | struct ubifs_info * | c | ) |
int ubifs_check_node | ( | const struct ubifs_info * | c, |
const void * | buf, | ||
int | lnum, | ||
int | offs, | ||
int | quiet, | ||
int | must_chk_crc | ||
) |
ubifs_check_node - check node. : UBIFS file-system description object : node to check : logical eraseblock number : offset within the logical eraseblock : print no messages : indicates whether to always check the CRC
This function checks node magic number and CRC checksum. This function also validates node length to prevent UBIFS from becoming crazy when an attacker feeds it a file-system image with incorrect nodes. For example, too large node length in the common header could cause UBIFS to read memory outside of allocated buffer when checking the CRC checksum.
This function may skip data nodes CRC checking if ->no_chk_data_crc is true, which is controlled by corresponding UBIFS mount option. However, if is true, then
->no_chk_data_crc is ignored and CRC is checked. Similarly, if
->mounting or
->remounting_rw is true (we are mounting or re-mounting to R/W mode),
->no_chk_data_crc is ignored and CRC is checked. This is because during mounting or re-mounting from R/O mode to R/W mode we may read journal nodes (when replying the journal or doing the recovery) and the journal nodes may potentially be corrupted, so checking is required.
This function returns zero in case of success and %-EUCLEAN in case of bad CRC or magic.
ubifs_pad - pad flash space. : UBIFS file-system description object : buffer to put padding to : how many bytes to pad
The flash media obliges us to write only in chunks of c->min_io_size and when we have to write less data we add padding node to the write-buffer and pad it to the next minimal I/O unit's boundary. Padding nodes help when the media is being scanned. If the amount of wasted space is not enough to fit a padding node which takes UBIFS_PAD_NODE_SZ bytes, we write padding bytes pattern (UBIFS_PADDING_BYTE).
Padding nodes are also used to fill gaps when the "commit-in-gaps" method is used.
ubifs_prepare_node - prepare node to be written to flash. : UBIFS file-system description object : the node to pad : node length : if the buffer has to be padded
This function prepares node at to be written to the media - it calculates node CRC, fills the common header, and adds proper padding up to the next minimum I/O unit if is not zero.
int ubifs_read_node | ( | const struct ubifs_info * | c, |
void * | buf, | ||
int | type, | ||
int | len, | ||
int | lnum, | ||
int | offs | ||
) |
ubifs_read_node - read node. : UBIFS file-system description object : buffer to read to : node type : node length (not aligned) : logical eraseblock number : offset within the logical eraseblock
This function reads a node of known type and and length, checks it and stores in . Returns zero in case of success, %-EUCLEAN if CRC mismatched and a negative error code in case of failure.
int ubifs_read_node_wbuf | ( | struct ubifs_wbuf * | wbuf, |
void * | buf, | ||
int | type, | ||
int | len, | ||
int | lnum, | ||
int | offs | ||
) |
ubifs_read_node_wbuf - read node from the media or write-buffer. : wbuf to check for un-written data : buffer to read to : node type : node length : logical eraseblock number : offset within the logical eraseblock
This function reads a node of known type and length, checks it and stores in . If the node partially or fully sits in the write-buffer, this function takes data from the buffer, otherwise it reads the flash media. Returns zero in case of success, %-EUCLEAN if CRC mismatched and a negative error code in case of failure.
void ubifs_ro_mode | ( | struct ubifs_info * | c, |
int | err | ||
) |
int ubifs_sync_wbufs_by_inode | ( | struct ubifs_info * | c, |
struct inode * | inode | ||
) |
ubifs_sync_wbufs_by_inode - synchronize write-buffers for an inode. : UBIFS file-system description object : inode to synchronize
This function synchronizes write-buffers which contain nodes belonging to . Returns zero in case of success and a negative error code in case of failure.
void ubifs_wbuf_add_ino_nolock | ( | struct ubifs_wbuf * | wbuf, |
ino_t | inum | ||
) |
int ubifs_wbuf_init | ( | struct ubifs_info * | c, |
struct ubifs_wbuf * | wbuf | ||
) |
int ubifs_wbuf_seek_nolock | ( | struct ubifs_wbuf * | wbuf, |
int | lnum, | ||
int | offs | ||
) |
ubifs_wbuf_seek_nolock - seek write-buffer. : write-buffer : logical eraseblock number to seek to : logical eraseblock offset to seek to
This function targets the write-buffer to logical eraseblock :. The write-buffer has to be empty. Returns zero in case of success and a negative error code in case of failure.
int ubifs_wbuf_sync_nolock | ( | struct ubifs_wbuf * | wbuf | ) |
ubifs_wbuf_sync_nolock - synchronize write-buffer. : write-buffer to synchronize
This function synchronizes write-buffer and returns zero in case of success or a negative error code in case of failure.
Note, although write-buffers are of ->max_write_size, this function does not necessarily writes all
->max_write_size bytes to the flash. Instead, if the write-buffer is only partially filled with data, only the used part of the write-buffer (aligned on
->min_io_size boundary) is synchronized. This way we waste less space.
int ubifs_wbuf_write_nolock | ( | struct ubifs_wbuf * | wbuf, |
void * | buf, | ||
int | len | ||
) |
ubifs_wbuf_write_nolock - write data to flash via write-buffer. : write-buffer : node to write : node length
This function writes data to flash via write-buffer . This means that the last piece of the node won't reach the flash media immediately if it does not take whole max. write unit (->max_write_size). Instead, the node will sit in RAM until the write-buffer is synchronized (e.g., by timer, or because more data are appended to the write-buffer).
This function returns zero in case of success and a negative error code in case of failure. If the node cannot be written because there is no more space in this logical eraseblock, %-ENOSPC is returned.
ubifs_write_node - write node to the media. : UBIFS file-system description object : the node to write : node length : logical eraseblock number : offset within the logical eraseblock
This function automatically fills node magic number, assigns sequence number, and calculates node CRC checksum. The length of the buffer has to be aligned to the minimal I/O unit size. This function automatically appends padding node and padding bytes if needed. Returns zero in case of success and a negative error code in case of failure.