Signed-off-by: Charles Manning <cdhmanning@gmail.com>
#include "yaffs_fsx.h"
#include <stdio.h>
#include "yaffs_fsx.h"
#include <stdio.h>
* yaffs direct. Seek out the original fsx.c if you want to do anything
* else.
*
* yaffs direct. Seek out the original fsx.c if you want to do anything
* else.
*
*
* File: fsx.c
* Author: Avadis Tevanian, Jr.
*
*
* File: fsx.c
* Author: Avadis Tevanian, Jr.
*
- * File system exerciser.
+ * File system exerciser.
*
* Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
*
*
* Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
*
int closeprob = 0; /* -c flag */
int debug = 0; /* -d flag */
unsigned long debugstart = 0; /* -D flag */
int closeprob = 0; /* -c flag */
int debug = 0; /* -d flag */
unsigned long debugstart = 0; /* -D flag */
-unsigned long maxfilelen = 256 * 1024; /* -l flag */
+long int maxfilelen = 256 * 1024; /* -l flag */
int sizechecks = 1; /* -n flag disables them */
int maxoplen = 64 * 1024; /* -o flag */
int quiet = 0; /* -q flag */
int sizechecks = 1; /* -n flag disables them */
int maxoplen = 64 * 1024; /* -o flag */
int quiet = 0; /* -q flag */
lp = &oplog[i];
if ((closeopen = lp->operation < 0))
lp->operation = ~ lp->operation;
lp = &oplog[i];
if ((closeopen = lp->operation < 0))
lp->operation = ~ lp->operation;
switch (lp->operation) {
case OP_MAPREAD:
prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
switch (lp->operation) {
case OP_MAPREAD:
prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
if (ret == (off_t)-1)
prterr("save_buffer: lseek 0");
ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
if (ret == (off_t)-1)
prterr("save_buffer: lseek 0");
byteswritten = yaffs_write(fd, buffer, (size_t)bufferlength);
if (byteswritten != bufferlength) {
if (byteswritten == -1)
byteswritten = yaffs_write(fd, buffer, (size_t)bufferlength);
if (byteswritten != bufferlength) {
if (byteswritten == -1)
report_failure(int status)
{
logdump();
report_failure(int status)
{
logdump();
if (fsxgoodfd) {
if (good_buf) {
save_buffer(good_buf, file_size, fsxgoodfd);
if (fsxgoodfd) {
if (good_buf) {
save_buffer(good_buf, file_size, fsxgoodfd);
-doread(unsigned offset, unsigned size)
+doread(unsigned offset, int size)
offset -= offset % readbdy;
if (size == 0) {
offset -= offset % readbdy;
if (size == 0) {
gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
{
while (size--) {
gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
{
while (size--) {
- good_buf[offset] = testcalls % 256;
+ good_buf[offset] = testcalls % 256;
if (offset % 2)
good_buf[offset] += original_buf[offset];
offset++;
if (offset % 2)
good_buf[offset] += original_buf[offset];
offset++;
-dowrite(unsigned offset, unsigned size)
+dowrite(unsigned offset, int size)
offset -= offset % writebdy;
if (size == 0) {
offset -= offset % writebdy;
if (size == 0) {
if (testcalls <= simulatedopcount)
return;
if (testcalls <= simulatedopcount)
return;
if ((progressinterval && testcalls % progressinterval == 0) ||
(debug && (monitorstart == -1 || monitorend == -1 ||
size <= monitorend)))
if ((progressinterval && testcalls % progressinterval == 0) ||
(debug && (monitorstart == -1 || monitorend == -1 ||
size <= monitorend)))
if (testcalls <= simulatedopcount)
return;
if (testcalls <= simulatedopcount)
return;
void
yaffs_fsx_do_op(void)
{
void
yaffs_fsx_do_op(void)
{
- unsigned long offset;
- unsigned long size = maxoplen;
- unsigned long rv = random();
- unsigned long op = rv % (3 + !lite + mapped_writes);
+ long int offset;
+ long int size = maxoplen;
+ long int rv = random();
+ long int op = rv % (3 + !lite + mapped_writes);
/* turn off the map read if necessary */
/* turn off the map read if necessary */
strcpy(mount_name,mount_pt);
strcpy(fname,mount_name);
strcat(fname,"/fsxdata");
strcpy(mount_name,mount_pt);
strcpy(fname,mount_name);
strcat(fname,"/fsxdata");
#if 0
signal(SIGHUP, cleanup);
signal(SIGINT, cleanup);
#if 0
signal(SIGHUP, cleanup);
signal(SIGINT, cleanup);
(unsigned)written, maxfilelen);
EXIT(98);
}
(unsigned)written, maxfilelen);
EXIT(98);
}
printf("yaffs_fsx_init done\n");
printf("yaffs_fsx_init done\n");
prterr("close");
report_failure(99);
}
prterr("close");
report_failure(99);
}
prt("All operations completed A-OK!\n");
EXIT(0);
prt("All operations completed A-OK!\n");
EXIT(0);
while (numops == -1 || numops--)
yaffs_fsx_do_op();
yaffs_fsx_complete();
while (numops == -1 || numops--)
yaffs_fsx_do_op();
yaffs_fsx_complete();
const struct yaffs_utimbuf *buf)
{
int retVal = -1;
const struct yaffs_utimbuf *buf)
{
int retVal = -1;
- struct yaffs_utimbuf local;
obj = yaffs_get_equivalent_obj(obj);
obj = yaffs_get_equivalent_obj(obj);
}
#if !CONFIG_YAFFS_WINCE
}
#if !CONFIG_YAFFS_WINCE
- if (!buf) {
- local.actime = Y_CURRENT_TIME;
- local.modtime = local.actime;
- buf = &local;
- }
+ {
+ struct yaffs_utimbuf local;
- if (obj) {
- int result;
+ if (!buf) {
+ local.actime = Y_CURRENT_TIME;
+ local.modtime = local.actime;
+ buf = &local;
+ }
- obj->yst_atime = buf->actime;
- obj->yst_mtime = buf->modtime;
- obj->dirty = 1;
- result = yaffs_flush_file(obj, 0, 0, 0);
- retVal = result == YAFFS_OK ? 0 : -1;
+ if (obj) {
+ int result;
+
+ obj->yst_atime = buf->actime;
+ obj->yst_mtime = buf->modtime;
+ obj->dirty = 1;
+ result = yaffs_flush_file(obj, 0, 0, 0);
+ retVal = result == YAFFS_OK ? 0 : -1;
+ }
char *ascii_oh_name = (char *)oh_name;
int n = YAFFS_MAX_NAME_LENGTH - 1;
while (n > 0 && *name) {
char *ascii_oh_name = (char *)oh_name;
int n = YAFFS_MAX_NAME_LENGTH - 1;
while (n > 0 && *name) {
- *ascii_oh_name = *name;
+ *ascii_oh_name = (char)*name;
name++;
ascii_oh_name++;
n--;
name++;
ascii_oh_name++;
n--;
* in the tree. 0 means only the level 0 tnode is in the tree.
*/
* in the tree. 0 means only the level 0 tnode is in the tree.
*/
-/* FindLevel0Tnode finds the level 0 tnode, if one exists. */
+/* yaffs_find_tnode_0 finds the level 0 tnode, if one exists. */
struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev,
struct yaffs_file_var *file_struct,
u32 chunk_id)
struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev,
struct yaffs_file_var *file_struct,
u32 chunk_id)
if (bits <= dev->tnode_width)
dev->chunk_grp_bits = 0;
else
if (bits <= dev->tnode_width)
dev->chunk_grp_bits = 0;
else
- dev->chunk_grp_bits = bits - dev->tnode_width;
+ dev->chunk_grp_bits = (u16)(bits - dev->tnode_width);
dev->tnode_size = (dev->tnode_width * YAFFS_NTNODES_LEVEL0) / 8;
if (dev->tnode_size < sizeof(struct yaffs_tnode))
dev->tnode_size = (dev->tnode_width * YAFFS_NTNODES_LEVEL0) / 8;
if (dev->tnode_size < sizeof(struct yaffs_tnode))
int yaffs_query_init_block_state(struct yaffs_dev *dev,
int block_no,
enum yaffs_block_state *state,
int yaffs_query_init_block_state(struct yaffs_dev *dev,
int block_no,
enum yaffs_block_state *state,
int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);
int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);
struct yaffs_summary_header hdr;
struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr);
struct yaffs_summary_header hdr;
struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr);
- sum_tags_bytes = sizeof(struct yaffs_summary_tags) *
- dev->chunks_per_summary;
buffer = yaffs_get_temp_buffer(dev);
n_bytes = sizeof(struct yaffs_summary_tags) * dev->chunks_per_summary;
chunk_in_block = dev->chunks_per_summary;
buffer = yaffs_get_temp_buffer(dev);
n_bytes = sizeof(struct yaffs_summary_tags) * dev->chunks_per_summary;
chunk_in_block = dev->chunks_per_summary;
- if (tags && ecc_result == -YAFFS_ECC_RESULT_FIXED) {
+ if (tags && ecc_result == YAFFS_ECC_RESULT_FIXED) {
if (tags->ecc_result <= YAFFS_ECC_RESULT_NO_ERROR)
tags->ecc_result = YAFFS_ECC_RESULT_FIXED;
dev->n_ecc_fixed++;
if (tags->ecc_result <= YAFFS_ECC_RESULT_NO_ERROR)
tags->ecc_result = YAFFS_ECC_RESULT_FIXED;
dev->n_ecc_fixed++;