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.
13 #include "yaffs_test_write.h"
15 int yaffs_test_write(arg_temp *args_struct)
19 int output=0,output2=0;
21 struct yaffs_stat yaffs_stat_struct;
22 join_paths(yaffs_struct.root_path,args_struct->string1, path );
23 sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1);
24 print_message(3,message);
25 printf("mode S_IREAD %d S_IWRITE %d\n",(args_struct->char2 & S_IREAD),(args_struct->char2 & S_IWRITE));
26 handle=yaffs_open(path,((args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND))|O_RDWR),(args_struct->char2&(S_IREAD|S_IWRITE)));
27 printf("handle %d\n",handle);
29 print_message(3,"failed to open a handle\n");
30 return -1; //handle failed to open
33 /* output=yaffs_fstat(handle,&yaffs_stat_struct);
35 sprintf(message,"failed to stat the file\n");
36 print_message(3,message);
39 sprintf(message,"stated the file\n");
40 print_message(3,message);
41 sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE)));
42 print_message(3,message);
43 sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE));
44 print_message(3,message);
47 sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2));
48 print_message(3,message);
50 output=yaffs_write(handle,&args_struct->string2,strlen(args_struct->string2));
52 /* print_message(3,"\n wrote to the file\n");
53 output2=yaffs_fstat(handle,&yaffs_stat_struct);
55 sprintf(message,"failed to stat the file\n");
56 print_message(3,message);
59 sprintf(message,"stated the file\n");
60 print_message(3,message);
61 sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE)));
62 print_message(3,message);
63 sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE));
64 print_message(3,message);
66 */ yaffs_close(handle);
67 /* print_message(3,"\n closing the file\n");
68 output2=yaffs_stat(path,&yaffs_stat_struct);
70 sprintf(message,"failed to stat the file\n");
71 print_message(3,message);
74 sprintf(message,"stated the file\n");
75 print_message(3,message);
76 sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE)));
77 print_message(3,message);
78 sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE));
79 print_message(3,message);