test_yaffs_rename_dir.o test_yaffs_rename_dir_ENOENT.o test_yaffs_rename_dir_ENOENT2.o test_yaffs_rename_dir_to_file.o \
test_yaffs_rename_file_to_dir.o test_yaffs_rename_EEXISTS.o test_yaffs_rename_ELOOP_dir.o test_yaffs_rename_EROFS.o \
test_yaffs_rename_ENAMETOOLONG.o test_yaffs_rename_ENAMETOOLONG2.o test_yaffs_rename_NULL.o test_yaffs_rename_NULL2.o \
- test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o \
+ test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o test_yaffs_rename_to_null_file.o \
+ test_yaffs_rename_file_over_file.o test_yaffs_rename_dir_over_dir.o test_yaffs_rename_full_dir_over_dir.o test_yaffs_rename_ENOTEMPTY.o \
test_yaffs_lstat_NULL.o \
test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o \
test_yaffs_dup.o test_yaffs_dup_EBADF.o
#define FILE_TEXT_NBYTES 10
#define TEST_DIR "/yaffs2/test_dir"
#define DIR_PATH "/yaffs2/test_dir/new_directory"
-
+#define DIR_PATH2 "/yaffs2/test_dir/new_directory2"
+#define DIR_PATH2_FILE "/yaffs2/test_dir/new_directory2/foo"
#define SYMLINK_PATH "/yaffs2/test_dir/sym_foo"
#define HARD_LINK_PATH "/yaffs2/test_dir/hard_link"
/* warning do not define anything as FILE because there seems to be a conflict with stdio.h */
#define FILE_PATH "/yaffs2/test_dir/foo"
+#define FILE_PATH2 "/yaffs2/test_dir/foo2"
void join_paths(char *path1,char *path2,char *new_path );
void print_message(char *message,char print_level);
#include "test_yaffs_rename_ENAMETOOLONG2.h"
#include "test_yaffs_rename_NULL.h"
#include "test_yaffs_rename_NULL2.h"
+#include "test_yaffs_rename_file_over_file.h"
+#include "test_yaffs_rename_dir_over_dir.h"
+#include "test_yaffs_rename_to_null_file.h"
+#include "test_yaffs_rename_full_dir_over_dir.h"
+#include "test_yaffs_rename_ENOTEMPTY.h"
#include "test_yaffs_lstat.h"
#include "test_yaffs_lstat_ENOENT.h"
{test_yaffs_rename_ENAMETOOLONG2,test_yaffs_rename_ENAMETOOLONG2_clean,"test_yaffs_rename_ENAMETOOLONG2"},
{test_yaffs_rename_NULL,test_yaffs_rename_NULL_clean,"test_yaffs_rename_NULL"},
{test_yaffs_rename_NULL2,test_yaffs_rename_NULL2_clean,"test_yaffs_rename_NULL2"},
+ {test_yaffs_rename_to_null_file,test_yaffs_rename_to_null_file_clean,"test_yaffs_rename_to_null_file"},
+ {test_yaffs_rename_file_over_file,test_yaffs_rename_file_over_file_clean,"test_yaffs_rename_file_over_file"},
+ {test_yaffs_rename_dir_over_dir,test_yaffs_rename_dir_over_dir_clean,"test_yaffs_rename_dir_over_dir"},
+ {test_yaffs_rename_full_dir_over_dir,test_yaffs_rename_full_dir_over_dir_clean,"test_yaffs_rename_full_dir_over_dir"},
+ {test_yaffs_rename_ENOTEMPTY,test_yaffs_rename_ENOTEMPTY_clean,"test_yaffs_rename_ENOTEMPTY"},
{test_yaffs_lstat,test_yaffs_lstat_clean,"test_yaffs_lstat"},
{test_yaffs_lstat_ENOENT,test_yaffs_lstat_ENOENT_clean,"test_yaffs_lstat_ENOENT"},
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_ENOTEMPTY.h"
+
+int test_yaffs_rename_ENOTEMPTY(void)
+{
+
+ int output=0;
+ int error_code =0;
+
+ if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir\n",1);
+ return -1;
+ }
+ if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir2\n",1);
+ return -1;
+ }
+ if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){
+ print_message("failed to create file\n",1);
+ return -1;
+ }
+ output = yaffs_rename( DIR_PATH,DIR_PATH2 );
+ if (output<0){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==ENOTEMPTY){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ print_message("could not rename a directory over a nonempty directory (which is a bad thing)\n",2);
+ return -1;
+ }
+
+ return 1;
+
+}
+
+
+int test_yaffs_rename_ENOTEMPTY_clean(void)
+{
+ return 1;
+}
+
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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_RENAME_ENOTEMPTY_H__
+#define __TEST_YAFFS_RENAME_ENOTEMPTY_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_ENOTEMPTY(void);
+int test_yaffs_rename_ENOTEMPTY_clean(void);
+
+#endif
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_dir_over_dir.h"
+
+int test_yaffs_rename_dir_over_dir(void)
+{
+
+ int output=0;
+ int error_code =0;
+
+ if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir\n",1);
+ return -1;
+ }
+ if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir2\n",1);
+ return -1;
+ }
+ output = yaffs_rename(DIR_PATH ,DIR_PATH2 );
+ if (output<0){
+ print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2);
+ return -1;
+ }
+
+ return 1;
+
+}
+
+
+int test_yaffs_rename_dir_over_dir_clean(void)
+{
+ return 1;
+}
+
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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_RENAME_DIR_OVER_DIR_H__
+#define __TEST_YAFFS_RENAME_DIR_OVER_DIR_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_dir_over_dir(void);
+int test_yaffs_rename_dir_over_dir_clean(void);
+
+#endif
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_file_over_file.h"
+
+int test_yaffs_rename_file_over_file(void)
+{
+
+ int output=0;
+ int error_code =0;
+
+ if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
+ print_message("failed to create file\n",1);
+ return -1;
+ }
+ if (yaffs_close(yaffs_open(FILE_PATH2,O_CREAT | O_RDWR, FILE_MODE))==-1){
+ print_message("failed to create file\n",1);
+ return -1;
+ }
+ output = yaffs_rename(FILE_PATH ,FILE_PATH2 );
+ if (output<0){
+ print_message("could not rename a file over a file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+ return 1;
+
+}
+
+
+int test_yaffs_rename_file_over_file_clean(void)
+{
+ return 1;
+}
+
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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_RENAME_FILE_OVER_FILE_H__
+#define __test_yaffs_RENAME_FILE_OVER_FILE_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_file_over_file(void);
+int test_yaffs_rename_file_over_file_clean(void);
+
+#endif
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_full_dir_over_dir.h"
+
+int test_yaffs_rename_full_dir_over_dir(void)
+{
+
+ int output=0;
+ int error_code =0;
+
+ if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir\n",1);
+ return -1;
+ }
+ if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){
+ print_message("failed to create dir2\n",1);
+ return -1;
+ }
+ if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){
+ print_message("failed to create file\n",1);
+ return -1;
+ }
+ output = yaffs_rename( DIR_PATH2,DIR_PATH );
+ if (output<0){
+ print_message("could not rename a directory over a empty directory (which is a bad thing)\n",2);
+ return -1;
+ }
+
+ return 1;
+
+}
+
+
+int test_yaffs_rename_full_dir_over_dir_clean(void)
+{
+ return 1;
+}
+
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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_RENAME_FULL_DIR_OVER_DIR_H__
+#define __TEST_YAFFS_RENAME_FULL_DIR_OVER_DIR_H__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_full_dir_over_dir(void);
+int test_yaffs_rename_full_dir_over_dir_clean(void);
+
+#endif
--- /dev/null
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2011 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.
+ */
+
+
+#include "test_yaffs_rename_to_null_file.h"
+
+int test_yaffs_rename_to_null_file(void)
+{
+ int output=0;
+ int error_code =0;
+
+ if (0 != yaffs_access(DIR_PATH,0)) {
+ output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD);
+ if (output < 0) {
+ print_message("failed to create directory\n",2);
+ return -1;
+ }
+ }
+ output = yaffs_rename(FILE_PATH , NULL);
+ if (output<0){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==EFAULT){
+ return 1;
+ } else {
+ print_message("returned error does not match the the expected error\n",2);
+ return -1;
+ }
+ } else{
+ print_message("renamed to null path (which is a bad thing)\n",2);
+ return -1;
+ }
+}
+
+
+int test_yaffs_rename_to_null_file_clean(void)
+{
+ return 1;
+}
--- /dev/null
+#ifndef __test_yaffs_rename_NULL3_h__
+#define __test_yaffs_rename_NULL3_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_rename_to_null_file(void);
+int test_yaffs_rename_to_null_file_clean(void);
+
+#endif
+