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 "/yaffs2/"
16 #define FILE_PATH "/yaffs2/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 mounted: %s\n",YAFFS_MOUNT_POINT);
35 printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT);
39 output = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
41 printf("file created: %s\n",FILE_PATH);
43 printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH);
46 output2 = yaffs_close(output);
48 printf("file closed: %s\n",FILE_PATH);
50 printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH);
53 //unmount and remount the mount point.
54 output = yaffs_unmount(YAFFS_MOUNT_POINT);
56 printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT);
58 printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT);
61 output = yaffs_mount(YAFFS_MOUNT_POINT);
63 printf("yaffs mounted: %s\n",YAFFS_MOUNT_POINT);
65 printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT);
68 //now open the existing file.
69 output = yaffs_open(FILE_PATH, O_RDWR, S_IREAD | S_IWRITE);
71 printf("file created: %s\n",FILE_PATH);
73 printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH);
77 output2 = yaffs_close(output);
79 printf("file closed: %s\n",FILE_PATH);
81 printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH);
85 //unmount the mount point.
86 output = yaffs_unmount(YAFFS_MOUNT_POINT);
88 printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT);
90 printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT);
94 printf("test passed. yay!\n");