2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Timothy Manning <timothy@yaffs.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
15 #define YAFFS_MOUNT_POINT "/yflash2/"
16 #define FILE_PATH "/yflash2/foo.txt"
19 int simulate_power_failure = 0;
28 printf("\n\n starting test\n");
30 output = yaffs_mount(YAFFS_MOUNT_POINT);
33 printf("yaffs correctly mounted: %s\n",YAFFS_MOUNT_POINT);
35 printf("error\n yaffs failed to mount: %s\n with error code %d\n",YAFFS_MOUNT_POINT, yaffs_get_error());
40 output = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
42 printf("yaffs correctly created a the file: %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("yaffs correctly closed the file: %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 correctly 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 correctly 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("yaffs correctly opened the file: %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("yaffs correctly closed the file: %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 correctly 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");