@@ -49,7 +49,7 @@ void test() {
4949 int err ;
5050 int lastctime ;
5151 struct stat s ;
52-
52+
5353 //
5454 // chmod a file
5555 //
@@ -60,12 +60,12 @@ void test() {
6060 sleep (1 );
6161
6262 // do the actual chmod
63- err = chmod ("file" , 0200 );
63+ err = chmod ("file" , S_IWUSR );
6464 assert (!err );
6565
6666 memset (& s , 0 , sizeof s );
6767 stat ("file" , & s );
68- assert (s .st_mode == (0200 | S_IFREG ));
68+ assert (s .st_mode == (S_IWUSR | S_IFREG ));
6969 assert (s .st_ctime != lastctime );
7070
7171 //
@@ -74,26 +74,25 @@ void test() {
7474 lastctime = s .st_ctime ;
7575 sleep (1 );
7676
77- err = fchmod (open ("file" , O_WRONLY ), 0100 );
77+ err = fchmod (open ("file" , O_WRONLY ), S_IXUSR );
7878 assert (!err );
7979
8080 memset (& s , 0 , sizeof s );
8181 stat ("file" , & s );
82- assert (s .st_mode == (0100 | S_IFREG ));
82+ assert (s .st_mode == (S_IXUSR | S_IFREG ));
8383 assert (s .st_ctime != lastctime );
8484
85-
8685 //
8786 // fchmodat a file
8887 //
8988 lastctime = s .st_ctime ;
9089 sleep (1 );
91- err = fchmodat (AT_FDCWD , "otherfile" , 0100 , 0 );
90+ err = fchmodat (AT_FDCWD , "otherfile" , S_IXUSR , 0 );
9291 assert (!err );
9392
9493 memset (& s , 0 , sizeof s );
9594 stat ("otherfile" , & s );
96- assert (s .st_mode == (0100 | S_IFREG ));
95+ assert (s .st_mode == (S_IXUSR | S_IFREG ));
9796 assert (s .st_ctime != lastctime );
9897
9998 //
@@ -106,23 +105,23 @@ void test() {
106105 sleep (1 );
107106
108107 // do the actual chmod
109- err = chmod ("folder" , 0300 );
108+ err = chmod ("folder" , S_IWUSR | S_IXUSR );
110109 assert (!err );
111110 memset (& s , 0 , sizeof s );
112111 stat ("folder" , & s );
113- assert (s .st_mode == (0300 | S_IFDIR ));
112+ assert (s .st_mode == (S_IWUSR | S_IXUSR | S_IFDIR ));
114113 assert (s .st_ctime != lastctime );
115114
116115#ifndef WASMFS // TODO https://github.com/emscripten-core/emscripten/issues/15948
117116 //
118117 // chmod a symlink's target
119118 //
120- err = chmod ("file-link" , 0400 );
119+ err = chmod ("file-link" , S_IRUSR );
121120 assert (!err );
122121
123122 // make sure the file it references changed
124123 stat ("file-link" , & s );
125- assert (s .st_mode == (0400 | S_IFREG ));
124+ assert (s .st_mode == (S_IRUSR | S_IFREG ));
126125
127126 // but the link didn't
128127 lstat ("file-link" , & s );
@@ -131,12 +130,14 @@ void test() {
131130 //
132131 // chmod the actual symlink
133132 //
134- err = lchmod ("file-link" , 0500 );
135- assert (!err );
133+ err = lchmod ("file-link" , S_IRUSR | S_IXUSR );
134+ // On linux lchmod is not supported so allow that here.
135+ assert (!err || errno == ENOTSUP );
136+ printf ("lchmod -> %s\n" , strerror (errno ));
136137
137138 // make sure the file it references didn't change
138139 stat ("file-link" , & s );
139- assert (s .st_mode == (0400 | S_IFREG ));
140+ assert (s .st_mode == (S_IRUSR | S_IFREG ));
140141#endif // WASMFS
141142
142143 puts ("success" );
0 commit comments