2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
16 #define YAFFS_MOUNT_POINT "/yaffs2/"
17 #define FILE_PATH "/yaffs2/foo.txt"
20 int simulate_power_failure = 0;
29 printf("\n\n starting test\n");
31 output = yaffs_mount(YAFFS_MOUNT_POINT);
34 printf("yaffs mounted: %s\n",YAFFS_MOUNT_POINT);
36 printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT);
40 output = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
42 printf("file created: %s\n",FILE_PATH);
44 printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH);
47 output2 = yaffs_close(output);
49 printf("file closed: %s\n",FILE_PATH);
51 printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH);
54 //unmount and remount the mount point.
55 output = yaffs_unmount(YAFFS_MOUNT_POINT);
57 printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT);
59 printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT);
62 output = yaffs_mount(YAFFS_MOUNT_POINT);
64 printf("yaffs mounted: %s\n",YAFFS_MOUNT_POINT);
66 printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT);
69 //now open the existing file.
70 output = yaffs_open(FILE_PATH, O_RDWR, S_IREAD | S_IWRITE);
72 printf("file created: %s\n",FILE_PATH);
74 printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH);
78 output2 = yaffs_close(output);
80 printf("file closed: %s\n",FILE_PATH);
82 printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH);
86 //unmount the mount point.
87 output = yaffs_unmount(YAFFS_MOUNT_POINT);
89 printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT);
91 printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT);
95 printf("test passed. yay!\n");