Signed-off-by: Charles Manning <cdhmanning@gmail.com>
30 files changed:
CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2 -DCONFIG_YAFFS_DEFINES_TYPES
CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_YAFFS2 -DCONFIG_YAFFS_DEFINES_TYPES
CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
-CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing
+CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing -Werror
#CFLAGS += -fno-strict-aliasing
CFLAGS += -O0
CFLAGS += -Wextra -Wpointer-arith
#CFLAGS += -fno-strict-aliasing
CFLAGS += -O0
CFLAGS += -Wextra -Wpointer-arith
{
unsigned char status;
int ncycles;
{
unsigned char status;
int ncycles;
- unsigned short *buffer = tr->buffer;
+ unsigned short *buffer = (unsigned short *)tr->buffer;
ncycles = tr->nbytes >> 1;
while (ncycles> 0) {
ncycles = tr->nbytes >> 1;
while (ncycles> 0) {
- unsigned short *buffer = tr->buffer;
+ unsigned short *buffer = (unsigned short *)tr->buffer;
ncycles = tr->nbytes >> 1;
while (ncycles> 0) {
ncycles = tr->nbytes >> 1;
while (ncycles> 0) {
static void idle(struct nandsim_private *ns, int line)
{
static void idle(struct nandsim_private *ns, int line)
{
ns->read_offset = -1;
ns->write_offset = -1;
ns->addr_offset = -1;
ns->read_offset = -1;
ns->write_offset = -1;
ns->addr_offset = -1;
static void load_read_buffer(struct nandsim_private *ns)
{
int addr = get_page_address(ns);
static void load_read_buffer(struct nandsim_private *ns)
{
int addr = get_page_address(ns);
debug(1, "Store read at address %d\n", addr);
ns->store->retrieve(ns->store, addr,ns->buffer);
}
static void save_write_buffer(struct nandsim_private *ns)
{
int addr = get_page_address(ns);
debug(1, "Store read at address %d\n", addr);
ns->store->retrieve(ns->store, addr,ns->buffer);
}
static void save_write_buffer(struct nandsim_private *ns)
{
int addr = get_page_address(ns);
debug(1, "Store write at address %d\n", addr);
ns->store->store(ns->store, addr, ns->buffer);
}
static void check_read_buffer(struct nandsim_private *ns, int line)
{
debug(1, "Store write at address %d\n", addr);
ns->store->store(ns->store, addr, ns->buffer);
}
static void check_read_buffer(struct nandsim_private *ns, int line)
{
+ (void) ns;
+ (void) line;
}
static void end_cmd(struct nandsim_private *ns, int line)
{
}
static void end_cmd(struct nandsim_private *ns, int line)
{
ns->last_cmd_byte = 0xff;
}
static void set_busy(struct nandsim_private *ns, int cycles, int line)
{
ns->last_cmd_byte = 0xff;
}
static void set_busy(struct nandsim_private *ns, int cycles, int line)
{
ns->busy_count = cycles;
}
ns->busy_count = cycles;
}
static void read_id(struct nandsim_private *ns)
{
static void read_id(struct nandsim_private *ns)
{
}
static void unsupported(struct nandsim_private *ns)
{
}
static void unsupported(struct nandsim_private *ns)
{
}
static void nandsim_cl_write(struct nandsim_private *ns, unsigned char val)
}
static void nandsim_cl_write(struct nandsim_private *ns, unsigned char val)
check_not_busy(ns, __LINE__);
if(ns->addr_expected < 1 ||
ns->addr_offset < 0 ||
check_not_busy(ns, __LINE__);
if(ns->addr_expected < 1 ||
ns->addr_offset < 0 ||
- ns->addr_offset >= sizeof(ns->addr_buffer)){
+ ns->addr_offset >= (int)sizeof(ns->addr_buffer)){
debug(1, "Address write when not expected\n");
} else {
debug(1, "Address write when expecting %d bytes\n",
debug(1, "Address write when not expected\n");
} else {
debug(1, "Address write when expecting %d bytes\n",
-static void nandsim_dl_write(struct nandsim_private *ns,
+static void nandsim_dl_write(struct nandsim_private *ns,
unsigned val,
int bus_width_shift)
{
unsigned val,
int bus_width_shift)
{
#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
*
unsigned long testcalls = 0; /* calls to function "test" */
unsigned long simulatedopcount = 0; /* -b flag */
unsigned long testcalls = 0; /* calls to function "test" */
unsigned long simulatedopcount = 0; /* -b flag */
-int closeprob = 0; /* -c flag */
+unsigned closeprob = 0; /* -c flag */
int debug = 0; /* -d flag */
unsigned long debugstart = 0; /* -D flag */
unsigned long maxfilelen = 256 * 1024; /* -l flag */
int debug = 0; /* -d flag */
unsigned long debugstart = 0; /* -D flag */
unsigned long maxfilelen = 256 * 1024; /* -l 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);
statbuf.st_size = -1;
}
size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
statbuf.st_size = -1;
}
size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
- if (file_size != statbuf.st_size || file_size != size_by_seek) {
+ if (file_size != statbuf.st_size ||
+ file_size != size_by_seek) {
prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
(unsigned long long)file_size,
(unsigned long long)statbuf.st_size,
prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
(unsigned long long)file_size,
(unsigned long long)statbuf.st_size,
log4(OP_SKIPPED, OP_READ, offset, size);
return;
}
log4(OP_SKIPPED, OP_READ, offset, size);
return;
}
- if (size + offset > file_size) {
+ if ((off_t)(size + offset) > file_size) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping seek/read past end of file\n");
log4(OP_SKIPPED, OP_READ, offset, size);
if (!quiet && testcalls > simulatedopcount)
prt("skipping seek/read past end of file\n");
log4(OP_SKIPPED, OP_READ, offset, size);
}
iret = yaffs_read(fd, temp_buf, size);
if (iret != size) {
}
iret = yaffs_read(fd, temp_buf, size);
if (iret != size) {
+ if (iret == (unsigned)(-1))
prterr("doread: read");
else
prt("short read: 0x%x bytes instead of 0x%x\n",
prterr("doread: read");
else
prt("short read: 0x%x bytes instead of 0x%x\n",
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++;
}
iret = yaffs_write(fd, good_buf + offset, size);
if (iret != size) {
}
iret = yaffs_write(fd, good_buf + offset, size);
if (iret != size) {
+ if (iret == (unsigned)(-1))
prterr("dowrite: write");
else
prt("short write: 0x%x bytes instead of 0x%x\n",
prterr("dowrite: write");
else
prt("short write: 0x%x bytes instead of 0x%x\n",
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;
testcalls++;
if (closeprob)
testcalls++;
if (closeprob)
- closeopen = (rv >> 3) < (1 << 28) / closeprob;
+ closeopen = (rv >> 3) < (1U << 28) / closeprob;
if (debugstart > 0 && testcalls >= debugstart)
debug = 1;
if (debugstart > 0 && testcalls >= debugstart)
debug = 1;
offset %= file_size;
else
offset = 0;
offset %= file_size;
else
offset = 0;
- if (offset + size > file_size)
+ if ((ssize_t)(offset + size) > file_size)
size = file_size - offset;
doread(offset, size);
}
size = file_size - offset;
doread(offset, size);
}
int
yaffs_fsx_init(const char *mount_pt)
{
int
yaffs_fsx_init(const char *mount_pt)
{
goodfile[0] = 0;
logfile[0] = 0;
goodfile[0] = 0;
logfile[0] = 0;
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);
ssize_t written;
written = yaffs_write(fd, good_buf, (size_t)maxfilelen);
ssize_t written;
written = yaffs_write(fd, good_buf, (size_t)maxfilelen);
- if (written != maxfilelen) {
+ if (written != (ssize_t)maxfilelen) {
if (written == -1) {
prterr(fname);
warn("main: error on write");
if (written == -1) {
prterr(fname);
warn("main: error on write");
(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();
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
{
u8 data[528]; // Data + spare
} yflash_Page;
{
u8 data[528]; // Data + spare
} yflash_Page;
typedef struct
{
yflash_Page page[32]; // The pages in the block
typedef struct
{
yflash_Page page[32]; // The pages in the block
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
+
+ (void)dev;
+
+ if(initialised)
{
return YAFFS_OK;
}
initialised = 1;
{
return YAFFS_OK;
}
initialised = 1;
filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
filedisk.handle = open("emfile-512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
filedisk.handle = open("emfile-512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
if(filedisk.handle < 0)
{
perror("Failed to open yaffs emulation file");
return YAFFS_FAIL;
}
if(filedisk.handle < 0)
{
perror("Failed to open yaffs emulation file");
return YAFFS_FAIL;
}
fSize = lseek(filedisk.handle,0,SEEK_END);
fSize = lseek(filedisk.handle,0,SEEK_END);
if(fSize < SIZE_IN_MB * 1024 * 1024)
{
printf("Creating yaffs emulation file\n");
if(fSize < SIZE_IN_MB * 1024 * 1024)
{
printf("Creating yaffs emulation file\n");
lseek(filedisk.handle,0,SEEK_SET);
lseek(filedisk.handle,0,SEEK_SET);
memset(&p,0xff,sizeof(yflash_Page));
memset(&p,0xff,sizeof(yflash_Page));
for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512)
{
written = write(filedisk.handle,&p,sizeof(yflash_Page));
for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512)
{
written = write(filedisk.handle,&p,sizeof(yflash_Page));
if(written != sizeof(yflash_Page))
{
printf("Write failed\n");
return YAFFS_FAIL;
}
if(written != sizeof(yflash_Page))
{
printf("Write failed\n");
return YAFFS_FAIL;
}
int written;
CheckInit(dev);
int written;
CheckInit(dev);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
written = write(filedisk.handle,data,512);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
written = write(filedisk.handle,data,512);
if(written != 512) return YAFFS_FAIL;
}
if(written != 512) return YAFFS_FAIL;
}
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
written = write(filedisk.handle,spare,16);
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
written = write(filedisk.handle,spare,16);
if(written != 16) return YAFFS_FAIL;
}
if(written != 16) return YAFFS_FAIL;
}
int nread;
CheckInit(dev);
int nread;
CheckInit(dev);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
nread = read(filedisk.handle,data,512);
if(data)
{
lseek(filedisk.handle,nand_chunk * 528,SEEK_SET);
nread = read(filedisk.handle,data,512);
if(nread != 512) return YAFFS_FAIL;
}
if(nread != 512) return YAFFS_FAIL;
}
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
nread= read(filedisk.handle,spare,16);
if(spare)
{
lseek(filedisk.handle,nand_chunk * 528 + 512,SEEK_SET);
nread= read(filedisk.handle,spare,16);
if(nread != 16) return YAFFS_FAIL;
}
if(nread != 16) return YAFFS_FAIL;
}
}
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
}
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
memset(&pg,0xff,sizeof(yflash_Page));
memset(&pg,0xff,sizeof(yflash_Page));
lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
for(i = 0; i < 32; i++)
{
write(filedisk.handle,&pg,528);
}
return YAFFS_OK;
}
for(i = 0; i < 32; i++)
{
write(filedisk.handle,&pg,528);
}
return YAFFS_OK;
}
}
int yflash_InitialiseNAND(struct yaffs_dev *dev)
{
}
int yflash_InitialiseNAND(struct yaffs_dev *dev)
{
static void yflash2_MaybePowerFail(unsigned int nand_chunk, int failPoint)
{
static void yflash2_MaybePowerFail(unsigned int nand_chunk, int failPoint)
{
-
-
-
-
-static u8 localBuffer[PAGE_SIZE];
-
static char *NToName(char *buf,int n)
{
sprintf(buf,"emfile-2k-%d",n);
static char *NToName(char *buf,int n)
{
sprintf(buf,"emfile-2k-%d",n);
static int yflash2_EraseBlock(struct yaffs_dev *dev, int block_no)
{
static int yflash2_EraseBlock(struct yaffs_dev *dev, int block_no)
{
u8 pg[PAGE_SIZE];
int syz = PAGE_SIZE;
u8 pg[PAGE_SIZE];
int syz = PAGE_SIZE;
{
write(h,pg,PAGE_SIZE);
}
{
write(h,pg,PAGE_SIZE);
}
- pos = lseek(h, 0,SEEK_CUR);
u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
if(data)
{
m18_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
if(data)
{
m18_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
static int m18_drv_InitialiseNAND(struct yaffs_dev *dev)
{
static int m18_drv_InitialiseNAND(struct yaffs_dev *dev)
{
m18_drv_FlashInit();
/* Go through the blocks formatting them if they are not formatted */
m18_drv_FlashInit();
/* Go through the blocks formatting them if they are not formatted */
/* Set up and execute transfer */
/* Set up and execute transfer */
+ tr[0].buffer = (u8 *)data;
tr[0].offset = 0;
tr[0].nbytes = data_len;
tr[0].offset = 0;
tr[0].nbytes = data_len;
struct nand_chip *chip = dev_to_chip(dev);
u8 *buffer = dev_to_buffer(dev);
int nand_chunk = block_no * chip->pages_per_block;
struct nand_chip *chip = dev_to_chip(dev);
u8 *buffer = dev_to_buffer(dev);
int nand_chunk = block_no * chip->pages_per_block;
struct nanddrv_transfer tr[1];
memset(buffer, 0, chip->spare_bytes_per_page);
struct nanddrv_transfer tr[1];
memset(buffer, 0, chip->spare_bytes_per_page);
tr[0].offset = chip->data_bytes_per_page;
tr[0].nbytes = chip->spare_bytes_per_page;
tr[0].offset = chip->data_bytes_per_page;
tr[0].nbytes = chip->spare_bytes_per_page;
- ret = nanddrv_read_tr(chip, nand_chunk, tr, 1);
+ nanddrv_read_tr(chip, nand_chunk, tr, 1);
/* Check that bad block marker is not set */
if(yaffs_hweight8(buffer[0]) + yaffs_hweight8(buffer[1]) < 14)
/* Check that bad block marker is not set */
if(yaffs_hweight8(buffer[0]) + yaffs_hweight8(buffer[1]) < 14)
#include "yaffs_nandsim_file.h"
#include "yaffs_nandsim_file.h"
+#include "yaffs_nand_drv.h"
#include "nandsim_file.h"
#include "nand_chip.h"
#include "yaffs_guts.h"
#include "nandsim_file.h"
#include "nand_chip.h"
#include "yaffs_guts.h"
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-#ifndef __YAFFS_NAND_DRV_H__
-#define __YAFFS_NAND_DRV_H__
+#ifndef __YAFFS_NANDSIM_FILE_H__
+#define __YAFFS_NANDSIM_FILE_H__
-struct yaffs_dev *yaffs_nandsim_file_install(const char *dev_name,
+struct yaffs_dev *yaffs_nandsim_install_drv(const char *dev_name,
const char *backing_file_name,
int n_blocks);
const char *backing_file_name,
int n_blocks);
u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
if (data) {
nor_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / sizeof(u32));
}
if (data) {
nor_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / sizeof(u32));
}
static int nor_drv_InitialiseNAND(struct yaffs_dev *dev)
{
static int nor_drv_InitialiseNAND(struct yaffs_dev *dev)
{
nor_drv_FlashInit();
/* Go through the blocks formatting them if they are not formatted */
nor_drv_FlashInit();
/* Go through the blocks formatting them if they are not formatted */
*/
int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request)
{
*/
int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request)
{
+ (void) size;
+ (void) write_request;
+
if(!addr)
return -1;
return 0;
if(!addr)
return -1;
return 0;
int result;
int next_urgent;
int result;
int next_urgent;
/* Sleep for a bit to allow start up */
sleep(2);
/* Sleep for a bit to allow start up */
sleep(2);
{
u8 data[528]; // Data + spare
} yramdisk_page;
{
u8 data[528]; // Data + spare
} yramdisk_page;
typedef struct
{
yramdisk_page page[32]; // The pages in the block
typedef struct
{
yramdisk_page page[32]; // The pages in the block
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
static int CheckInit(struct yaffs_dev *dev)
{
static int initialised = 0;
{
return YAFFS_OK;
}
initialised = 1;
{
return YAFFS_OK;
}
initialised = 1;
ramdisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
ramdisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
ramdisk.block = malloc(sizeof(yramdisk_block *) * ramdisk.nBlocks);
ramdisk.block = malloc(sizeof(yramdisk_block *) * ramdisk.nBlocks);
if(!ramdisk.block) return 0;
if(!ramdisk.block) return 0;
for(i=0; i <ramdisk.nBlocks; i++)
{
ramdisk.block[i] = NULL;
}
for(i=0; i <ramdisk.nBlocks; i++)
{
ramdisk.block[i] = NULL;
}
for(i=0; i <ramdisk.nBlocks && !fail; i++)
{
if((ramdisk.block[i] = malloc(sizeof(yramdisk_block))) == 0)
for(i=0; i <ramdisk.nBlocks && !fail; i++)
{
if((ramdisk.block[i] = malloc(sizeof(yramdisk_block))) == 0)
if(fail)
{
for(i = 0; i < nAllocated; i++)
if(fail)
{
for(i = 0; i < nAllocated; i++)
kfree(ramdisk.block[i]);
}
kfree(ramdisk.block);
kfree(ramdisk.block[i]);
}
kfree(ramdisk.block);
yaffs_trace(YAFFS_TRACE_ALWAYS,
"Allocation failed, could only allocate %dMB of %dMB requested.\n",
nAllocated/64,ramdisk.nBlocks * 528);
return 0;
}
yaffs_trace(YAFFS_TRACE_ALWAYS,
"Allocation failed, could only allocate %dMB of %dMB requested.\n",
nAllocated/64,ramdisk.nBlocks * 528);
return 0;
}
blk = nand_chunk/32;
pg = nand_chunk%32;
blk = nand_chunk/32;
pg = nand_chunk%32;
if(data)
{
memcpy(ramdisk.block[blk]->page[pg].data,data,512);
}
if(data)
{
memcpy(ramdisk.block[blk]->page[pg].data,data,512);
}
if(tags)
{
struct yaffs_packed_tags1 pt;
if(tags)
{
struct yaffs_packed_tags1 pt;
yaffs_pack_tags1(&pt,tags);
memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
}
yaffs_pack_tags1(&pt,tags);
memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
}
blk = nand_chunk/32;
pg = nand_chunk%32;
blk = nand_chunk/32;
pg = nand_chunk%32;
if(data)
{
memcpy(data,ramdisk.block[blk]->page[pg].data,512);
}
if(data)
{
memcpy(data,ramdisk.block[blk]->page[pg].data,512);
}
if(tags)
{
struct yaffs_packed_tags1 pt;
if(tags)
{
struct yaffs_packed_tags1 pt;
memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt));
yaffs_unpack_tags1(tags,&pt);
memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt));
yaffs_unpack_tags1(tags,&pt);
blk = nand_chunk/32;
pg = nand_chunk%32;
blk = nand_chunk/32;
pg = nand_chunk%32;
for(i = 0; i < 528; i++)
{
if(ramdisk.block[blk]->page[pg].data[i] != 0xFF)
for(i = 0; i < 528; i++)
{
if(ramdisk.block[blk]->page[pg].data[i] != 0xFF)
int yramdisk_erase(struct yaffs_dev *dev, int blockNumber)
{
int yramdisk_erase(struct yaffs_dev *dev, int blockNumber)
{
if(blockNumber < 0 || blockNumber >= ramdisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
if(blockNumber < 0 || blockNumber >= ramdisk.nBlocks)
{
yaffs_trace(YAFFS_TRACE_ALWAYS,
memset(ramdisk.block[blockNumber],0xFF,sizeof(yramdisk_block));
return YAFFS_OK;
}
memset(ramdisk.block[blockNumber],0xFF,sizeof(yramdisk_block));
return YAFFS_OK;
}
}
int yramdisk_initialise(struct yaffs_dev *dev)
{
}
int yramdisk_initialise(struct yaffs_dev *dev)
{
- //dev->use_nand_ecc = 1; // force on use_nand_ecc which gets faked.
+ (void) dev;
+
+ //dev->use_nand_ecc = 1; // force on use_nand_ecc which gets faked.
// This saves us doing ECC checks.
// This saves us doing ECC checks.
static void nandemul_yield(int n)
{
static void nandemul_yield(int n)
{
#ifdef __KERNEL__
if(n > 0) schedule_timeout(n);
#endif
#ifdef __KERNEL__
if(n > 0) schedule_timeout(n);
#endif
-
-static int nandemul2k_CheckChunkErased(struct yaffs_dev *dev,int nand_chunk)
-{
- int blk;
- int pg;
- int i;
-
-
-
- blk = nand_chunk/PAGES_PER_BLOCK;
- pg = nand_chunk%PAGES_PER_BLOCK;
-
-
- for(i = 0; i < PAGE_TOTAL_SIZE; i++)
- {
- if(ned.block[blk]->page[pg]->data[i] != 0xFF)
- {
- return YAFFS_FAIL;
- }
- }
-
- return YAFFS_OK;
-
-}
-
int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
{
if(blockNumber < 0 || blockNumber >= ned.nBlocks)
{
if(blockNumber < 0 || blockNumber >= ned.nBlocks)
{
int nandemul2k_InitialiseNAND(struct yaffs_dev *dev)
{
int nandemul2k_InitialiseNAND(struct yaffs_dev *dev)
{
CheckInit();
return YAFFS_OK;
}
CheckInit();
return YAFFS_OK;
}
x = &ned.block[block_no]->page[0]->data[PAGE_DATA_SIZE];
memset(x,0,sizeof(struct yaffs_packed_tags2));
x = &ned.block[block_no]->page[0]->data[PAGE_DATA_SIZE];
memset(x,0,sizeof(struct yaffs_packed_tags2));
#include "yaffs_nandemul2k.h"
#include "yaffs_trace.h"
#include "yaffs_osglue.h"
#include "yaffs_nandemul2k.h"
#include "yaffs_trace.h"
#include "yaffs_osglue.h"
+#include "yaffs_nandsim_file.h"
obj->yst_ctime = obj->yst_atime;
#endif
}
obj->yst_ctime = obj->yst_atime;
#endif
}
-
-static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj)
-{
- YCHAR *alias = NULL;
- obj = yaffs_get_equivalent_obj(obj);
-
- switch (obj->variant_type) {
- case YAFFS_OBJECT_TYPE_FILE:
- return obj->variant.file_variant.file_size;
- case YAFFS_OBJECT_TYPE_SYMLINK:
- alias = obj->variant.symlink_variant.alias;
- if (!alias)
- return 0;
- return yaffs_strnlen(alias, YAFFS_MAX_ALIAS_LENGTH);
- default:
- return 0;
- }
-}
-
+#define YAFFS_MAX_RW_SIZE 0x70000000
#define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
#ifndef NULL
#define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
#ifndef NULL
/* Not a reading handle */
yaffsfs_SetError(-EINVAL);
totalRead = -1;
/* Not a reading handle */
yaffsfs_SetError(-EINVAL);
totalRead = -1;
- } else if (nbyte > YAFFS_MAX_FILE_SIZE) {
+ } else if (nbyte > YAFFS_MAX_RW_SIZE) {
yaffsfs_SetError(-EINVAL);
totalRead = -1;
} else {
yaffsfs_SetError(-EINVAL);
totalRead = -1;
} else {
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
- nbyte > YAFFS_MAX_FILE_SIZE ||
+ nbyte > YAFFS_MAX_RW_SIZE ||
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalRead = -1;
nbyte = 0;
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalRead = -1;
nbyte = 0;
while (nbyte > 0) {
nToRead = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
while (nbyte > 0) {
nToRead = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
+ if (nToRead > (int)nbyte)
nToRead = nbyte;
/* Tricky bit...
nToRead = nbyte;
/* Tricky bit...
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
endPos = pos + nbyte;
if (pos < 0 || pos > YAFFS_MAX_FILE_SIZE ||
- nbyte > YAFFS_MAX_FILE_SIZE ||
+ nbyte > YAFFS_MAX_RW_SIZE ||
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalWritten = -1;
nbyte = 0;
endPos < 0 || endPos > YAFFS_MAX_FILE_SIZE) {
totalWritten = -1;
nbyte = 0;
nToWrite = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
nToWrite = YAFFSFS_RW_SIZE -
(pos & (YAFFSFS_RW_SIZE - 1));
+ if (nToWrite > (int)nbyte)
nToWrite = nbyte;
/* Tricky bit...
nToWrite = nbyte;
/* Tricky bit...
{
struct yaffsfs_FileDes *fdp = yaffsfs_HandleToFileDes(fd);
int retVal;
{
struct yaffsfs_FileDes *fdp = yaffsfs_HandleToFileDes(fd);
int retVal;
yaffsfs_Lock();
if(!flags || !fdp) {
yaffsfs_Lock();
if(!flags || !fdp) {
*flags = O_RDONLY;
retVal = 0;
}
*flags = O_RDONLY;
retVal = 0;
}
yaffsfs_Unlock();
return retVal;
}
yaffsfs_Unlock();
return retVal;
}
obj = yaffs_get_equivalent_obj(obj);
if (obj && buf) {
obj = yaffs_get_equivalent_obj(obj);
if (obj && buf) {
- buf->st_dev = (int)obj->my_dev->os_context;
buf->st_ino = obj->obj_id;
buf->st_mode = obj->yst_mode & ~S_IFMT;
buf->st_ino = obj->obj_id;
buf->st_mode = obj->yst_mode & ~S_IFMT;
if (dsc->nextReturn) {
dsc->de.d_ino =
yaffs_get_equivalent_obj(dsc->nextReturn)->obj_id;
if (dsc->nextReturn) {
dsc->de.d_ino =
yaffs_get_equivalent_obj(dsc->nextReturn)->obj_id;
- dsc->de.d_dont_use = (unsigned)dsc->nextReturn;
+ dsc->de.d_dont_use = 0;
dsc->de.d_off = dsc->offset++;
yaffs_get_obj_name(dsc->nextReturn,
dsc->de.d_name, NAME_MAX);
dsc->de.d_off = dsc->offset++;
yaffs_get_obj_name(dsc->nextReturn,
dsc->de.d_name, NAME_MAX);
static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
{
static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
{
- if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
+ if (blk < (int)dev->internal_start_block ||
+ blk > (int)dev->internal_end_block) {
yaffs_trace(YAFFS_TRACE_ERROR,
"BlockBits block %d is not valid",
blk);
yaffs_trace(YAFFS_TRACE_ERROR,
"BlockBits block %d is not valid",
blk);
void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk)
{
void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk)
{
- if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
- chunk < 0 || chunk >= dev->param.chunks_per_block) {
+ if (blk < (int)dev->internal_start_block ||
+ blk > (int)dev->internal_end_block ||
+ chunk < 0 || chunk >= (int)dev->param.chunks_per_block) {
yaffs_trace(YAFFS_TRACE_ERROR,
"Chunk Id (%d:%d) invalid",
blk, chunk);
yaffs_trace(YAFFS_TRACE_ERROR,
"Chunk Id (%d:%d) invalid",
blk, chunk);
static int yaffs_checkpt_erase(struct yaffs_dev *dev)
{
static int yaffs_checkpt_erase(struct yaffs_dev *dev)
{
if (!dev->drv.drv_erase_fn)
return 0;
if (!dev->drv.drv_erase_fn)
return 0;
static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev)
{
static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev)
{
int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks;
yaffs_trace(YAFFS_TRACE_CHECKPOINT,
int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks;
yaffs_trace(YAFFS_TRACE_CHECKPOINT,
blocks_avail, dev->checkpt_next_block);
if (dev->checkpt_next_block >= 0 &&
blocks_avail, dev->checkpt_next_block);
if (dev->checkpt_next_block >= 0 &&
- dev->checkpt_next_block <= dev->internal_end_block &&
+ dev->checkpt_next_block <= (int)dev->internal_end_block &&
blocks_avail > 0) {
for (i = dev->checkpt_next_block; i <= dev->internal_end_block;
blocks_avail > 0) {
for (i = dev->checkpt_next_block; i <= dev->internal_end_block;
static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
{
static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
{
struct yaffs_ext_tags tags;
yaffs_trace(YAFFS_TRACE_CHECKPOINT,
struct yaffs_ext_tags tags;
yaffs_trace(YAFFS_TRACE_CHECKPOINT,
int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing)
{
int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing)
{
dev->checkpt_open_write = writing;
dev->checkpt_open_write = writing;
dev->checkpt_buffer, &tags);
dev->checkpt_page_seq++;
dev->checkpt_cur_chunk++;
dev->checkpt_buffer, &tags);
dev->checkpt_page_seq++;
dev->checkpt_cur_chunk++;
- if (dev->checkpt_cur_chunk >= dev->param.chunks_per_block) {
+ if (dev->checkpt_cur_chunk >= (int)dev->param.chunks_per_block) {
dev->checkpt_cur_chunk = 0;
dev->checkpt_cur_block = -1;
}
dev->checkpt_cur_chunk = 0;
dev->checkpt_cur_block = -1;
}
dev->checkpt_byte_count++;
if (dev->checkpt_byte_offs < 0 ||
dev->checkpt_byte_count++;
if (dev->checkpt_byte_offs < 0 ||
- dev->checkpt_byte_offs >= dev->data_bytes_per_chunk)
+ dev->checkpt_byte_offs >= (int)dev->data_bytes_per_chunk)
ok = yaffs2_checkpt_flush_buffer(dev);
}
ok = yaffs2_checkpt_flush_buffer(dev);
}
while (i < n_bytes) {
if (dev->checkpt_byte_offs < 0 ||
while (i < n_bytes) {
if (dev->checkpt_byte_offs < 0 ||
- dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) {
+ dev->checkpt_byte_offs >= (int)dev->data_bytes_per_chunk) {
if (dev->checkpt_cur_block < 0) {
yaffs2_checkpt_find_block(dev);
if (dev->checkpt_cur_block < 0) {
yaffs2_checkpt_find_block(dev);
&tags);
/* Bail out if the chunk is corrupted. */
&tags);
/* Bail out if the chunk is corrupted. */
- if (tags.chunk_id != (dev->checkpt_page_seq + 1) ||
+ if (tags.chunk_id != (u32)(dev->checkpt_page_seq + 1) ||
tags.ecc_result > YAFFS_ECC_RESULT_FIXED ||
tags.seq_number != YAFFS_SEQUENCE_CHECKPOINT_DATA)
break;
tags.ecc_result > YAFFS_ECC_RESULT_FIXED ||
tags.seq_number != YAFFS_SEQUENCE_CHECKPOINT_DATA)
break;
dev->checkpt_cur_chunk++;
if (dev->checkpt_cur_chunk >=
dev->checkpt_cur_chunk++;
if (dev->checkpt_cur_chunk >=
- dev->param.chunks_per_block)
+ (int)dev->param.chunks_per_block)
dev->checkpt_cur_block = -1;
}
dev->checkpt_cur_block = -1;
}
int yaffs_checkpt_close(struct yaffs_dev *dev)
{
int yaffs_checkpt_close(struct yaffs_dev *dev)
{
if (dev->checkpt_open_write) {
if (dev->checkpt_byte_offs !=
if (dev->checkpt_open_write) {
if (dev->checkpt_byte_offs !=
int blk = dev->checkpt_block_list[i];
struct yaffs_block_info *bi = NULL;
int blk = dev->checkpt_block_list[i];
struct yaffs_block_info *bi = NULL;
- if (dev->internal_start_block <= blk &&
- blk <= dev->internal_end_block)
+ if ((int)dev->internal_start_block <= blk &&
+ blk <= (int)dev->internal_end_block)
bi = yaffs_get_block_info(dev, blk);
if (bi && bi->block_state == YAFFS_BLOCK_STATE_EMPTY)
bi->block_state = YAFFS_BLOCK_STATE_CHECKPOINT;
bi = yaffs_get_block_info(dev, blk);
if (bi && bi->block_state == YAFFS_BLOCK_STATE_EMPTY)
bi->block_state = YAFFS_BLOCK_STATE_CHECKPOINT;
return;
/* Change every field */
oh->type = swap_u32(oh->type);
return;
/* Change every field */
oh->type = swap_u32(oh->type);
- oh->parent_obj_id = swap_s32(oh->parent_obj_id);
+ oh->parent_obj_id = swap_u32(oh->parent_obj_id);
oh->yst_mode = swap_u32(oh->yst_mode);
oh->yst_mode = swap_u32(oh->yst_mode);
static inline struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev
*dev, int blk)
{
static inline struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev
*dev, int blk)
{
- if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
+ if (blk < (int)dev->internal_start_block ||
+ blk > (int)dev->internal_end_block) {
yaffs_trace(YAFFS_TRACE_ERROR,
"**>> yaffs: get_block_info block %d is not valid",
blk);
yaffs_trace(YAFFS_TRACE_ERROR,
"**>> yaffs: get_block_info block %d is not valid",
blk);
result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
- if (tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR)
+ if (result == YAFFS_FAIL ||
+ tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR)
retval = YAFFS_FAIL;
if (!yaffs_check_ff(data, dev->data_bytes_per_chunk) ||
retval = YAFFS_FAIL;
if (!yaffs_check_ff(data, dev->data_bytes_per_chunk) ||
int result;
result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
int result;
result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
- if (memcmp(buffer, data, dev->data_bytes_per_chunk) ||
+ if (result == YAFFS_FAIL ||
+ memcmp(buffer, data, dev->data_bytes_per_chunk) ||
temp_tags.obj_id != tags->obj_id ||
temp_tags.chunk_id != tags->chunk_id ||
temp_tags.n_bytes != tags->n_bytes)
temp_tags.obj_id != tags->obj_id ||
temp_tags.chunk_id != tags->chunk_id ||
temp_tags.n_bytes != tags->n_bytes)
static int yaffs_find_alloc_block(struct yaffs_dev *dev)
{
static int yaffs_find_alloc_block(struct yaffs_dev *dev)
{
struct yaffs_block_info *bi;
if (dev->n_erased_blocks < 1) {
struct yaffs_block_info *bi;
if (dev->n_erased_blocks < 1) {
for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
dev->alloc_block_finder++;
for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
dev->alloc_block_finder++;
- if (dev->alloc_block_finder < dev->internal_start_block
- || dev->alloc_block_finder > dev->internal_end_block) {
+ if (dev->alloc_block_finder < (int)dev->internal_start_block
+ || dev->alloc_block_finder > (int)dev->internal_end_block) {
dev->alloc_block_finder = dev->internal_start_block;
}
dev->alloc_block_finder = dev->internal_start_block;
}
- if (dev->n_erased_blocks < dev->param.n_reserved_blocks
+ if (dev->n_erased_blocks < (int)dev->param.n_reserved_blocks
&& dev->alloc_page == 0)
yaffs_trace(YAFFS_TRACE_ALLOCATE, "Allocating reserve");
&& dev->alloc_page == 0)
yaffs_trace(YAFFS_TRACE_ALLOCATE, "Allocating reserve");
const u8 *data,
struct yaffs_ext_tags *tags, int use_reserver)
{
const u8 *data,
struct yaffs_ext_tags *tags, int use_reserver)
{
int write_ok = 0;
int chunk;
int write_ok = 0;
int chunk;
yaffs_handle_chunk_wr_ok(dev, chunk, data, tags);
} while (write_ok != YAFFS_OK &&
yaffs_handle_chunk_wr_ok(dev, chunk, data, tags);
} while (write_ok != YAFFS_OK &&
- (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
+ (yaffs_wr_attempts == 0 || attempts <= yaffs_wr_attempts));
if (!write_ok)
chunk = -1;
if (!write_ok)
chunk = -1;
static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id,
int chunk_obj)
{
static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id,
int chunk_obj)
{
- return (tags->chunk_id == chunk_obj &&
- tags->obj_id == obj_id &&
+ return (tags->chunk_id == (u32)chunk_obj &&
+ tags->obj_id == (u32)obj_id &&
!tags->is_deleted) ? 1 : 0;
}
!tags->is_deleted) ? 1 : 0;
}
*/
static struct yaffs_cache *yaffs_grab_chunk_worker(struct yaffs_dev *dev)
{
*/
static struct yaffs_cache *yaffs_grab_chunk_worker(struct yaffs_dev *dev)
{
if (dev->param.n_caches > 0) {
for (i = 0; i < dev->param.n_caches; i++) {
if (dev->param.n_caches > 0) {
for (i = 0; i < dev->param.n_caches; i++) {
{
struct yaffs_cache *cache;
int usage;
{
struct yaffs_cache *cache;
int usage;
if (dev->param.n_caches < 1)
return NULL;
if (dev->param.n_caches < 1)
return NULL;
int chunk_id)
{
struct yaffs_dev *dev = obj->my_dev;
int chunk_id)
{
struct yaffs_dev *dev = obj->my_dev;
if (dev->param.n_caches < 1)
return NULL;
if (dev->param.n_caches < 1)
return NULL;
static void yaffs_use_cache(struct yaffs_dev *dev, struct yaffs_cache *cache,
int is_write)
{
static void yaffs_use_cache(struct yaffs_dev *dev, struct yaffs_cache *cache,
int is_write)
{
if (dev->param.n_caches < 1)
return;
if (dev->param.n_caches < 1)
return;
*/
static void yaffs_invalidate_whole_cache(struct yaffs_obj *in)
{
*/
static void yaffs_invalidate_whole_cache(struct yaffs_obj *in)
{
struct yaffs_dev *dev = in->my_dev;
if (dev->param.n_caches > 0) {
struct yaffs_dev *dev = in->my_dev;
if (dev->param.n_caches > 0) {
{
struct yaffs_block_info *bi = yaffs_get_block_info(dev, block_no);
int erased_ok = 0;
{
struct yaffs_block_info *bi = yaffs_get_block_info(dev, block_no);
int erased_ok = 0;
/* If the block is still healthy erase it and mark as clean.
* If the block has had a data failure, then retire it.
/* If the block is still healthy erase it and mark as clean.
* If the block has had a data failure, then retire it.
bi->block_state = YAFFS_BLOCK_STATE_DIRTY;
/* If this is the block being garbage collected then stop gc'ing */
bi->block_state = YAFFS_BLOCK_STATE_DIRTY;
/* If this is the block being garbage collected then stop gc'ing */
- if (block_no == dev->gc_block)
+ if (block_no == (int)dev->gc_block)
dev->gc_block = 0;
/* If this block is currently the best candidate for gc
* then drop as a candidate */
dev->gc_block = 0;
/* If this block is currently the best candidate for gc
* then drop as a candidate */
- if (block_no == dev->gc_dirtiest) {
+ if (block_no == (int)dev->gc_dirtiest) {
dev->gc_dirtiest = 0;
dev->gc_pages_in_use = 0;
}
dev->gc_dirtiest = 0;
dev->gc_pages_in_use = 0;
}
{
int old_chunk;
int ret_val = YAFFS_OK;
{
int old_chunk;
int ret_val = YAFFS_OK;
int is_checkpt_block;
int max_copies;
int chunks_before = yaffs_get_erased_chunks(dev);
int is_checkpt_block;
int max_copies;
int chunks_before = yaffs_get_erased_chunks(dev);
static unsigned yaffs_find_gc_block(struct yaffs_dev *dev,
int aggressive, int background)
{
static unsigned yaffs_find_gc_block(struct yaffs_dev *dev,
int aggressive, int background)
{
- int i;
- int iterations;
- unsigned selected = 0;
+ u32 i;
+ u32 iterations;
+ u32 selected = 0;
int prioritised = 0;
int prioritised_exist = 0;
struct yaffs_block_info *bi;
int prioritised = 0;
int prioritised_exist = 0;
struct yaffs_block_info *bi;
/* First let's see if we need to grab a prioritised block */
if (dev->has_pending_prioritised_gc && !aggressive) {
/* First let's see if we need to grab a prioritised block */
if (dev->has_pending_prioritised_gc && !aggressive) {
int n_blocks =
dev->internal_end_block - dev->internal_start_block + 1;
if (aggressive) {
threshold = dev->param.chunks_per_block;
iterations = n_blocks;
} else {
int n_blocks =
dev->internal_end_block - dev->internal_start_block + 1;
if (aggressive) {
threshold = dev->param.chunks_per_block;
iterations = n_blocks;
} else {
if (background)
max_threshold = dev->param.chunks_per_block / 2;
if (background)
max_threshold = dev->param.chunks_per_block / 2;
gc_ok = yaffs_gc_block(dev, dev->gc_block, aggressive);
}
gc_ok = yaffs_gc_block(dev, dev->gc_block, aggressive);
}
- if (dev->n_erased_blocks < (dev->param.n_reserved_blocks) &&
+ if (dev->n_erased_blocks < (int)dev->param.n_reserved_blocks &&
dev->gc_block > 0) {
yaffs_trace(YAFFS_TRACE_GC,
"yaffs: GC !!!no reclaim!!! n_erased_blocks %d after try %d block %d",
dev->n_erased_blocks, max_tries,
dev->gc_block);
}
dev->gc_block > 0) {
yaffs_trace(YAFFS_TRACE_GC,
"yaffs: GC !!!no reclaim!!! n_erased_blocks %d after try %d block %d",
dev->n_erased_blocks, max_tries,
dev->gc_block);
}
- } while ((dev->n_erased_blocks < dev->param.n_reserved_blocks) &&
+ } while ((dev->n_erased_blocks < (int)dev->param.n_reserved_blocks) &&
(dev->gc_block > 0) && (max_tries < 2));
return aggressive ? gc_ok : YAFFS_OK;
(dev->gc_block > 0) && (max_tries < 2));
return aggressive ? gc_ok : YAFFS_OK;
(prev_chunk_id > 0) ? prev_tags.serial_number + 1 : 1;
new_tags.n_bytes = n_bytes;
(prev_chunk_id > 0) ? prev_tags.serial_number + 1 : 1;
new_tags.n_bytes = n_bytes;
- if (n_bytes < 1 || n_bytes > dev->data_bytes_per_chunk) {
+ if (n_bytes < 1 || n_bytes > (int)dev->data_bytes_per_chunk) {
yaffs_trace(YAFFS_TRACE_ERROR,
"Writing %d bytes to chunk!!!!!!!!!",
n_bytes);
yaffs_trace(YAFFS_TRACE_ERROR,
"Writing %d bytes to chunk!!!!!!!!!",
n_bytes);
struct yaffs_dev *dev;
struct yaffs_ext_tags tags;
int result;
struct yaffs_dev *dev;
struct yaffs_ext_tags tags;
int result;
if (!in || !in->lazy_loaded || in->hdr_chunk < 1)
return;
dev = in->my_dev;
if (!in || !in->lazy_loaded || in->hdr_chunk < 1)
return;
dev = in->my_dev;
buf = yaffs_get_temp_buffer(dev);
result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
buf = yaffs_get_temp_buffer(dev);
result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
+
+ if (result == YAFFS_FAIL)
+ return;
+
oh = (struct yaffs_obj_hdr *)buf;
yaffs_do_endian_oh(dev, oh);
oh = (struct yaffs_obj_hdr *)buf;
yaffs_do_endian_oh(dev, oh);
in->yst_mode = oh->yst_mode;
yaffs_load_attribs(in, oh);
yaffs_set_obj_name_from_oh(in, oh);
in->yst_mode = oh->yst_mode;
yaffs_load_attribs(in, oh);
yaffs_set_obj_name_from_oh(in, oh);
- if (in->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
+ if (in->variant_type == YAFFS_OBJECT_TYPE_SYMLINK)
in->variant.symlink_variant.alias =
yaffs_clone_str(oh->alias);
in->variant.symlink_variant.alias =
yaffs_clone_str(oh->alias);
- if (!in->variant.symlink_variant.alias)
- alloc_failed = 1; /* Not returned */
- }
yaffs_release_temp_buffer(dev, buf);
}
yaffs_release_temp_buffer(dev, buf);
}
/* Access the old obj header just to read the name. */
result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id,
buffer, &old_tags);
/* Access the old obj header just to read the name. */
result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id,
buffer, &old_tags);
-
- yaffs_verify_oh(in, oh, &old_tags, 0);
- memcpy(old_name, oh->name, sizeof(oh->name));
-
- /*
- * NB We only wipe the object header area because the rest of
- * the buffer might contain xattribs.
- */
- memset(oh, 0xff, sizeof(*oh));
+ if (result == YAFFS_OK) {
+ yaffs_verify_oh(in, oh, &old_tags, 0);
+ memcpy(old_name, oh->name, sizeof(oh->name));
+
+ /*
+ * NB We only wipe the object header area because the rest of
+ * the buffer might contain xattribs.
+ */
+ memset(oh, 0xff, sizeof(*oh));
+ }
} else {
memset(buffer, 0xff, dev->data_bytes_per_chunk);
}
} else {
memset(buffer, 0xff, dev->data_bytes_per_chunk);
}
* a whole chunk or we're using inband tags then use the cache
* (if there is caching) else bypass the cache.
*/
* a whole chunk or we're using inband tags then use the cache
* (if there is caching) else bypass the cache.
*/
- if (cache || n_copy != dev->data_bytes_per_chunk ||
+ if (cache || n_copy != (int)dev->data_bytes_per_chunk ||
dev->param.inband_tags) {
if (dev->param.n_caches > 0) {
dev->param.inband_tags) {
if (dev->param.n_caches > 0) {
start >= dev->data_bytes_per_chunk) {
yaffs_trace(YAFFS_TRACE_ERROR,
"AddrToChunk of offset %lld gives chunk %d start %d",
start >= dev->data_bytes_per_chunk) {
yaffs_trace(YAFFS_TRACE_ERROR,
"AddrToChunk of offset %lld gives chunk %d start %d",
+ (long long)offset, chunk, start);
}
chunk++; /* File pos to chunk in file offset */
}
chunk++; /* File pos to chunk in file offset */
(start + n)) ? n_bytes_read : (start + n);
if (n_writeback < 0 ||
(start + n)) ? n_bytes_read : (start + n);
if (n_writeback < 0 ||
- n_writeback > dev->data_bytes_per_chunk)
+ n_writeback > (int)dev->data_bytes_per_chunk)
n_writeback = dev->data_bytes_per_chunk;
}
n_writeback = dev->data_bytes_per_chunk;
}
- if (n_copy != dev->data_bytes_per_chunk ||
+ if (n_copy != (int)dev->data_bytes_per_chunk ||
!dev->param.cache_bypass_aligned ||
dev->param.inband_tags) {
/* An incomplete start or end chunk (or maybe both
!dev->param.cache_bypass_aligned ||
dev->param.inband_tags) {
/* An incomplete start or end chunk (or maybe both
if (chunk_id < 1)
continue;
if (chunk_id < 1)
continue;
(dev->internal_start_block * dev->param.chunks_per_block) ||
(dev->internal_start_block * dev->param.chunks_per_block) ||
((dev->internal_end_block + 1) *
dev->param.chunks_per_block)) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
((dev->internal_end_block + 1) *
dev->param.chunks_per_block)) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
obj->hdr_chunk,
buffer, NULL);
}
obj->hdr_chunk,
buffer, NULL);
}
- yaffs_load_name_from_oh(obj->my_dev, name, oh->name,
+ if (result == YAFFS_OK)
+ yaffs_load_name_from_oh(obj->my_dev, name, oh->name,
buffer_size);
yaffs_release_temp_buffer(obj->my_dev, buffer);
buffer_size);
yaffs_release_temp_buffer(obj->my_dev, buffer);
int yaffs_guts_format_dev(struct yaffs_dev *dev)
{
int yaffs_guts_format_dev(struct yaffs_dev *dev)
{
enum yaffs_block_state state;
u32 dummy;
enum yaffs_block_state state;
u32 dummy;
int yaffs_guts_initialise(struct yaffs_dev *dev)
{
int init_failed = 0;
int yaffs_guts_initialise(struct yaffs_dev *dev)
{
int init_failed = 0;
- unsigned x;
- int bits;
if(yaffs_guts_ll_init(dev) != YAFFS_OK)
return YAFFS_FAIL;
if(yaffs_guts_ll_init(dev) != YAFFS_OK)
return YAFFS_FAIL;
dev->gc_cleanup_list = NULL;
if (!init_failed && dev->param.n_caches > 0) {
dev->gc_cleanup_list = NULL;
if (!init_failed && dev->param.n_caches > 0) {
dev->param.n_caches * sizeof(struct yaffs_cache);
if (dev->param.n_caches > YAFFS_MAX_SHORT_OP_CACHES)
dev->param.n_caches * sizeof(struct yaffs_cache);
if (dev->param.n_caches > YAFFS_MAX_SHORT_OP_CACHES)
void yaffs_deinitialise(struct yaffs_dev *dev)
{
if (dev->is_mounted) {
void yaffs_deinitialise(struct yaffs_dev *dev)
{
if (dev->is_mounted) {
yaffs_deinit_blocks(dev);
yaffs_deinit_tnodes_and_objs(dev);
yaffs_deinit_blocks(dev);
yaffs_deinit_tnodes_and_objs(dev);
int yaffs_count_free_chunks(struct yaffs_dev *dev)
{
int n_free = 0;
int yaffs_count_free_chunks(struct yaffs_dev *dev)
{
int n_free = 0;
struct yaffs_block_info *blk;
blk = dev->block_info;
struct yaffs_block_info *blk;
blk = dev->block_info;
int n_free;
int n_dirty_caches;
int blocks_for_checkpt;
int n_free;
int n_dirty_caches;
int blocks_for_checkpt;
n_free = dev->n_free_chunks;
n_free += dev->n_deleted_files;
n_free = dev->n_free_chunks;
n_free += dev->n_deleted_files;
void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10])
{
void yaffs_count_blocks_by_state(struct yaffs_dev *dev, int bs[10])
{
struct yaffs_block_info *bi;
int s;
struct yaffs_block_info *bi;
int s;
u32 type; /* enum yaffs_obj_type */
/* Apply to everything */
u32 type; /* enum yaffs_obj_type */
/* Apply to everything */
u16 sum_no_longer_used; /* checksum of name. No longer used */
YCHAR name[YAFFS_MAX_NAME_LENGTH + 1];
u16 sum_no_longer_used; /* checksum of name. No longer used */
YCHAR name[YAFFS_MAX_NAME_LENGTH + 1];
int inband_tags; /* Use unband tags */
u32 total_bytes_per_chunk; /* Should be >= 512, does not need to
be a power of 2 */
int inband_tags; /* Use unband tags */
u32 total_bytes_per_chunk; /* Should be >= 512, does not need to
be a power of 2 */
- int chunks_per_block; /* does not need to be a power of 2 */
- int spare_bytes_per_chunk; /* spare area size */
- int start_block; /* Start block we're allowed to use */
- int end_block; /* End block we're allowed to use */
- int n_reserved_blocks; /* Tuneable so that we can reduce
+ u32 chunks_per_block; /* does not need to be a power of 2 */
+ u32 spare_bytes_per_chunk; /* spare area size */
+ u32 start_block; /* Start block we're allowed to use */
+ u32 end_block; /* End block we're allowed to use */
+ u32 n_reserved_blocks; /* Tuneable so that we can reduce
* reserved blocks on NOR and RAM. */
* reserved blocks on NOR and RAM. */
- int n_caches; /* If <= 0, then short op caching is disabled,
+ u32 n_caches; /* If == 0, then short op caching is disabled,
* else the number of short op caches.
*/
int cache_bypass_aligned; /* If non-zero then bypass the cache for
* else the number of short op caches.
*/
int cache_bypass_aligned; /* If non-zero then bypass the cache for
int ll_init;
/* Runtime parameters. Set up by YAFFS. */
int ll_init;
/* Runtime parameters. Set up by YAFFS. */
- int data_bytes_per_chunk;
+ u32 data_bytes_per_chunk;
/* Non-wide tnode stuff */
u16 chunk_grp_bits; /* Number of bits that need to be resolved if
/* Non-wide tnode stuff */
u16 chunk_grp_bits; /* Number of bits that need to be resolved if
int swap_endian; /* Stored endian needs endian swap. */
/* Stuff to support block offsetting to support start block zero */
int swap_endian; /* Stored endian needs endian swap. */
/* Stuff to support block offsetting to support start block zero */
- int internal_start_block;
- int internal_end_block;
+ u32 internal_start_block;
+ u32 internal_end_block;
int block_offset;
int chunk_offset;
int block_offset;
int chunk_offset;
int checkpt_byte_offs;
u8 *checkpt_buffer;
int checkpt_open_write;
int checkpt_byte_offs;
u8 *checkpt_buffer;
int checkpt_open_write;
int checkpt_cur_chunk;
int checkpt_cur_block;
int checkpt_next_block;
int *checkpt_block_list;
int checkpt_cur_chunk;
int checkpt_cur_block;
int checkpt_next_block;
int *checkpt_block_list;
- int checkpt_max_blocks;
+ u32 checkpt_max_blocks;
u32 checkpt_sum;
u32 checkpt_xor;
u32 checkpt_sum;
u32 checkpt_xor;
int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR * old_name,
struct yaffs_obj *new_dir, const YCHAR * new_name);
int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR * old_name,
struct yaffs_obj *new_dir, const YCHAR * new_name);
+int yaffs_unlink_obj(struct yaffs_obj *obj);
+
int yaffs_unlinker(struct yaffs_obj *dir, const YCHAR * name);
int yaffs_del_obj(struct yaffs_obj *obj);
struct yaffs_obj *yaffs_retype_obj(struct yaffs_obj *obj,
int yaffs_unlinker(struct yaffs_obj *dir, const YCHAR * name);
int yaffs_del_obj(struct yaffs_obj *obj);
struct yaffs_obj *yaffs_retype_obj(struct yaffs_obj *obj,
#include "yaffs_nameval.h"
#include "yaffs_guts.h"
#include "yportenv.h"
#include "yaffs_nameval.h"
#include "yaffs_guts.h"
#include "yportenv.h"
+#include "yaffs_endian.h"
static int nval_find(struct yaffs_dev *dev,
const char *xb, int xb_size, const YCHAR *name,
static int nval_find(struct yaffs_dev *dev,
const char *xb, int xb_size, const YCHAR *name,
return pos;
}
pos += size;
return pos;
}
pos += size;
- if (pos < xb_size - sizeof(size)) {
+ if (pos < (int)(xb_size - sizeof(size))) {
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
while (size > 0 && (size < xb_size) && (pos + size < xb_size)) {
pos += size;
while (size > 0 && (size < xb_size) && (pos + size < xb_size)) {
pos += size;
- if (pos < xb_size - sizeof(size)) {
+ if (pos < (int)(xb_size - sizeof(size))) {
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
} else
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
} else
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
- while (size > sizeof(size) &&
+ while (size > (int)(sizeof(size)) &&
size <= xb_size &&
(pos + size) < xb_size &&
!filled) {
size <= xb_size &&
(pos + size) < xb_size &&
!filled) {
filled = 1;
}
pos += size;
filled = 1;
}
pos += size;
- if (pos < xb_size - sizeof(size)) {
+ if (pos < (int)(xb_size - sizeof(size))) {
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
}
memcpy(&size, xb + pos, sizeof(size));
yaffs_do_endian_s32(dev, &size);
}
u8 *buffer;
u8 *sum_buffer = (u8 *)st;
int n_bytes;
u8 *buffer;
u8 *sum_buffer = (u8 *)st;
int n_bytes;
int chunk_in_nand;
int chunk_in_block;
int result;
int chunk_in_nand;
int chunk_in_block;
int result;
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;
void yaffs_summary_gc(struct yaffs_dev *dev, int blk)
{
struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
void yaffs_summary_gc(struct yaffs_dev *dev, int blk)
{
struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
if (!bi->has_summary)
return;
if (!bi->has_summary)
return;
+ if (retval == YAFFS_FAIL)
+ return YAFFS_FAIL;
+
if (dev->param.inband_tags) {
if (tags) {
struct yaffs_packed_tags2_tags_only *pt2tp;
if (dev->param.inband_tags) {
if (tags) {
struct yaffs_packed_tags2_tags_only *pt2tp;
- 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++;
actually_used = bi->pages_in_use - bi->soft_del_pages;
if (bi->pages_in_use < 0 ||
actually_used = bi->pages_in_use - bi->soft_del_pages;
if (bi->pages_in_use < 0 ||
- bi->pages_in_use > dev->param.chunks_per_block ||
+ bi->pages_in_use > (int)dev->param.chunks_per_block ||
bi->soft_del_pages < 0 ||
bi->soft_del_pages < 0 ||
- bi->soft_del_pages > dev->param.chunks_per_block ||
- actually_used < 0 || actually_used > dev->param.chunks_per_block)
+ bi->soft_del_pages > (int)dev->param.chunks_per_block ||
+ actually_used < 0 || actually_used > (int)dev->param.chunks_per_block)
yaffs_trace(YAFFS_TRACE_VERIFY,
"Block %d has illegal values pages_in_used %d soft_del_pages %d",
n, bi->pages_in_use, bi->soft_del_pages);
yaffs_trace(YAFFS_TRACE_VERIFY,
"Block %d has illegal values pages_in_used %d soft_del_pages %d",
n, bi->pages_in_use, bi->soft_del_pages);
void yaffs_verify_blocks(struct yaffs_dev *dev)
{
void yaffs_verify_blocks(struct yaffs_dev *dev)
{
- int i;
- int state_count[YAFFS_NUMBER_OF_BLOCK_STATES];
+ u32 i;
+ u32 state_count[YAFFS_NUMBER_OF_BLOCK_STATES];
int illegal_states = 0;
if (yaffs_skip_verification(dev))
int illegal_states = 0;
if (yaffs_skip_verification(dev))
dev->blocks_in_checkpt,
state_count[YAFFS_BLOCK_STATE_CHECKPOINT]);
dev->blocks_in_checkpt,
state_count[YAFFS_BLOCK_STATE_CHECKPOINT]);
- if (dev->n_erased_blocks != state_count[YAFFS_BLOCK_STATE_EMPTY])
+ if (dev->n_erased_blocks != (int)state_count[YAFFS_BLOCK_STATE_EMPTY])
yaffs_trace(YAFFS_TRACE_VERIFY,
"Erased block count wrong dev %d count %d",
dev->n_erased_blocks,
yaffs_trace(YAFFS_TRACE_VERIFY,
"Erased block count wrong dev %d count %d",
dev->n_erased_blocks,
tags->obj_id, oh->parent_obj_id);
if (parent_check && obj->parent &&
tags->obj_id, oh->parent_obj_id);
if (parent_check && obj->parent &&
- oh->parent_obj_id != obj->parent->obj_id &&
+ oh->parent_obj_id != obj->parent->obj_id &&
(oh->parent_obj_id != YAFFS_OBJECTID_UNLINKED ||
obj->parent->obj_id != YAFFS_OBJECTID_DELETED))
yaffs_trace(YAFFS_TRACE_VERIFY,
(oh->parent_obj_id != YAFFS_OBJECTID_UNLINKED ||
obj->parent->obj_id != YAFFS_OBJECTID_DELETED))
yaffs_trace(YAFFS_TRACE_VERIFY,
{
u32 x;
int required_depth;
{
u32 x;
int required_depth;
int last_chunk;
u32 offset_in_chunk;
u32 the_chunk;
int last_chunk;
u32 offset_in_chunk;
u32 the_chunk;
struct yaffs_dev *dev;
struct yaffs_ext_tags tags;
struct yaffs_tnode *tn;
struct yaffs_dev *dev;
struct yaffs_ext_tags tags;
struct yaffs_tnode *tn;
- actual_depth = obj->variant.file_variant.top_level;
-
/* Check that the chunks in the tnode tree are all correct.
* We do this by scanning through the tnode tree and
* checking the tags for every chunk match.
/* Check that the chunks in the tnode tree are all correct.
* We do this by scanning through the tnode tree and
* checking the tags for every chunk match.
if (the_chunk > 0) {
yaffs_rd_chunk_tags_nand(dev, the_chunk, NULL,
&tags);
if (the_chunk > 0) {
yaffs_rd_chunk_tags_nand(dev, the_chunk, NULL,
&tags);
- if (tags.obj_id != obj_id || tags.chunk_id != i)
+ if (tags.obj_id != obj_id || tags.chunk_id != (u32)i)
yaffs_trace(YAFFS_TRACE_VERIFY,
"Object %d chunk_id %d NAND mismatch chunk %d tags (%d:%d)",
obj_id, i, the_chunk,
yaffs_trace(YAFFS_TRACE_VERIFY,
"Object %d chunk_id %d NAND mismatch chunk %d tags (%d:%d)",
obj_id, i, the_chunk,
int yaffs1_scan(struct yaffs_dev *dev)
{
struct yaffs_ext_tags tags;
int yaffs1_scan(struct yaffs_dev *dev)
{
struct yaffs_ext_tags tags;
int deleted;
enum yaffs_block_state state;
LIST_HEAD(hard_list);
int deleted;
enum yaffs_block_state state;
LIST_HEAD(hard_list);
result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
&tags);
result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
&tags);
+ if (result != YAFFS_OK)
+ continue;
/* Let's have a good look at this chunk... */
if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED ||
/* Let's have a good look at this chunk... */
if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED ||
*/
void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev)
{
*/
void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev)
{
unsigned seq;
unsigned block_no = 0;
struct yaffs_block_info *b;
unsigned seq;
unsigned block_no = 0;
struct yaffs_block_info *b;
b = dev->block_info;
for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
if (b->block_state == YAFFS_BLOCK_STATE_FULL &&
b = dev->block_info;
for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
if (b->block_state == YAFFS_BLOCK_STATE_FULL &&
- (b->pages_in_use - b->soft_del_pages) <
+ (u32)(b->pages_in_use - b->soft_del_pages) <
dev->param.chunks_per_block &&
b->seq_number < seq) {
seq = b->seq_number;
dev->param.chunks_per_block &&
b->seq_number < seq) {
seq = b->seq_number;
u32 n_bytes;
u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1;
int ok;
u32 n_bytes;
u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1;
int ok;
union yaffs_block_info_union bu;
/* Write device runtime values */
union yaffs_block_info_union bu;
/* Write device runtime values */
/* Write block info. */
if (!dev->swap_endian) {
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
/* Write block info. */
if (!dev->swap_endian) {
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
- ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) ==
+ (int)n_bytes);
} else {
/*
* Need to swap the endianisms. We can't do this in place
} else {
/*
* Need to swap the endianisms. We can't do this in place
* no endian conversion is needed.
*/
n_bytes = n_blocks * dev->chunk_bit_stride;
* no endian conversion is needed.
*/
n_bytes = n_blocks * dev->chunk_bit_stride;
- ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) ==
+ (int)n_bytes);
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
- ok = (yaffs2_checkpt_rd(dev, dev->block_info, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_rd(dev, dev->block_info, n_bytes) ==
+ (int)n_bytes);
n_bytes = n_blocks * dev->chunk_bit_stride;
n_bytes = n_blocks * dev->chunk_bit_stride;
- ok = (yaffs2_checkpt_rd(dev, dev->chunk_bits, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_rd(dev, dev->chunk_bits, n_bytes) ==
+ (int)n_bytes);
*/
tn = yaffs2_do_endian_tnode_copy(dev, tn);
ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) ==
*/
tn = yaffs2_do_endian_tnode_copy(dev, tn);
ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) ==
tn = yaffs_get_tnode(dev);
if (tn) {
ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) ==
tn = yaffs_get_tnode(dev);
if (tn) {
ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) ==
yaffs2_do_endian_tnode(dev, tn);
}
else
yaffs2_do_endian_tnode(dev, tn);
}
else
cp.obj_id, cp.parent_id, cp_variant_type,
cp.hdr_chunk);
cp.obj_id, cp.parent_id, cp_variant_type,
cp.hdr_chunk);
- if (ok && cp.obj_id == ~0) {
+ if (ok && cp.obj_id == (u32)(~0)) {
done = 1;
} else if (ok) {
obj =
done = 1;
} else if (ok) {
obj =
while (increase > 0 && small_increase_ok) {
this_write = increase;
while (increase > 0 && small_increase_ok) {
this_write = increase;
- if (this_write > dev->data_bytes_per_chunk)
+ if (this_write > (int)dev->data_bytes_per_chunk)
this_write = dev->data_bytes_per_chunk;
written =
yaffs_do_file_wr(obj, local_buffer, pos, this_write,
this_write = dev->data_bytes_per_chunk;
written =
yaffs_do_file_wr(obj, local_buffer, pos, this_write,
+ if (result == YAFFS_FAIL)
+ yaffs_trace(YAFFS_TRACE_SCAN,
+ "Could not get tags for chunk %d\n", chunk);
/* Let's have a good look at this chunk... */
if (!tags.chunk_used) {
/* Let's have a good look at this chunk... */
if (!tags.chunk_used) {
yaffs_oh_to_size(dev, oh, 0) :
tags.extra_file_size;
u32 parent_obj_id = (oh) ?
yaffs_oh_to_size(dev, oh, 0) :
tags.extra_file_size;
u32 parent_obj_id = (oh) ?
+ (u32)oh->parent_obj_id :
tags.extra_parent_id;
is_shrink = (oh) ?
tags.extra_parent_id;
is_shrink = (oh) ?
int yaffs2_scan_backwards(struct yaffs_dev *dev)
{
int yaffs2_scan_backwards(struct yaffs_dev *dev)
{
int block_iter;
int start_iter;
int end_iter;
int block_iter;
int start_iter;
int end_iter;