Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
authorCharles Manning <cdhmanning@gmail.com>
Mon, 8 Nov 2010 23:06:41 +0000 (12:06 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 8 Nov 2010 23:06:41 +0000 (12:06 +1300)
67 files changed:
direct/fsx_test/Makefile [deleted file]
direct/fsx_test/README [deleted file]
direct/fsx_test/yaffs_fsx.c [deleted file]
direct/timothy_tests/found_bugs.txt [deleted file]
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/current_bugs.txt [new file with mode: 0644]
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate.c
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_lseek.c
direct/timothy_tests/quick_tests/test_yaffs_mount.c [moved from direct/timothy_tests/quick_tests/test_mount_yaffs.c with 85% similarity]
direct/timothy_tests/quick_tests/test_yaffs_mount.h [moved from direct/timothy_tests/quick_tests/test_mount_yaffs.h with 82% similarity]
direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open.c
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_EISDIR.c
direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink.c [moved from direct/timothy_tests/quick_tests/test_yaffs_unlinking.c with 86% similarity]
direct/timothy_tests/quick_tests/test_yaffs_unlink.h [moved from direct/timothy_tests/quick_tests/test_yaffs_unlinking.h with 81% similarity]
direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unmount.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_unmount.h [new file with mode: 0644]
direct/yaffsfs.c
direct/yaffsfs.h
yaffs_trace.h

diff --git a/direct/fsx_test/Makefile b/direct/fsx_test/Makefile
deleted file mode 100644 (file)
index 93d2bac..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-# Makefile for YAFFS direct test
-#
-#
-# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
-#
-# Copyright (C) 2003 Aleph One Ltd.
-#
-#
-# Created by Charles Manning <charles@aleph1.co.uk>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# NB Warning this Makefile does not include header dependencies.
-#
-# $Id: Makefile,v 1.4 2008-11-07 00:32:22 charles Exp $
-
-#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
-
-CFLAGS =    -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE
-CFLAGS+=    -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
-CFLAGS+=    -Wall -g $(EXTRA_COMPILE_FLAGS)
-CFLAGS+=    -fstack-check -O0
-
-#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
-#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
-
-
-FSXTESTOBJS = yaffs_fsx.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffs_fileem.o yaffsfs.o yaffs_guts.o \
-                yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
-                yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
-                yaffs_checkptrw.o  yaffs_qsort.o \
-                yaffs_norif1.o ynorsim.o
-#               yaffs_checkptrwtest.o\
-                
-
-#BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o
-
-#ALLOBJS =  dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o yaffs_ramem2k.o
-
-ALLOBJS = $(FSXTESTOBJS) $(BOOTTESTOBJS)
-
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
-          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
-          yaffs_nand.c yaffs_nand.h \
-          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
-          yaffs_qsort.c yaffs_qsort.h yaffs_getblockinfo.h
-
-YAFFSDIRECTSYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
-                      yaffs_fileem2k.h yaffsfs.h yaffs_malloc.h yaffs_ramdisk.h ydirectenv.h \
-                      yaffscfg.h yaffs_fileem.c yaffs_flashif.c yaffs_ramdisk.c yaffs_ramem2k.c\
-                      yaffs_norif1.c yaffs_norif1.h ynorsim.c ynorsim.h
-
-
-
-#all: fsxtest boottest
-
-all: fsxtest
-
-$(ALLOBJS): %.o: %.c
-       gcc -c $(CFLAGS) $< -o $@
-
-$(YAFFSSYMLINKS):
-       ln -s ../../$@ $@
-
-$(YAFFSDIRECTSYMLINKS):
-       ln -s ../$@ $@
-
-fsxtest: $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(FSXTESTOBJS)
-       gcc -o $@ $(FSXTESTOBJS)
-
-
-boottest: $(SYMLINKS) $(BOOTTESTOBJS)
-       gcc -o $@ $(BOOTTESTOBJS)
-
-
-clean:
-       rm -f $(ALLOBJS) core
diff --git a/direct/fsx_test/README b/direct/fsx_test/README
deleted file mode 100644 (file)
index 725ab07..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-NB THis directory uses a hacked version of fsx.c which is released under
-Apple Public Source License.
-
-From what I have been able to determine, it is legally OK to release a hacked
-version for the purposes of testing.
-
-If anyone knows otherwise, please contact me: manningc2@actrix.gen.nz
diff --git a/direct/fsx_test/yaffs_fsx.c b/direct/fsx_test/yaffs_fsx.c
deleted file mode 100644 (file)
index d3d3149..0000000
+++ /dev/null
@@ -1,1013 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.2 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- *
- *     WARNING--WARNING--WARNING
- *     This is not the original fsx.c. It has been modified to run with
- *      yaffs direct. Seek out the original fsx.c if you want to do anything
- *     else.
- *
- *     
- *
- *     File:   fsx.c
- *     Author: Avadis Tevanian, Jr.
- *
- *     File system exerciser. 
- *
- *     Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
- *
- *     Various features from Joe Sokol, Pat Dirks, and Clark Warner.
- *
- *     Small changes to work under Linux -- davej@suse.de
- *
- *     Sundry porting patches from Guy Harris 12/2001
- *
- *     Checks for mmap last-page zero fill.
- *
- *     Modified heavily by Charles Manning to exercise via the
- *     yaffs direct interface.
- *
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef _UWIN
-# include <sys/param.h>
-# include <limits.h>
-# include <time.h>
-# include <strings.h>
-#endif
-#include <fcntl.h>
-#include <sys/mman.h>
-#ifndef MAP_FILE
-# define MAP_FILE 0
-#endif
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <time.h>
-
-#include "yaffsfs.h"
-
-#define NUMPRINTCOLUMNS 32     /* # columns of data to print on each line */
-
-/*
- *     A log entry is an operation and a bunch of arguments.
- */
-
-struct log_entry {
-       int     operation;
-       int     args[3];
-};
-
-#define        LOGSIZE 1000
-
-struct log_entry       oplog[LOGSIZE]; /* the log */
-int                    logptr = 0;     /* current position in log */
-int                    logcount = 0;   /* total ops */
-
-/*
- *     Define operations
- */
-
-#define        OP_READ         1
-#define OP_WRITE       2
-#define OP_TRUNCATE    3
-#define OP_CLOSEOPEN   4
-#define OP_MAPREAD     5
-#define OP_MAPWRITE    6
-#define OP_SKIPPED     7
-
-int page_size;
-int page_mask;
-
-char   *original_buf;                  /* a pointer to the original data */
-char   *good_buf;                      /* a pointer to the correct data */
-char   *temp_buf;                      /* a pointer to the current data */
-char   *fname;                         /* name of our test file */
-int    fd;                             /* fd for our test file */
-
-off_t          file_size = 0;
-off_t          biggest = 0;
-char           state[256];
-unsigned long  testcalls = 0;          /* calls to function "test" */
-
-unsigned long  simulatedopcount = 0;   /* -b flag */
-int    closeprob = 0;                  /* -c flag */
-int    debug = 0;                      /* -d flag */
-unsigned long  debugstart = 0;         /* -D flag */
-unsigned long  maxfilelen = 256 * 1024;        /* -l flag */
-int    sizechecks = 1;                 /* -n flag disables them */
-int    maxoplen = 64 * 1024;           /* -o flag */
-int    quiet = 0;                      /* -q flag */
-unsigned long progressinterval = 0;    /* -p flag */
-int    readbdy = 1;                    /* -r flag */
-int    style = 0;                      /* -s flag */
-int    truncbdy = 1;                   /* -t flag */
-int    writebdy = 1;                   /* -w flag */
-long   monitorstart = -1;              /* -m flag */
-long   monitorend = -1;                /* -m flag */
-int    lite = 0;                       /* -L flag */
-long   numops = /*-1 */ 10000000;                      /* -N flag */
-int    randomoplen = 1;                /* -O flag disables it */
-int    seed = 1;                       /* -S flag */
-
-int     mapped_writes = 0;           /* yaffs direct does not support mmapped files */
-int    mapped_reads = 0;
-
-int    fsxgoodfd = 0;
-FILE * fsxlogf = NULL;
-int badoff = -1;
-int closeopen = 0;
-
-
-void
-vwarnc(code, fmt, ap)
-       int code;
-       const char *fmt;
-       va_list ap;
-{
-       fprintf(stderr, "fsx: ");
-       if (fmt != NULL) {
-               vfprintf(stderr, fmt, ap);
-               fprintf(stderr, ": ");
-       }
-       fprintf(stderr, "%s\n", strerror(code));
-}
-
-
-void
-warn(const char * fmt, ...)
-{
-       va_list ap;
-       va_start(ap, fmt);
-       vwarnc(errno, fmt, ap);
-       va_end(ap);
-}
-
-
-void
-prt(char *fmt, ...)
-{
-       va_list args;
-
-       va_start(args, fmt);
-       vfprintf(stdout, fmt, args);
-       if (fsxlogf)
-               vfprintf(fsxlogf, fmt, args);
-       va_end(args);
-}
-
-void
-prterr(char *prefix)
-{
-       prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
-}
-
-
-void
-log4(int operation, int arg0, int arg1, int arg2)
-{
-       struct log_entry *le;
-
-       le = &oplog[logptr];
-       le->operation = operation;
-       if (closeopen)
-               le->operation = ~ le->operation;
-       le->args[0] = arg0;
-       le->args[1] = arg1;
-       le->args[2] = arg2;
-       logptr++;
-       logcount++;
-       if (logptr >= LOGSIZE)
-               logptr = 0;
-}
-
-
-void
-logdump(void)
-{
-       int     i, count, down;
-       struct log_entry        *lp;
-
-       prt("LOG DUMP (%d total operations):\n", logcount);
-       if (logcount < LOGSIZE) {
-               i = 0;
-               count = logcount;
-       } else {
-               i = logptr;
-               count = LOGSIZE;
-       }
-       for ( ; count > 0; count--) {
-               int opnum;
-
-               opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
-               prt("%d(%d mod 256): ", opnum, opnum%256);
-               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)",
-                           lp->args[0], lp->args[0] + lp->args[1] - 1,
-                           lp->args[1]);
-                       if (badoff >= lp->args[0] && badoff <
-                                                    lp->args[0] + lp->args[1])
-                               prt("\t***RRRR***");
-                       break;
-               case OP_MAPWRITE:
-                       prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
-                           lp->args[0], lp->args[0] + lp->args[1] - 1,
-                           lp->args[1]);
-                       if (badoff >= lp->args[0] && badoff <
-                                                    lp->args[0] + lp->args[1])
-                               prt("\t******WWWW");
-                       break;
-               case OP_READ:
-                       prt("READ\t0x%x thru 0x%x\t(0x%x bytes)",
-                           lp->args[0], lp->args[0] + lp->args[1] - 1,
-                           lp->args[1]);
-                       if (badoff >= lp->args[0] &&
-                           badoff < lp->args[0] + lp->args[1])
-                               prt("\t***RRRR***");
-                       break;
-               case OP_WRITE:
-                       prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)",
-                           lp->args[0], lp->args[0] + lp->args[1] - 1,
-                           lp->args[1]);
-                       if (lp->args[0] > lp->args[2])
-                               prt(" HOLE");
-                       else if (lp->args[0] + lp->args[1] > lp->args[2])
-                               prt(" EXTEND");
-                       if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
-                           badoff < lp->args[0] + lp->args[1])
-                               prt("\t***WWWW");
-                       break;
-               case OP_TRUNCATE:
-                       down = lp->args[0] < lp->args[1];
-                       prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
-                           down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
-                       if (badoff >= lp->args[!down] &&
-                           badoff < lp->args[!!down])
-                               prt("\t******WWWW");
-                       break;
-               case OP_SKIPPED:
-                       prt("SKIPPED (no operation)");
-                       break;
-               default:
-                       prt("BOGUS LOG ENTRY (operation code = %d)!",
-                           lp->operation);
-               }
-               if (closeopen)
-                       prt("\n\t\tCLOSE/OPEN");
-               prt("\n");
-               i++;
-               if (i == LOGSIZE)
-                       i = 0;
-       }
-}
-
-
-void
-save_buffer(char *buffer, off_t bufferlength, int fd)
-{
-       off_t ret;
-       ssize_t byteswritten;
-
-       if (fd <= 0 || bufferlength == 0)
-               return;
-
-       if (bufferlength > SSIZE_MAX) {
-               prt("fsx flaw: overflow in save_buffer\n");
-               exit(67);
-       }
-       if (lite) {
-               off_t size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
-               if (size_by_seek == (off_t)-1)
-                       prterr("save_buffer: lseek eof");
-               else if (bufferlength > size_by_seek) {
-                       warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
-                            (unsigned long long)bufferlength);
-                       bufferlength = size_by_seek;
-               }
-       }
-
-       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)
-                       prterr("save_buffer write");
-               else
-                       warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n",
-                            (unsigned)byteswritten,
-                            (unsigned long long)bufferlength);
-       }
-}
-
-
-void
-report_failure(int status)
-{
-       logdump();
-       
-       if (fsxgoodfd) {
-               if (good_buf) {
-                       save_buffer(good_buf, file_size, fsxgoodfd);
-                       prt("Correct content saved for comparison\n");
-                       prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
-                           fname, fname);
-               }
-               close(fsxgoodfd);
-       }
-       prt("Exiting with %d\n",status);
-       exit(status);
-}
-
-
-#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
-                                       *(((unsigned char *)(cp)) + 1)))
-
-void
-check_buffers(unsigned offset, unsigned size)
-{
-       unsigned char c, t;
-       unsigned i = 0;
-       unsigned n = 0;
-       unsigned op = 0;
-       unsigned bad = 0;
-
-       if (memcmp(good_buf + offset, temp_buf, size) != 0) {
-               prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n",
-                   offset, size);
-               prt("OFFSET\tGOOD\tBAD\tRANGE\n");
-               while (size > 0) {
-                       c = good_buf[offset];
-                       t = temp_buf[i];
-                       if (c != t) {
-                               if (n == 0) {
-                                       bad = short_at(&temp_buf[i]);
-                                       prt("0x%5x\t0x%04x\t0x%04x", offset,
-                                           short_at(&good_buf[offset]), bad);
-                                       op = temp_buf[offset & 1 ? i+1 : i];
-                               }
-                               n++;
-                               badoff = offset;
-                       }
-                       offset++;
-                       i++;
-                       size--;
-               }
-               if (n) {
-                       prt("\t0x%5x\n", n);
-                       if (bad)
-                               prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff));
-                       else
-                               prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n");
-               } else
-                       prt("????????????????\n");
-               report_failure(110);
-       }
-}
-
-
-void
-check_size(void)
-{
-       struct yaffs_stat       statbuf;
-       off_t   size_by_seek;
-
-       if (yaffs_fstat(fd, &statbuf)) {
-               prterr("check_size: fstat");
-               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) {
-               prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
-                   (unsigned long long)file_size,
-                   (unsigned long long)statbuf.st_size,
-                   (unsigned long long)size_by_seek);
-               report_failure(120);
-       }
-}
-
-
-void
-check_trunc_hack(void)
-{
-       struct yaffs_stat statbuf;
-
-       yaffs_ftruncate(fd, (off_t)0);
-       yaffs_ftruncate(fd, (off_t)100000);
-       yaffs_fstat(fd, &statbuf);
-       if (statbuf.st_size != (off_t)100000) {
-               prt("no extend on truncate! not posix!\n");
-               exit(130);
-       }
-       yaffs_ftruncate(fd, (off_t)0);
-}
-
-
-void
-doread(unsigned offset, unsigned size)
-{
-       off_t ret;
-       unsigned iret;
-
-       offset -= offset % readbdy;
-       if (size == 0) {
-               if (!quiet && testcalls > simulatedopcount)
-                       prt("skipping zero size read\n");
-               log4(OP_SKIPPED, OP_READ, offset, size);
-               return;
-       }
-       if (size + offset > file_size) {
-               if (!quiet && testcalls > simulatedopcount)
-                       prt("skipping seek/read past end of file\n");
-               log4(OP_SKIPPED, OP_READ, offset, size);
-               return;
-       }
-
-       log4(OP_READ, offset, size, 0);
-
-       if (testcalls <= simulatedopcount)
-               return;
-
-       if (!quiet && ((progressinterval &&
-                       testcalls % progressinterval == 0) ||
-                      (debug &&
-                       (monitorstart == -1 ||
-                        (offset + size > monitorstart &&
-                         (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
-                   offset, offset + size - 1, size);
-       ret = yaffs_lseek(fd, (off_t)offset, SEEK_SET);
-       if (ret == (off_t)-1) {
-               prterr("doread: lseek");
-               report_failure(140);
-       }
-       iret = yaffs_read(fd, temp_buf, size);
-       if (iret != size) {
-               if (iret == -1)
-                       prterr("doread: read");
-               else
-                       prt("short read: 0x%x bytes instead of 0x%x\n",
-                           iret, size);
-               report_failure(141);
-       }
-       check_buffers(offset, size);
-}
-
-
-
-
-
-void
-gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
-{
-       while (size--) {
-               good_buf[offset] = testcalls % 256; 
-               if (offset % 2)
-                       good_buf[offset] += original_buf[offset];
-               offset++;
-       }
-}
-
-
-void
-dowrite(unsigned offset, unsigned size)
-{
-       off_t ret;
-       unsigned iret;
-
-       offset -= offset % writebdy;
-       if (size == 0) {
-               if (!quiet && testcalls > simulatedopcount)
-                       prt("skipping zero size write\n");
-               log4(OP_SKIPPED, OP_WRITE, offset, size);
-               return;
-       }
-
-       log4(OP_WRITE, offset, size, file_size);
-
-       gendata(original_buf, good_buf, offset, size);
-       if (file_size < offset + size) {
-               if (file_size < offset)
-                       memset(good_buf + file_size, '\0', offset - file_size);
-               file_size = offset + size;
-               if (lite) {
-                       warn("Lite file size bug in fsx!");
-                       report_failure(149);
-               }
-       }
-
-       if (testcalls <= simulatedopcount)
-               return;
-
-       if (!quiet && ((progressinterval &&
-                       testcalls % progressinterval == 0) ||
-                      (debug &&
-                       (monitorstart == -1 ||
-                        (offset + size > monitorstart &&
-                         (monitorend == -1 || offset <= monitorend))))))
-               prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
-                   offset, offset + size - 1, size);
-       ret = yaffs_lseek(fd, (off_t)offset, SEEK_SET);
-       if (ret == (off_t)-1) {
-               prterr("dowrite: lseek");
-               report_failure(150);
-       }
-       iret = yaffs_write(fd, good_buf + offset, size);
-       if (iret != size) {
-               if (iret == -1)
-                       prterr("dowrite: write");
-               else
-                       prt("short write: 0x%x bytes instead of 0x%x\n",
-                           iret, size);
-               report_failure(151);
-       }
-}
-
-
-
-void
-dotruncate(unsigned size)
-{
-       int oldsize = file_size;
-
-       size -= size % truncbdy;
-       if (size > biggest) {
-               biggest = size;
-               if (!quiet && testcalls > simulatedopcount)
-                       prt("truncating to largest ever: 0x%x\n", size);
-       }
-
-       log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
-
-       if (size > file_size)
-               memset(good_buf + file_size, '\0', size - file_size);
-       file_size = size;
-
-       if (testcalls <= simulatedopcount)
-               return;
-       
-       if ((progressinterval && testcalls % progressinterval == 0) ||
-           (debug && (monitorstart == -1 || monitorend == -1 ||
-                      size <= monitorend)))
-               prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
-       if (yaffs_ftruncate(fd, (off_t)size) == -1) {
-               prt("ftruncate1: %x\n", size);
-               prterr("dotruncate: ftruncate");
-               report_failure(160);
-       }
-}
-
-
-void
-writefileimage()
-{
-       ssize_t iret;
-
-       if (yaffs_lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
-               prterr("writefileimage: lseek");
-               report_failure(171);
-       }
-       iret = yaffs_write(fd, good_buf, file_size);
-       if ((off_t)iret != file_size) {
-               if (iret == -1)
-                       prterr("writefileimage: write");
-               else
-                       prt("short write: 0x%x bytes instead of 0x%llx\n",
-                           iret, (unsigned long long)file_size);
-               report_failure(172);
-       }
-       if (lite ? 0 : yaffs_ftruncate(fd, file_size) == -1) {
-               prt("ftruncate2: %llx\n", (unsigned long long)file_size);
-               prterr("writefileimage: ftruncate");
-               report_failure(173);
-       }
-}
-
-
-void
-docloseopen(void)
-{ 
-       if (testcalls <= simulatedopcount)
-               return;
-
-       if (debug)
-               prt("%lu close/open\n", testcalls);
-       if (yaffs_close(fd)) {
-               prterr("docloseopen: close");
-               report_failure(180);
-       }
-       fd = yaffs_open(fname, O_RDWR, 0);
-       if (fd < 0) {
-               prterr("docloseopen: open");
-               report_failure(181);
-       }
-}
-
-
-void
-test(void)
-{
-       unsigned long   offset;
-       unsigned long   size = maxoplen;
-       unsigned long   rv = random();
-       unsigned long   op = rv % (3 + !lite + mapped_writes);
-
-       /* turn off the map read if necessary */
-
-       if (op == 2 && !mapped_reads)
-           op = 0;
-
-       if (simulatedopcount > 0 && testcalls == simulatedopcount)
-               writefileimage();
-
-       testcalls++;
-
-       if (closeprob)
-               closeopen = (rv >> 3) < (1 << 28) / closeprob;
-
-       if (debugstart > 0 && testcalls >= debugstart)
-               debug = 1;
-
-       if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
-               prt("%lu...\n", testcalls);
-
-       /*
-        * READ:        op = 0
-        * WRITE:       op = 1
-        * MAPREAD:     op = 2
-        * TRUNCATE:    op = 3
-        * MAPWRITE:    op = 3 or 4
-        */
-       if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */
-               dotruncate(random() % maxfilelen);
-       else {
-               if (randomoplen)
-                       size = random() % (maxoplen+1);
-               if (lite ? 0 : op == 3)
-                       dotruncate(size);
-               else {
-                       offset = random();
-                       if (op == 1 || op == (lite ? 3 : 4)) {
-                               offset %= maxfilelen;
-                               if (offset + size > maxfilelen)
-                                       size = maxfilelen - offset;
-                               dowrite(offset, size);
-                       } else {
-                               if (file_size)
-                                       offset %= file_size;
-                               else
-                                       offset = 0;
-                               if (offset + size > file_size)
-                                       size = file_size - offset;
-                               doread(offset, size);
-                       }
-               }
-       }
-       if (sizechecks && testcalls > simulatedopcount)
-               check_size();
-       if (closeopen)
-               docloseopen();
-}
-
-
-void
-cleanup(sig)
-       int     sig;
-{
-       if (sig)
-               prt("signal %d\n", sig);
-       prt("testcalls = %lu\n", testcalls);
-       exit(sig);
-}
-
-
-void
-usage(void)
-{
-       fprintf(stdout, "usage: %s",
-               "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
-       -b opnum: beginning operation number (default 1)\n\
-       -c P: 1 in P chance of file close+open at each op (default infinity)\n\
-       -d: debug output for all operations\n\
-       -l flen: the upper bound on file size (default 262144)\n\
-       -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
-       -n: no verifications of file size\n\
-       -o oplen: the upper bound on operation size (default 65536)\n\
-       -p progressinterval: debug output at specified operation interval\n\
-       -q: quieter operation\n\
-       -r readbdy: 4096 would make reads page aligned (default 1)\n\
-       -s style: 1 gives smaller truncates (default 0)\n\
-       -t truncbdy: 4096 would make truncates page aligned (default 1)\n\
-       -w writebdy: 4096 would make writes page aligned (default 1)\n\
-       -D startingop: debug output starting at specified operation\n\
-       -L: fsxLite - no file creations & no file size changes\n\
-       -N numops: total # operations to do (default infinity)\n\
-       -O: use oplen (see -o flag) for every op (default random)\n\
-       -P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
-       -S seed: for random # generator (default 1) 0 gets timestamp\n\
-       fname: this filename is REQUIRED (no default)\n");
-       exit(90);
-}
-
-
-int
-getnum(char *s, char **e)
-{
-       int ret = -1;
-
-       *e = (char *) 0;
-       ret = strtol(s, e, 0);
-       if (*e)
-               switch (**e) {
-               case 'b':
-               case 'B':
-                       ret *= 512;
-                       *e = *e + 1;
-                       break;
-               case 'k':
-               case 'K':
-                       ret *= 1024;
-                       *e = *e + 1;
-                       break;
-               case 'm':
-               case 'M':
-                       ret *= 1024*1024;
-                       *e = *e + 1;
-                       break;
-               case 'w':
-               case 'W':
-                       ret *= 4;
-                       *e = *e + 1;
-                       break;
-               }
-       return (ret);
-}
-
-
-#define BASE_NAME "/M18-1"
-
-int random_seed = 999;
-int simulate_power_failure = 0;
-
-int
-main(int argc, char **argv)
-{
-       int     i, style, ch;
-       char    *endp;
-       char goodfile[1024];
-       char logfile[1024];
-
-       goodfile[0] = 0;
-       logfile[0] = 0;
-
-       page_size = getpagesize();
-       page_mask = page_size - 1;
-
-       setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
-
-       while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
-              != EOF)
-               switch (ch) {
-               case 'b':
-                       simulatedopcount = getnum(optarg, &endp);
-                       if (!quiet)
-                               fprintf(stdout, "Will begin at operation %ld\n",
-                                       simulatedopcount);
-                       if (simulatedopcount == 0)
-                               usage();
-                       simulatedopcount -= 1;
-                       break;
-               case 'c':
-                       closeprob = getnum(optarg, &endp);
-                       if (!quiet)
-                               fprintf(stdout,
-                                       "Chance of close/open is 1 in %d\n",
-                                       closeprob);
-                       if (closeprob <= 0)
-                               usage();
-                       break;
-               case 'd':
-                       debug = 1;
-                       break;
-               case 'l':
-                       maxfilelen = getnum(optarg, &endp);
-                       if (maxfilelen <= 0)
-                               usage();
-                       break;
-               case 'm':
-                       monitorstart = getnum(optarg, &endp);
-                       if (monitorstart < 0)
-                               usage();
-                       if (!endp || *endp++ != ':')
-                               usage();
-                       monitorend = getnum(endp, &endp);
-                       if (monitorend < 0)
-                               usage();
-                       if (monitorend == 0)
-                               monitorend = -1; /* aka infinity */
-                       debug = 1;
-               case 'n':
-                       sizechecks = 0;
-                       break;
-               case 'o':
-                       maxoplen = getnum(optarg, &endp);
-                       if (maxoplen <= 0)
-                               usage();
-                       break;
-               case 'p':
-                       progressinterval = getnum(optarg, &endp);
-                       if (progressinterval < 0)
-                               usage();
-                       break;
-               case 'q':
-                       quiet = 1;
-                       break;
-               case 'r':
-                       readbdy = getnum(optarg, &endp);
-                       if (readbdy <= 0)
-                               usage();
-                       break;
-               case 's':
-                       style = getnum(optarg, &endp);
-                       if (style < 0 || style > 1)
-                               usage();
-                       break;
-               case 't':
-                       truncbdy = getnum(optarg, &endp);
-                       if (truncbdy <= 0)
-                               usage();
-                       break;
-               case 'w':
-                       writebdy = getnum(optarg, &endp);
-                       if (writebdy <= 0)
-                               usage();
-                       break;
-               case 'D':
-                       debugstart = getnum(optarg, &endp);
-                       if (debugstart < 1)
-                               usage();
-                       break;
-               case 'L':
-                       lite = 1;
-                       break;
-               case 'N':
-                       numops = getnum(optarg, &endp);
-                       if (numops < 0)
-                               usage();
-                       break;
-               case 'O':
-                       randomoplen = 0;
-                       break;
-               case 'P':
-                       strncpy(goodfile, optarg, sizeof(goodfile));
-                       strcat(goodfile, "/");
-                       strncpy(logfile, optarg, sizeof(logfile));
-                       strcat(logfile, "/");
-                       break;
-               case 'R':
-                       mapped_reads = 0;
-                       break;
-               case 'S':
-                       seed = getnum(optarg, &endp);
-                       if (seed == 0)
-                               seed = time(0) % 10000;
-                       if (!quiet)
-                               fprintf(stdout, "Seed set to %d\n", seed);
-                       if (seed < 0)
-                               usage();
-                       break;
-               case 'W':
-                       mapped_writes = 0;
-                       if (!quiet)
-                               fprintf(stdout, "mapped writes DISABLED\n");
-                       break;
-
-               default:
-                       usage();
-                       /* NOTREACHED */
-               }
-       argc -= optind;
-       argv += optind;
-
-       yaffs_start_up();
-       yaffs_mount(BASE_NAME);
-       
-       fname = BASE_NAME "/fsxdata";
-
-       signal(SIGHUP,  cleanup);
-       signal(SIGINT,  cleanup);
-       signal(SIGPIPE, cleanup);
-       signal(SIGALRM, cleanup);
-       signal(SIGTERM, cleanup);
-       signal(SIGXCPU, cleanup);
-       signal(SIGXFSZ, cleanup);
-       signal(SIGVTALRM,       cleanup);
-       signal(SIGUSR1, cleanup);
-       signal(SIGUSR2, cleanup);
-
-       initstate(seed, state, 256);
-       setstate(state);
-       fd = yaffs_open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666);
-       if (fd < 0) {
-               prterr(fname);
-               exit(91);
-       }
-       strncat(goodfile, fname, 256);
-       strcat (goodfile, ".fsxgood");
-       fsxgoodfd = yaffs_open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
-       if (fsxgoodfd < 0) {
-               prterr(goodfile);
-               exit(92);
-       }
-       strncat(logfile, "fsx", 256);
-       strcat (logfile, ".fsxlog");
-       fsxlogf = fopen(logfile, "w");
-       if (fsxlogf == NULL) {
-               prterr(logfile);
-               exit(93);
-       }
-       if (lite) {
-               off_t ret;
-               file_size = maxfilelen = yaffs_lseek(fd, (off_t)0, SEEK_END);
-               if (file_size == (off_t)-1) {
-                       prterr(fname);
-                       warn("main: lseek eof");
-                       exit(94);
-               }
-               ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
-               if (ret == (off_t)-1) {
-                       prterr(fname);
-                       warn("main: lseek 0");
-                       exit(95);
-               }
-       }
-       original_buf = (char *) malloc(maxfilelen);
-       for (i = 0; i < maxfilelen; i++)
-               original_buf[i] = random() % 256;
-       good_buf = (char *) malloc(maxfilelen);
-       memset(good_buf, '\0', maxfilelen);
-       temp_buf = (char *) malloc(maxoplen);
-       memset(temp_buf, '\0', maxoplen);
-       if (lite) {     /* zero entire existing file */
-               ssize_t written;
-
-               written = yaffs_write(fd, good_buf, (size_t)maxfilelen);
-               if (written != maxfilelen) {
-                       if (written == -1) {
-                               prterr(fname);
-                               warn("main: error on write");
-                       } else
-                               warn("main: short write, 0x%x bytes instead of 0x%x\n",
-                                    (unsigned)written, maxfilelen);
-                       exit(98);
-               }
-       } else 
-               check_trunc_hack();
-
-       while (numops == -1 || numops--)
-               test();
-
-       if (yaffs_close(fd)) {
-               prterr("close");
-               report_failure(99);
-       }
-       
-       yaffs_close(fsxgoodfd);
-       
-       yaffs_unmount(BASE_NAME);
-       prt("All operations completed A-OK!\n");
-
-       exit(0);
-       return 0;
-}
-
diff --git a/direct/timothy_tests/found_bugs.txt b/direct/timothy_tests/found_bugs.txt
deleted file mode 100644 (file)
index e24443c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-Found bugs in yaffs
-
-Error code 0 bug (run out of handles)
-       By opening lots of files and not closing them yaffs can run out of handles. 
-       The error code given by yaffs_get_error() returns 0. this error is not defined in yportenv.h
-
-
-ENOENT error is generated when opening a new file with O_CREATE.
-       This should not be happening and has been logged as an error.
-       To regenerate this error remove the emfile and use the seed 1288064149
-
-EACCES error
-       This program tries to open a new file in yaffs. The yaffs_open() function returns a -1 handle and gives an error of EACCES.
-       This bug only seems to happen when the emfile has a lot of files in it.
-
-Mkdir with slash error
-       Yaffs' mkdir function will not work if the path ends in a slash.
-       i.e. /yaffs2/new_dir/
-       This is a known bug and is not likely to be fixed. 
-       To get around this bug remove the slash on the end.
-       i.e. /yaffs2/new_dir
-
-
-
-BUG in yaffs caused by the program yaffs_importer.py in /direct/python/
-       when the emfile is full yaffs gives these errors when trying to open a file:
-
-('adding path ', '/yaffs2/', ' to ', 'yaffs2/direct/basic-test/yaffs_tagscompat.o', ' resulting path: ', '/yaffs2/yaffs2/direct/basic-test/yaffs_tagscompat.o')
-('creating file:', '/yaffs2/yaffs2/direct/basic-test/yaffs_tagscompat.o')
-('mode', 33188)
-opening file
-erase block 248
-('current_handle', -1)
-yaffs free space: 0
-yaffs is out of space exiting program
-error with yaffs lseeking
-error######################################
-('error code', -9)
-error message EBADF
-('length of data to be written', 25944)
-('error writing file:', -1)
-error######################################
-('error code', -9)
-error message EBADF
-('error truncating file:', -1)
-error######################################
-('error code', -9)
-error message EBADF
-('error closing file:', -1)
-error######################################
-('error code', -9)
-error message EBADF
-('error chmoding file:', -1)
-error######################################
-('error code', -2)
-error message ENOENT
-
-       yaffs should be giving a no memory error insted of a EBADF. 
index a340165..91ece44 100644 (file)
@@ -45,14 +45,18 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
 #               yaffs_checkptrwtest.o\
 
 TESTFILES =    quick_tests.o lib.o \
-               test_mount_yaffs.o \
-               test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o \
-               test_yaffs_unlinking.o  \
-               test_yaffs_ftruncate.o test_yaffs_truncate.o \
+               test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_ENOENT.o test_yaffs_mount_EBUSY.o \
+               test_yaffs_unmount.o\
+               test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o test_yaffs_open_ENAMETOOLONG.o \
+               test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o \
+               test_yaffs_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\
+               test_yaffs_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_EFBIG.o \
+               test_yaffs_truncate.o test_yaffs_truncate_ENOTDIR.o test_yaffs_truncate_EISDIR.o test_yaffs_truncate_ENOENT.o test_yaffs_truncate_EINVAL.o \
+               test_yaffs_truncate_EFBIG.o\
                test_yaffs_write.o \
                test_yaffs_read.o \
                test_yaffs_lseek.o \
-               test_yaffs_access.o \
+               test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o\
                test_yaffs_stat.o \
                test_yaffs_close_EBADF.o
                  
@@ -119,4 +123,4 @@ quick_tests: $(SYMLINKS) $(ALLOBJS)
 
 
 clean:
-       rm -f quick_tests  $(ALLOBJS) core $(SYMLINKS) log.txt 
+       rm -f quick_tests  $(ALLOBJS) core $(SYMLINKS) 
index 127898c..3b32b43 100644 (file)
@@ -2,18 +2,99 @@
 Made by Timothy Manning <timothy@yaffs.net> on 04/11/2010
 
 
-the yaffs_open function has been covered by tests
-the yaffs_close function has been covered by tests
+Tests made
+       test_yaffs_mount
+       test_yaffs_mount_ENODEV
+       test_yaffs_mount_ENAMETOOLONG
+       test_yaffs_mount_ENOENT
+       test_yaffs_mount_EBUSY          //called when trying to mount a new mount point with a mount point already mounted.
+
+       test_yaffs_access
+       test_yaffs_access_ENIVAL        //when the mode is incorrect.
+       test_yaffs_access_ENOTDIR
+       test_yaffs_access_ENOENT
+
+       test_yaffs_close_EBADF
+
+       test_yaffs_ftruncate
+       test_yaffs_ftruncate_EBADF
+       test_yaffs_ftruncate_ENIVAL
+
+       test_yaffs_lseek
+
+       test_yaffs_open
+       test_yaffs_open_EEXIST
+       test_yaffs_open_EISDIR
+       test_yaffs_open_ENAMETOOLONG
+       test_yaffs_open_ENOENT
+       test_yaffs_open_ENOTDIR
+       test_yaffs_open_EINVAL
+       test_yaffs_open_EINVAL2 //the function open has to modes which can be set, so two modes are needed.
+
+       test_yaffs_read
+       test_yaffs_stat
+
+       test_yaffs_truncate
+       test_yaffs_truncate_ENOTDIR
+       test_yaffs_truncate_EISDIR
+       test_yaffs_truncate_ENOENT
+       test_yaffs_truncate_ENIVAL
+       test_yaffs_truncate_EFBIG
+
+       test_yaffs_unlink
+       test_yaffs_unlink_EISDIR
+       test_yaffs_unlink_ENAMETOOLONG
+       test_yaffs_unlink_ENOENT
+       test_yaffs_unlink_ENOTDIR
+       test_yaffs_unlink_ENOENT
+
+       test_yaffs_unmount
+       test_yaffs_write
+
+       add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog". 
+
+Tests to add
+       test_yaffs_mount_EACCES         //Cannot be generated with yaffs.
+       test_yaffs_mount_EINVAL         //Cannot be generated with yaffs.
+       test_yaffs_mount_ELOOP          //Cannot be generated with yaffs.
+       test_yaffs_mount_EMFILE         //Cannot be generated with yaffs.
+       test_yaffs_mount_ENOTDIR        //Cannot be generated with yaffs.
+
+       test_yaffs_umount_ENODEV
+       test_yaffs_umount_ENAMETOOLONG
+       test_yaffs_umount_ENOENT
+       test_yaffs_umount_EBUSY
 
-
-
-tests to add
        test_yaffs_open_EACCES
        test_yaffs_open_ENOSPC
-       test_yaffs_open_ELOOP   Too many symbolic links were encountered in resolving pathname
-       test_yaffs_close
+       test_yaffs_open_ELOOP   //Too many symbolic links were encountered in resolving pathname
        test yaffs_open_running_out_of_handles error
-       check to see if an error code is generated when there isn't an error
+
+       test_yaffs_close        //This function has already been called by the time this test is reached. 
+
+       test_yaffs_unlink_EACCES
+       test_yaffs_unlink_ELOOP
+       test_yaffs_unlink_ENOMEM
+
+       test_yaffs_access_EACCESS
+       test_yaffs_access_ELOOP
+       test_yaffs_access_ENAMETOOLONG
+       test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
+
+       test_yaffs_ftruncate_EACCES
+       test_yaffs_ftruncate_EFBIG
+       test_yaffs_ftruncate_EISDIR
+       test_yaffs_ftruncate_ELOOP
+       test_yaffs_ftruncate_ENOENT
+       test_yaffs_ftruncate_ENOTDIR
+
+       test_yaffs_truncate_EACCES
+       test_yaffs_truncate_ELOOP
+       test_yaffs_truncate_ENAMETOOLONG
+       add a truncate function for truncating a file size to -1.
+
+
+       check to see if an error code is generated when there isn't an error.
 
 
 How to add a test
@@ -24,47 +105,48 @@ How to add a test
        Test_yaffs_[function of yaffs which is been tested]_[error trying to be generated]
        
        The .c file needs to contain two functions.
-       The first function needs to contain the code for the main test and will return -1 on a failure and 0 or greater on a success.
-       The second function needs contain the code for cleaning up after the test. Cleaning up may include closing some open handles, recreating a file, ect. 
+       The first function needs to contain the code for the main test and will 
+       return -1 on a failure and 0 or greater on a success.
+       The second function needs contain the code for cleaning up after the test. 
+       Cleaning up may include closing some open handles, recreating a file, ect. 
        This second function needs to return -1 on a failure and 0 or greater on success.
 
-       The name of first function needs to be called the same as the file name (without the .c or .h)
-       The second function's name needs be the same as the first function but with "_clean" added on the end.
+       The name of first function needs to be called the same as the file 
+       name (without the .c or .h)
+       The second function's name needs be the same as the first function but 
+       with "_clean" added on the end.
        
-       So if a test is been created for the yaffs function yaffs_fish() then create these files
-       Test_yaffs_fish.c
-               Contains int test_yaffs_fish(void); int test_yaffs_fish_clean(void);
-       Test_yaffs_fish.h
+       So if a test is been created for the yaffs function yaffs_foo() then 
+       create these files
+       test_yaffs_foo.c
+               Contains int test_yaffs_foo(void); int test_yaffs_foo_clean(void);
+       test_yaffs_foo.h
                Which includes "lib.h", "yaffsfs.h" header files.
 
        Next write the test code in these files then add these files to the Makefile.
 
-       Add the name of the test files' object file (test_yaffs_fish.o ) to the TESTFILES tag around line 50 of the Makefile.   
-
-
+       Add the name of the test files' object file (test_yaffs_foo.o ) to the 
+       TESTFILES tag around line 50 of the Makefile.   
 
        Now add the test functions to the test_list[] array in quick_tests.h
-       The order of the tests matters. The idea is to test each yaffs_function individualy and only using tested yaffs_components before using this new yaffs_function. 
-       This array consists of: {[test function], [the clean function], [name of the tests which will be printed when the test fails]}, 
+       The order of the tests matters. The idea is to test each yaffs_function 
+       individualy and only using tested yaffs_components before using this new 
+       yaffs_function. 
+       This array consists of: 
+       {[test function], [the clean function], [name of the tests which will be printed when the test fails]}, 
        
-       So add this line to the test_list[]: {test_yaffs_fish, test_yaffs_fish_clean, "test_yaffs_fish"},
+       So add this line to the test_list[]: {test_yaffs_foo, test_yaffs_foo_clean, "test_yaffs_foo"},
 
-       Also include the test's .h file in the quick_test.h file: #include "test_yaffs_fish.h"
-
-       The test file should now make and run. 
-       
-       
+       Also include the test's .h file in the quick_test.h file: #include "test_yaffs_foo.h"
        
+       The test file should now make and run(you may need to make clean first). 
 
 
 
-       PS: yaffs_fish() is a made up function for this README (in case you want to try and find this function in yaffs). 
+       PS: yaffs_foo() is a made up function for this README (in case you want 
+       to find this function in yaffs). 
 
 
-BUGS
-       Needing to include int random_seed; and int simulate_power_failure = 0; in any main program using yaffsfs.h
-       ENOSPC error in programs test_yaffs_open_ENOTDIR and test_yaffs_open_ENOENT.
-       ENOENT been returned by yaffs_read but the handle is good and the yaffs_open function does not return an error.
 
 
 
diff --git a/direct/timothy_tests/quick_tests/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt
new file mode 100644 (file)
index 0000000..24ed8ca
--- /dev/null
@@ -0,0 +1,43 @@
+
+Made by Timothy Manning <timothy@yaffs.net> on 08/11/2010
+
+
+Current BUGS 
+       Bug with opening a file with a name of 1,000,000 char long with no errors.
+
+       Bug with unlinking a file with 1,000,000 get the error ENOENT but should
+       be geting ENAMETOOLONG. 
+
+       Bug with mounting a too long non-existant mount point is returning 
+       ENODEV. there are two errors here, ENOENT and ENAMETOOLONG.
+       The ENODEV is the error which yaffs gives instead of ENOENT.
+       BBut the mount function should just return ENAMETOOLONG.
+
+       Bug when trying to use yaffs_access on an existing file with mode 255 
+       the error returned is EACCES it should be EINVAL(note there is no quick test file yet).
+
+       Bug when trying to access a non-existing directory the error ENOENT is 
+       returned. It should be ENOTDIR.
+
+       Bug when trying to truncate a file in a non-existing directory. The error
+       returned is ENOENT it should be ENOTDIR.
+
+       Bug truncating a file to a size of -1 does not cause an error. 
+
+       
+       Bug with opening a file with bad mode. yaffs_open has two modes which 
+       are passed into it. if the modes are set to 255 the open function 
+       does not report any errors. (Also need to try this with modes set to -1.)  
+
+
+Current WARNINGS
+       
+       WARNING- truncating a file to a size greater than the maximum file size returns
+       EINVAL. In standard linux system the error EFBIG is returned. 
+       
+       WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. 
+       some function return EBADF instead.
+
+       WARNING- When mounting a non-existing mount point the error ENODEV is returned.
+       The quick tests have been altered to accommodate this error code.    
+       With standard access function in linux the error returned is ENOENT.
index 3753583..e057f12 100644 (file)
@@ -31,7 +31,7 @@ int main(){
 
        unsigned int x=0;       
        init_quick_tests();
-       printf("\n\nrunning quick tests for yaffs\n");
+       printf("\n\nrunning quick tests for yaffs\n\n");
        //printf("testing yaffs\n");
 
        //printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
@@ -41,23 +41,37 @@ int main(){
                output=test_list[x].p_function();       /*run test*/
                if (output>=0){
                        /*test has passed*/
+                       printf("\ttest %s passed\n",test_list[x].name_of_test); 
                        num_of_tests_pass++;
                }
                else {
                        /*test is assumed to have failed*/
                        //printf("test failed\n");
-                       printf("test: %s failed\n",test_list[x].fail_message);          
+                       printf("test: %s failed\n",test_list[x].name_of_test);          
                        num_of_tests_failed ++; 
-                       quit_quick_tests(1);
-                       
+
+                       if (EXIT_ON_ERROR){
+                               get_error();
+                               printf("\n\n");
+                               quit_quick_tests(1);
+                       }
+                       else {
+                               get_error();
+                               printf("\n\n");
+                       }
                }
                output=test_list[x].p_function_clean(); /*clean the test*/
                if (output <0){
                        /* if the test failed to clean it's self then */
-                       printf("test: %s failed to clean\n",test_list[x].fail_message);         
+                       printf("test: %s failed to clean\n",test_list[x].name_of_test);         
                        num_of_tests_failed ++; 
                        num_of_tests_pass--;
-                       quit_quick_tests(1);
+                       get_error();
+                       printf("\n\n");
+                       if (EXIT_ON_ERROR){
+                               quit_quick_tests(1);
+                       }
+                       
                }
                        
        }
@@ -68,20 +82,22 @@ int main(){
 }
 
 void quit_quick_tests(int exit_code){
-       int error_code=0;
+       
        if (num_of_tests_pass==total_number_of_tests &&  num_of_tests_failed==0){
                printf("\t OK \n");
        }
-       else {
-               error_code=yaffs_get_error();
-               printf("yaffs_error code %d\n",error_code);
-               printf("error is : %s\n",yaffs_error_to_str(error_code));
-       }
        printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed);
        yaffs_unmount(YAFFS_MOUNT_POINT);
        exit(exit_code);
 }
 
+void get_error(void){
+       int error_code=0;
+       error_code=yaffs_get_error();
+       printf("yaffs_error code %d\n",error_code);
+       printf("error is : %s\n",yaffs_error_to_str(error_code));
+}
+
 void init_quick_tests(void){
        yaffs_start_up();;
        yaffs_set_trace(0);
index ebe55b6..3d5dc6a 100644 (file)
 #define __quick_tests_h__
 #include <stdio.h>
 
-#include "test_mount_yaffs.h"
+#include "test_yaffs_mount.h"
+#include "test_yaffs_mount_ENODEV.h"
+#include "test_yaffs_mount_ENAMETOOLONG.h"
+#include "test_yaffs_mount_ENOENT.h"
+#include "test_yaffs_mount_EBUSY.h"
+
+#include "test_yaffs_unmount.h"
 
 #include "test_yaffs_open.h"
 #include "test_yaffs_open_EISDIR.h"
 #include "test_yaffs_open_EEXIST.h"
 #include "test_yaffs_open_ENOENT.h"
 #include "test_yaffs_open_ENOTDIR.h"
+#include "test_yaffs_open_ENAMETOOLONG.h"
+#include "test_yaffs_open_EINVAL.h"
+#include "test_yaffs_open_EINVAL2.h"
 
 #include "test_yaffs_close_EBADF.h"
 
 
-#include "test_yaffs_unlinking.h"
+#include "test_yaffs_unlink.h"
+#include "test_yaffs_unlink_EISDIR.h"
+#include "test_yaffs_unlink_ENOENT.h"
+#include "test_yaffs_unlink_ENAMETOOLONG.h"
+#include "test_yaffs_unlink_ENOTDIR.h"
+#include "test_yaffs_unlink_ENOENT.h"
+
 #include "test_yaffs_ftruncate.h"
+#include "test_yaffs_ftruncate_EBADF.h"
+#include "test_yaffs_ftruncate_EINVAL.h"
+#include "test_yaffs_ftruncate_EFBIG.h"
+
 #include "test_yaffs_truncate.h"
+#include "test_yaffs_truncate_ENOTDIR.h"
+#include "test_yaffs_truncate_EISDIR.h"
+#include "test_yaffs_truncate_ENOENT.h"
+#include "test_yaffs_truncate_EINVAL.h"
+#include "test_yaffs_truncate_EFBIG.h"
+
 #include "test_yaffs_write.h"
 #include "test_yaffs_read.h"
 #include "test_yaffs_lseek.h"
+
 #include "test_yaffs_access.h"
+#include "test_yaffs_access_EINVAL.h"
+#include "test_yaffs_access_ENOTDIR.h"
+#include "test_yaffs_access_ENOENT.h"
+
 #include "test_yaffs_stat.h"
 #include "yaffsfs.h"
 #include "yaffs_error_converter.h"
 #include "lib.h"
 
+
+#define EXIT_ON_ERROR 0
+
 typedef struct test {
        int (*p_function)(void);        /*pointer to test function*/
        int (*p_function_clean)(void);
        /*char pass_message[50]; will not need a pass message*/
-       char *fail_message;     /*pointer to fail message, needs to include name of test*/
+       char *name_of_test;     /*pointer to fail message, needs to include name of test*/
 }test_template;
 
 
 test_template test_list[]={
-       {mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"},
+       {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
+       {test_yaffs_mount_ENODEV,test_yaffs_mount_ENODEV_clean,"test_yaffs_mount_ENODEV"},
+//     {test_yaffs_mount_ENAMETOOLONG,test_yaffs_mount_ENAMETOOLONG_clean,"test_yaffs_mount_ENAMETOOLONG"},
+       {test_yaffs_mount_ENOENT,test_yaffs_mount_ENOENT_clean,"test_yaffs_mount_ENOENT"},
+       {test_yaffs_mount_EBUSY,test_yaffs_mount_EBUSY_clean,"test_yaffs_mount_EBUSY"},
+
+       {test_yaffs_unmount,test_yaffs_unmount_clean,"test_yaffs_unmount"},
+
        {test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"},
        {test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"},
        {test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"},
        {test_yaffs_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"},
        {test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"},
+       {test_yaffs_open_ENAMETOOLONG,test_yaffs_open_ENAMETOOLONG_clean,"test_yaffs_open_ENAMETOOLONG"},
+       {test_yaffs_open_EINVAL,test_yaffs_open_EINVAL_clean,"test_yaffs_open_EINVAL"},
+       {test_yaffs_open_EINVAL2,test_yaffs_open_EINVAL2_clean,"test_yaffs_open_EINVAL2"},
        
        {test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
 
        {test_yaffs_access,test_yaffs_access_clean,"test_yaffs_access"},
-       {test_yaffs_unlinking, test_yaffs_unlinking_clean,"test_yaffs_unlinking"},
+       {test_yaffs_access_EINVAL,test_yaffs_access_EINVAL_clean,"test_yaffs_access_EINVAL"},
+       {test_yaffs_access_ENOTDIR,test_yaffs_access_ENOTDIR_clean,"test_yaffs_access_ENOTDIR"},
+       {test_yaffs_access_ENOENT,test_yaffs_access_ENOENT_clean,"test_yaffs_access_ENOENT"},
+
+       {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"},
+       {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"},
+       {test_yaffs_unlink_ENOENT,test_yaffs_unlink_ENOENT_clean,"test_yaffs_unlink_ENOENT"},
+       {test_yaffs_unlink_ENAMETOOLONG,test_yaffs_unlink_ENAMETOOLONG_clean,"test_yaffs_unlink_ENAMETOOLONG"},
+       {test_yaffs_unlink_ENOTDIR,test_yaffs_unlink_ENOTDIR_clean,"test_yaffs_unlink_ENOTDIR"},
+       {test_yaffs_unlink_ENOENT,test_yaffs_unlink_ENOENT_clean,"test_yaffs_unlink_ENOENT"},
+
 
        {test_yaffs_lseek,test_yaffs_lseek_clean,"test_yaffs_lseek"},
        {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
@@ -67,11 +120,21 @@ test_template test_list[]={
 
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
+
        {test_yaffs_ftruncate,test_yaffs_ftruncate_clean,"test_yaffs_ftruncate"},
-       {test_yaffs_truncate,test_yaffs_truncate_clean,"test_yaffs_truncate"}
+       {test_yaffs_ftruncate_EBADF,test_yaffs_ftruncate_EBADF_clean,"test_yaffs_ftruncate_EBADF"},
+       {test_yaffs_ftruncate_EINVAL,test_yaffs_ftruncate_EINVAL_clean,"test_yaffs_ftruncate_EINVAL"},
+       {test_yaffs_ftruncate_EFBIG,test_yaffs_ftruncate_EFBIG_clean,"test_yaffs_ftruncate_EFBIG"},
 
+       {test_yaffs_truncate,test_yaffs_truncate_clean,"test_yaffs_truncate"},
+       {test_yaffs_truncate_ENOTDIR,test_yaffs_truncate_ENOTDIR_clean,"test_yaffs_truncate_ENOTDIR"},
+       {test_yaffs_truncate_EISDIR,test_yaffs_truncate_EISDIR_clean,"test_yaffs_truncate_EISDIR"},
+       {test_yaffs_truncate_EINVAL,test_yaffs_truncate_EINVAL_clean,"test_yaffs_truncate_EINVAL"},
+       {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"},
+       {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"}
        };
 
 void init_quick_tests(void);
 void quit_quick_tests(int exit_code);
+void get_error(void);
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.c
new file mode 100644 (file)
index 0000000..cec0389
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_access_EINVAL.h"
+
+int test_yaffs_access_EINVAL(void){
+       int output=0;
+       int error=0;
+       output= yaffs_access(FILE_PATH,255);
+       if (output<0){
+               error=yaffs_get_error();
+               if ( abs(error)== EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("error does not match expected error\n");
+                       return -1;
+               }
+       }
+       else{
+               printf("accessed an existing file with bad mode (which is a bad thing\n");
+               return -1;
+       }
+}
+
+int test_yaffs_access_EINVAL_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_access_EINVAL.h
new file mode 100644 (file)
index 0000000..b13a1a0
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs__access_EINVAL_h__
+#define __test_yaffs_access_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+#include "test_yaffs_lseek.h"
+int test_yaffs_access_EINVAL(void);
+int test_yaffs_access_EINVAL_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c
new file mode 100644 (file)
index 0000000..610e4ee
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_access_ENOENT.h"
+
+
+int test_yaffs_access_ENOENT(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       output=yaffs_access("/yaffs2/non_existant_file",0);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOENT){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant file accessed.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_access_ENOENT_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h
new file mode 100644 (file)
index 0000000..ed24f95
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_access_ENOENT_h__
+#define __test_yaffs_access_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_access_ENOENT(void);
+int test_yaffs_access_ENOENT_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c
new file mode 100644 (file)
index 0000000..ad2402c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_access_ENOTDIR.h"
+
+static int handle=0;
+int test_yaffs_access_ENOTDIR(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       output=yaffs_access("/nonexisting_dir/foo",0);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==ENOTDIR){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant directory accessed.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_access_ENOTDIR_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h
new file mode 100644 (file)
index 0000000..0f18c90
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_access_ENOTDIR_h__
+#define __test_yaffs_access_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_access_ENOTDIR(void);
+int test_yaffs_access_ENOTDIR_clean(void);
+#endif
index fec910d..a6d661b 100644 (file)
@@ -16,7 +16,7 @@
 static int handle=0;
 int test_yaffs_ftruncate(void){
        handle=test_yaffs_open();
-       if (handle>0){
+       if (handle>=0){
                return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
        }
        else {
@@ -28,7 +28,7 @@ int test_yaffs_ftruncate(void){
 int test_yaffs_ftruncate_clean(void){
        /* change file size back to orignal size */
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                output=yaffs_ftruncate(handle,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.c
new file mode 100644 (file)
index 0000000..e308906
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_ftruncate_EBADF.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EBADF(void){
+       int output=0;
+       int error_code=0;
+       output= yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED );
+       if (output<0){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+               if (abs(error_code)== EBADF){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant file truncated.(which is a bad thing)\n");
+               return -1;
+       }
+}
+
+int test_yaffs_ftruncate_EBADF_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EBADF.h
new file mode 100644 (file)
index 0000000..631150d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_ftruncate_EBADF_h__
+#define __test_yaffs_ftruncate_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EBADF(void);
+int test_yaffs_ftruncate_EBADF_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.c
new file mode 100644 (file)
index 0000000..3c99f1b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_ftruncate_EFBIG.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EFBIG(void){
+       int output=0;
+       int error_code=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output=yaffs_ftruncate(handle,10000000000000000000000000000000);
+               if (output<0){
+                       error_code=yaffs_get_error();
+                       //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+                       if (abs(error_code)== EINVAL){  /* yaffs uses the error EINVAL instead of EFBIG */
+                               return 1;
+                       }
+                       else {
+                               printf("different error than expected\n");
+                               return -1;
+                       }
+               }
+               else {
+                       printf("file truncated to a very large size.(which is a bad thing)\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+
+       
+       
+}
+
+int test_yaffs_ftruncate_EFBIG_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EFBIG.h
new file mode 100644 (file)
index 0000000..0e10046
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_ftruncate_EFBIG_h__
+#define __test_yaffs_ftruncate_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EFBIG(void);
+int test_yaffs_ftruncate_EFBIG_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.c
new file mode 100644 (file)
index 0000000..9a47c39
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_ftruncate_EINVAL.h"
+
+static int handle=0;
+int test_yaffs_ftruncate_EINVAL(void){
+       int output=0;
+       int error_code=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output=yaffs_ftruncate(handle,-1 );
+               if (output<0){
+                       error_code=yaffs_get_error();
+                       //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+                       if (abs(error_code)== EINVAL){
+                               return 1;
+                       }
+                       else {
+                               printf("different error than expected\n");
+                               return -1;
+                       }
+               }
+               else {
+                       printf("file truncated to a negative size.(which is a bad thing)\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("error opening file\n");
+               return -1;
+       }
+
+       
+       
+}
+
+int test_yaffs_ftruncate_EINVAL_clean(void){
+       return 1;
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_ftruncate_EINVAL.h
new file mode 100644 (file)
index 0000000..d95bdb8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_ftruncate_EINVAL_h__
+#define __test_yaffs_ftruncate_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_ftruncate_EINVAL(void);
+int test_yaffs_ftruncate_EINVAL_clean(void); 
+#endif
index 5e063ef..588635e 100644 (file)
@@ -18,7 +18,7 @@ int test_yaffs_lseek(void){
        handle=test_yaffs_open();
        char text[20]="\0";
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                if (0==yaffs_lseek(handle, 0, SEEK_SET)){
                        return 1;
                }
  * published by the Free Software Foundation.
  */
 
-#include "test_mount_yaffs.h"
+#include "test_yaffs_mount.h"
 
-int mount_yaffs_test(void){
+int test_yaffs_mount(void){
        int output=0;
        output=yaffs_mount(YAFFS_MOUNT_POINT);
        /*printf("output %d",output);*/
        return output;
 }
 
-int mount_yaffs_test_clean(void){
+int test_yaffs_mount_clean(void){
        return 1;
        
 }
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __mount_yaffs_test__
-#define __mount_yaffs_test__
+#ifndef __test_yaffs_mount__
+#define __test_yaffs_mount__
 
 #include "yaffsfs.h"
 #include "lib.h"
 
-int mount_yaffs_test(void);
-int mount_yaffs_test_clean(void);
+int test_yaffs_mount(void);
+int test_yaffs_mount_clean(void);
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.c
new file mode 100644 (file)
index 0000000..eb08ef2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_mount_EBUSY.h"
+
+
+int test_yaffs_mount_EBUSY(void){
+       int output=0;
+       int error_code=0;
+
+       output=yaffs_mount(YAFFS_MOUNT_POINT);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==EBUSY){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else if (output >=0){
+               printf("mounted the same mount point twice.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_mount_EBUSY_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_EBUSY.h
new file mode 100644 (file)
index 0000000..5c34869
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_mount_EBUSY_h__
+#define __test_yaffs_mount_EBUSY_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mount_EBUSY(void);
+int test_yaffs_mount_EBUSY_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.c
new file mode 100644 (file)
index 0000000..99102c9
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_mount_ENAMETOOLONG.h"
+
+
+
+
+int test_yaffs_mount_ENAMETOOLONG(void){
+       int output=0;
+       int x;
+       int error_code=0;
+       int file_name_length=1000000;
+       char file_name[file_name_length];
+
+       /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */
+       output=test_yaffs_unmount();
+       if (output<0){
+               printf("yaffs failed to unmount\n");
+               return -1;
+       } 
+
+       strcat(file_name,YAFFS_MOUNT_POINT);
+       for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+               file_name[x]='a';
+       }
+       file_name[file_name_length-2]='\0';
+       
+       //printf("file name: %s\n",file_name);
+
+
+       output=yaffs_mount(file_name);
+
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)== ENAMETOOLONG){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("mounted a too long mount point name.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_mount_ENAMETOOLONG_clean(void){
+       return test_yaffs_mount();
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENAMETOOLONG.h
new file mode 100644 (file)
index 0000000..746fc48
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_mount_ENAMETOOLONG_h__
+#define __test_yaffs_mount_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_mount.h"
+#include "test_yaffs_unmount.h"
+
+
+int test_yaffs_mount_ENAMETOOLONG(void);
+int test_yaffs_mount_ENAMETOOLONG_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.c
new file mode 100644 (file)
index 0000000..e0bc9f7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_mount_ENODEV.h"
+
+static int handle=0;
+int test_yaffs_mount_ENODEV(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_mount("/nonexisting_mount_point/");
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==ENODEV){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else if (output >=0){
+               printf("non existant directory opened.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_mount_ENODEV_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENODEV.h
new file mode 100644 (file)
index 0000000..27cd767
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_mount_ENODEV_h__
+#define __test_yaffs_mount_ENODEV_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_mount_ENODEV(void);
+int test_yaffs_mount_ENODEV_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c
new file mode 100644 (file)
index 0000000..01040fd
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_mount_ENOENT.h"
+
+
+int test_yaffs_mount_ENOENT(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       
+       
+       /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */
+       output=test_yaffs_unmount();
+       if (output<0){
+               printf("yaffs failed to unmount\n");
+               return -1;
+       } 
+
+       output=yaffs_mount("/non_existaint_mount_point/");
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENODEV){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant mount point mounted.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_mount_ENOENT_clean(void){
+       return test_yaffs_mount();
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h
new file mode 100644 (file)
index 0000000..e0e7ad6
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_mount_ENOENT_h__
+#define __test_yaffs_mount_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_unmount.h"
+#include "test_yaffs_mount.h"
+
+int test_yaffs_mount_ENOENT(void);
+int test_yaffs_mount_ENOENT_clean(void);
+#endif
index 76ed67b..d7237a8 100644 (file)
@@ -23,7 +23,6 @@ int test_yaffs_open(void){
 
 
 int test_yaffs_open_clean(void){
-       handle=0;
        if (handle >=0){
                return yaffs_close(handle);
        }
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.c
new file mode 100644 (file)
index 0000000..17c5912
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_open_EINVAL.h"
+
+static int handle=0;
+int test_yaffs_open_EINVAL(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_open(FILE_PATH, 255,FILE_MODE);
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
+               if (abs(error_code)== EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf(" file opened with bad mode.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_open_EINVAL_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL.h
new file mode 100644 (file)
index 0000000..85597da
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_open_EINVAL_h__
+#define __test_yaffs_open_EINVAL_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EINVAL(void);
+int test_yaffs_open_EINVAL_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.c
new file mode 100644 (file)
index 0000000..cdab776
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_open_EINVAL2.h"
+
+static int handle=0;
+int test_yaffs_open_EINVAL2(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_open(FILE_PATH, O_CREAT | O_RDWR ,255);
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
+               if (abs(error_code)== EINVAL){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf(" file opened with bad mode.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_open_EINVAL2_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_open_EINVAL2.h
new file mode 100644 (file)
index 0000000..de35847
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_open_EINVAL2_h__
+#define __test_yaffs_open_EINVAL2_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EINVAL2(void);
+int test_yaffs_open_EINVAL2_clean(void);
+#endif
index d86e081..b15156f 100644 (file)
@@ -32,12 +32,11 @@ int test_yaffs_open_EISDIR(void){
                        return -1;
                }
        }
-       else if (output >=0){
+       else {
                printf("non existant directory opened.(which is a bad thing)\n");
                return -1;
        }
-       /* the program should not get here but the compiler is complaining */
-       return -1;
+
 }
 int test_yaffs_open_EISDIR_clean(void){
        if (handle >=0){
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.c
new file mode 100644 (file)
index 0000000..44fd562
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_open_ENAMETOOLONG.h"
+
+
+
+static int handle=0;
+int test_yaffs_open_ENAMETOOLONG(void){
+       int output=0;
+       int x;
+       int error_code=0;
+       int file_name_length=1000000;
+       char file_name[file_name_length];
+
+       strcat(file_name,YAFFS_MOUNT_POINT);
+       for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+               file_name[x]='a';
+       }
+       file_name[file_name_length-2]='\0';
+       
+       //printf("file name: %s\n",file_name);
+
+
+       handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
+
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
+               if (abs(error_code)== ENAMETOOLONG){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else if (output >=0){
+               printf("handle %d \n",handle);
+               printf("non existant file opened.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_open_ENAMETOOLONG_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_open_ENAMETOOLONG.h
new file mode 100644 (file)
index 0000000..8325fd5
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_open_ENAMETOOLONG_h__
+#define __test_yaffs_open_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_ENAMETOOLONG(void);
+int test_yaffs_open_ENAMETOOLONG_clean(void);
+#endif
index 1b19bd5..c1ae528 100644 (file)
@@ -16,7 +16,7 @@ static int handle=0;
 
 int test_yaffs_truncate(void){
        handle=test_yaffs_open();
-       if (handle>0){
+       if (handle>=0){
                return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
        }
        else {
@@ -27,9 +27,8 @@ int test_yaffs_truncate(void){
 
 int test_yaffs_truncate_clean(void){
        /* change file size back to orignal size */
-       int handle=test_yaffs_open();
        int output=0;
-       if (handle>0){
+       if (handle>=0){
                output= yaffs_truncate(FILE_PATH,FILE_SIZE );
                if (output>=0){
                        return yaffs_close(handle);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.c
new file mode 100644 (file)
index 0000000..7ea85da
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_truncate_EFBIG.h"
+static int handle=0;
+
+int test_yaffs_truncate_EFBIG(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/foo",10000000000000000000000000000000000000000000 );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==EINVAL){        /*in yaffs EINVAL is used instead of EFBIG */
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a file to a massive size\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_EFBIG_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EFBIG.h
new file mode 100644 (file)
index 0000000..15f0999
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_truncate_EFBIG_h__
+#define __test_yaffs_truncate_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EFBIG(void);
+int test_yaffs_truncate_EFBIG_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c
new file mode 100644 (file)
index 0000000..bec53de
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_truncate_EINVAL.h"
+static int handle=0;
+
+int test_yaffs_truncate_EINVAL(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/foo",-1 );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==EINVAL){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a file with a bad mode set.\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_EINVAL_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h
new file mode 100644 (file)
index 0000000..f78af54
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_truncate_EINVAL_h__
+#define __test_yaffs_truncate_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EINVAL(void);
+int test_yaffs_truncate_EINVAL_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c
new file mode 100644 (file)
index 0000000..051e1a7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_truncate.h"
+static int handle=0;
+
+int test_yaffs_truncate_EISDIR(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/",10);
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==EISDIR){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a directory\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return 1;
+       }
+}
+
+int test_yaffs_truncate_EISDIR_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h
new file mode 100644 (file)
index 0000000..7299c6d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_truncate_EISDIR_h__
+#define __test_yaffs_truncate_EISDIR_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EISDIR(void);
+int test_yaffs_truncate_EISDIR_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c
new file mode 100644 (file)
index 0000000..6258aea
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_truncate_ENOENT.h"
+static int handle=0;
+
+int test_yaffs_truncate_ENOENT(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==ENOENT){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a nonexisting file\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_ENOENT_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h
new file mode 100644 (file)
index 0000000..1a74d87
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_truncate_ENOENT_h__
+#define __test_yaffs_truncate_ENOENT_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_ENOENT(void);
+int test_yaffs_truncate_ENOENT_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c
new file mode 100644 (file)
index 0000000..2cc71b5
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_truncate_ENOTDIR.h"
+static int handle=0;
+
+int test_yaffs_truncate_ENOTDIR(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==ENOTDIR){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a nonexisting file\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_ENOTDIR_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h
new file mode 100644 (file)
index 0000000..24120d4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_truncate_ENOTDIR_h__
+#define __test_yaffs_truncate_ENOTDIR_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_ENOTDIR(void);
+int test_yaffs_truncate_ENOTDIR_clean(void); 
+#endif
@@ -11,9 +11,9 @@
  * published by the Free Software Foundation.
  */
 
-#include "test_yaffs_unlinking.h"
+#include "test_yaffs_unlink.h"
 
-int test_yaffs_unlinking(void){
+int test_yaffs_unlink(void){
        int output=yaffs_unlink(FILE_PATH);
        if (output>=0){
                return (-test_yaffs_access());  /*return negative access. we do not want the file to be there*/
@@ -24,6 +24,6 @@ int test_yaffs_unlinking(void){
        }
 }
 
-int test_yaffs_unlinking_clean(void){
+int test_yaffs_unlink_clean(void){
        return test_yaffs_open();
 }
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
-#ifndef __test_yaffs_unlinking_h__
-#define __test_yaffs_unlinking_h__
+#ifndef __test_yaffs_unlink_h__
+#define __test_yaffs_unlink_h__
 
 #include "lib.h"
 #include "yaffsfs.h"
 #include "test_yaffs_open.h"
 #include "test_yaffs_access.h"
 
-int test_yaffs_unlinking(void);
-int test_yaffs_unlinking_clean(void);
+int test_yaffs_unlink(void);
+int test_yaffs_unlink_clean(void);
 #endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.c
new file mode 100644 (file)
index 0000000..80c8f40
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_unlink_EISDIR.h"
+
+/*EISDIR is caused by trying to unlink a directory */
+
+static int handle=0;
+int test_yaffs_unlink_EISDIR(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_unlink(YAFFS_MOUNT_POINT);
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+               if (abs(error_code)== EISDIR){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else if (output >=0){
+               printf("directory unlinked opened.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_unlink_EISDIR_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_EISDIR.h
new file mode 100644 (file)
index 0000000..cdba6f5
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_unlink_EISDIR_h__
+#define __test_yaffs_unlink_EISDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_EISDIR(void);
+int test_yaffs_unlink_EISDIR_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.c
new file mode 100644 (file)
index 0000000..c5184a5
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_unlink_ENAMETOOLONG.h"
+
+
+static int handle=0;
+int test_yaffs_unlink_ENAMETOOLONG(void){
+       int output=0;
+       int error_code=0;
+       int x=0;
+       int file_name_length=1000000;
+       char file_name[file_name_length];
+       
+       strcat(file_name,YAFFS_MOUNT_POINT);
+       for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+               file_name[x]='a';
+       }
+       file_name[file_name_length-2]='\0';
+
+       /*printf("path %s\n",path); */
+       output=yaffs_unlink(file_name);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+               if (abs(error_code)== EISDIR){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("directory unlinked opened.(which is a bad thing)\n");
+               return -1;
+       }
+       /* the program should not get here but the compiler is complaining */
+       return -1;
+}
+int test_yaffs_unlink_ENAMETOOLONG_clean(void){
+       if (handle >=0){
+               return yaffs_close(handle);
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENAMETOOLONG.h
new file mode 100644 (file)
index 0000000..dffaeb9
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_unlink_ENAMETOOLONG_h__
+#define __test_yaffs_unlink_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_ENAMETOOLONG(void);
+int test_yaffs_unlink_ENAMETOOLONG_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.c
new file mode 100644 (file)
index 0000000..8821257
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_unlink_ENOENT.h"
+
+static int handle=0;
+int test_yaffs_unlink_ENOENT(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       handle=yaffs_unlink("/yaffs2/non_existant_file");
+       if (handle==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOENT){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else if (output >=0){
+               printf("non existant file unlinked.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_unlink_ENOENT_clean(void){
+       if (handle >=0){
+               return test_yaffs_open();
+       }
+       else {
+               return 1;       /* the file failed to open so there is no need to close it*/
+       }
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOENT.h
new file mode 100644 (file)
index 0000000..ec95fd7
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_unlink_ENOENT_h__
+#define __test_yaffs_unlink_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+
+int test_yaffs_unlink_ENOENT(void);
+int test_yaffs_unlink_ENOENT_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.c
new file mode 100644 (file)
index 0000000..8724376
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_open_ENOTDIR.h"
+
+
+int test_yaffs_unlink_ENOTDIR(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       output=yaffs_unlink("/nonexisting_dir/foo");
+       if (output==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==ENOTDIR){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant directory opened.(which is a bad thing)\n");
+               return -1;
+       }
+
+
+}
+int test_yaffs_unlink_ENOTDIR_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_unlink_ENOTDIR.h
new file mode 100644 (file)
index 0000000..82e44da
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_unlink_ENOTDIR_h__
+#define __test_yaffs_unlink_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_ENOTDIR(void);
+int test_yaffs_unlink_ENOTDIR_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount.c
new file mode 100644 (file)
index 0000000..b3ddba2
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "test_yaffs_unmount.h"
+
+int test_yaffs_unmount(void){
+       int output=0;
+       output=yaffs_unmount(YAFFS_MOUNT_POINT);
+       /*printf("output %d",output);*/
+       return output;
+}
+
+int test_yaffs_unmount_clean(void){
+       return test_yaffs_mount();
+       
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount.h
new file mode 100644 (file)
index 0000000..7b0562a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __test_yaffs_unmount__
+#define __test_yaffs_unmount__
+
+#include "yaffsfs.h"
+#include "lib.h"
+#include "test_yaffs_mount.h"
+
+int test_yaffs_unmount(void);
+int test_yaffs_unmount_clean(void);
+#endif
index 3cd532e..41d37f4 100644 (file)
@@ -67,14 +67,14 @@ static yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES];
 static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
 static int yaffsfs_handlesInitialised;
 
-unsigned int yaffs_trace_mask;
 
-int yaffs_set_trace(unsigned int tm) 
+unsigned yaffs_set_trace(unsigned  tm) 
 {
-       return yaffs_trace_mask=tm;
+       yaffs_trace_mask = tm;
+       return yaffs_trace_mask;
 }
 
-unsigned int yaffs_get_trace(void)
+unsigned yaffs_get_trace(void)
 {
        return yaffs_trace_mask;
 }
@@ -277,7 +277,7 @@ static int yaffsfs_PutHandle(int handle)
 
 
 /*
- *  Stuff to search for a directory from a path
+ *  Stuff to handle names.
  */
 
 
@@ -300,7 +300,22 @@ int yaffsfs_IsPathDivider(YCHAR ch)
        return 0;
 }
 
+int yaffsfs_CheckNameLength(const char *name)
+{
+       int retVal = 0;         
 
+       int nameLength = yaffs_strnlen(name,YAFFS_MAX_NAME_LENGTH+1);
+               
+       if(nameLength == 0){
+               yaffsfs_SetError(-ENOENT);
+               retVal = -1;
+       } else if (nameLength > YAFFS_MAX_NAME_LENGTH){
+               yaffsfs_SetError(-ENAMETOOLONG);
+               retVal = -1;
+       }
+
+       return retVal;  
+}
 
 LIST_HEAD(yaffsfs_deviceList);
 
@@ -382,48 +397,6 @@ static struct yaffs_dev *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPat
        return retval;
 }
 
-#if 0
-static struct yaffs_dev *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
-{
-       yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
-       const YCHAR *leftOver;
-       const YCHAR *p;
-       struct yaffs_dev *retval = NULL;
-       int thisMatchLength;
-       int longestMatch = -1;
-
-       /*
-        * Check all configs, choose the one that:
-        * 1) Actually matches a prefix (ie /a amd /abc will not match
-        * 2) Matches the longest.
-        */
-       while(cfg && cfg->prefix && cfg->dev){
-               leftOver = path;
-               p = cfg->prefix;
-               thisMatchLength = 0;
-
-               while(*p &&  /* unmatched part of prefix */
-                     !(yaffsfs_IsPathDivider(*p) && (p[1] == 0)) &&
-                     *leftOver && yaffsfs_Match(*p,*leftOver)){
-                       p++;
-                       leftOver++;
-                       thisMatchLength++;
-               }
-
-
-               if((!*p || (yaffsfs_IsPathDivider(*p) && (p[1] == 0))) &&  /* end of prefix */
-                  (!*leftOver || yaffsfs_IsPathDivider(*leftOver)) && /* no more in this path name part */
-                  (thisMatchLength > longestMatch)){
-                       /* Matched prefix */
-                       *restOfPath = (YCHAR *)leftOver;
-                       retval = cfg->dev;
-                       longestMatch = thisMatchLength;
-               }
-               cfg++;
-       }
-       return retval;
-}
-#endif
 
 static struct yaffs_obj *yaffsfs_FindRoot(const YCHAR *path, YCHAR **restOfPath)
 {
@@ -1048,13 +1021,14 @@ int yaffs_truncate(const YCHAR *path,off_t new_size)
        else if(obj->variant_type != YAFFS_OBJECT_TYPE_FILE)
                yaffsfs_SetError(-EISDIR);
        else if(obj->my_dev->read_only)
+               yaffsfs_SetError(-EACCES);
+       else if(new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE)
                yaffsfs_SetError(-EINVAL);
        else
                result = yaffs_resize_file(obj,new_size);
 
        yaffsfs_Unlock();
 
-
        return (result) ? 0 : -1;
 }
 
@@ -1072,13 +1046,14 @@ int yaffs_ftruncate(int fd, off_t new_size)
                /* bad handle */
                yaffsfs_SetError(-EBADF);
        else if(obj->my_dev->read_only)
+               yaffsfs_SetError(-EACCES);
+       else if( new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE)
                yaffsfs_SetError(-EINVAL);
        else
                /* resize the file */
                result = yaffs_resize_file(obj,new_size);
        yaffsfs_Unlock();
 
-
        return (result) ? 0 : -1;
 
 }
@@ -1192,8 +1167,7 @@ int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
                yaffsfs_SetError(-EINVAL);
                rename_allowed = 0;
        } else if(olddir->my_dev != newdir->my_dev) {
-               /* oops must be on same device */
-               /* todo error */
+               /* Rename must be on same device */
                yaffsfs_SetError(-EXDEV);
                rename_allowed = 0;
        } else if(obj && obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) {
@@ -1682,6 +1656,11 @@ int yaffs_access(const YCHAR *path, int amode)
 
        int retval = 0;
 
+       if(amode & ~(R_OK | W_OK | X_OK)){
+               yaffsfs_SetError(-EINVAL);
+               return -1;
+       }
+
        yaffsfs_Lock();
 
        obj = yaffsfs_FindObject(NULL,path,0,1);
@@ -1844,7 +1823,7 @@ int yaffs_mount2(const YCHAR *path,int read_only)
        struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
-       T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Mounting %s" TENDSTR),path));
+       T(YAFFS_TRACE_MOUNT,(TSTR("yaffs: Mounting %s" TENDSTR),path));
 
        yaffsfs_Lock();
 
@@ -2296,7 +2275,6 @@ int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz)
        struct yaffs_obj *obj = NULL;
        int retVal;
 
-
        yaffsfs_Lock();
 
        obj = yaffsfs_FindObject(NULL,path,0,1);
@@ -2323,8 +2301,6 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath)
        struct yaffs_obj *obj = NULL;
        struct yaffs_obj *target = NULL;
        int retVal = 0;
-       int new_nameLength = 0;
-
 
        yaffsfs_Lock();
 
@@ -2356,15 +2332,7 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath)
                        retVal = -1;
                }
                
-               new_nameLength = yaffs_strnlen(newname,YAFFS_MAX_NAME_LENGTH+1);
-               
-               if(new_nameLength == 0){
-                       yaffsfs_SetError(-ENOENT);
-                       retVal = -1;
-               } else if (new_nameLength > YAFFS_MAX_NAME_LENGTH){
-                       yaffsfs_SetError(-ENAMETOOLONG);
-                       retVal = -1;
-               }
+               retVal = yaffsfs_CheckNameLength(newname);
                
                if(retVal == 0) {
                        link = yaffs_link_obj(newdir,newname,obj);
index e9e40f9..6eb30ef 100644 (file)
@@ -35,6 +35,8 @@
 #define NAME_MAX       256
 #endif
 
+#define YAFFS_MAX_FILE_SIZE (0x7FFFFFFF)
+
 
 struct yaffs_dirent{
     long d_ino;                 /* inode number */
@@ -180,8 +182,8 @@ void * yaffs_getdev(const YCHAR *path);
 int yaffs_dump_dev(const YCHAR *path);
 
 /* Trace control functions */
-int yaffs_set_trace(unsigned int tm);
-unsigned int yaffs_get_trace(void);
+unsigned  yaffs_set_trace(unsigned tm);
+unsigned  yaffs_get_trace(void);
 #endif
 
 
index 90dbefc..8f632ff 100644 (file)
@@ -48,6 +48,7 @@ extern unsigned int yaffs_wr_attempts;
 #define YAFFS_TRACE_SYNC               0x00100000
 #define YAFFS_TRACE_BACKGROUND         0x00200000
 #define YAFFS_TRACE_LOCK               0x00400000
+#define YAFFS_TRACE_MOUNT              0x00800000
 
 #define YAFFS_TRACE_ERROR              0x40000000
 #define YAFFS_TRACE_BUG                        0x80000000