Merge branch 'big-files': Merge in large file support
[yaffs2.git] / direct / timothy_tests / quick_tests / test_yaffs_fchmod_EROFS.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
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.
12  */
13
14 #include "test_yaffs_fchmod_EROFS.h"
15 static int handle = -1;
16
17 int test_yaffs_fchmod_EROFS(void)
18 {
19         int error = 0;
20         int output = 0;
21         if (EROFS_setup() < 0 ){
22                 return -1;
23         }
24         handle = yaffs_open(FILE_PATH,O_CREAT  ,S_IREAD  );
25         if (handle<0){
26                 print_message("failed to open file\n",2);
27                 return -1;
28         }
29
30
31
32         output = yaffs_fchmod(handle,S_IREAD|S_IWRITE);
33
34         if (output<0){
35                 error=yaffs_get_error();
36                 if (abs(error)==EROFS){
37                         return 1;
38                 } else {
39                         print_message("different error than expected\n",2);
40                         return -1;
41                 }
42         } else {
43                 print_message("chmoded with EROFS (which is a bad thing)\n",2);
44                 return -1;
45         }
46
47
48 }
49
50 int test_yaffs_fchmod_EROFS_clean(void)
51 {
52         int output =-1;
53         if (handle >= 0) {
54                 output= yaffs_close(handle);
55         }
56         return (EROFS_clean() && output);
57 }