@@ -18,7 +18,9 @@ void write_first_block(FILE *out) {
1818 fwrite (block .bytes , 1 , sizeof (block .bytes ), out );
1919}
2020
21- void write_file (int file_id , FILE * outfile , int * outfile_nextdata_block , const char * filename , FILE * srcfile ) {
21+ void write_file (int file_id , FILE * outfile , int * outfile_nextdata_block ,
22+ const char * filename , FILE * srcfile ,
23+ int is_executable ) {
2224 fseek (srcfile , 0L , SEEK_END );
2325 int file_size = ftell (srcfile );
2426 rewind (srcfile );
@@ -27,6 +29,10 @@ void write_file(int file_id, FILE *outfile, int *outfile_nextdata_block, const c
2729 strncpy (entry .content .filename , filename , sizeof (entry .content .filename ));
2830 entry .content .filesize = file_size ;
2931 entry .content .start_block_id = (* outfile_nextdata_block );
32+ entry .content .flags = 0 ;
33+ if (is_executable ) {
34+ entry .content .flags |= FFS_FILE_FLAG_EXECUTABLE ;
35+ }
3036
3137 // Write file entry
3238 fseek (outfile , FILEENTRY_LOCATION (file_id ), SEEK_SET );
@@ -88,9 +94,10 @@ int create_partition(char *src_dir, char *out_filepath) {
8894 fprintf ("skipping non-regular file '%s': %d" , buffer_filename , file_stat .st_mode );
8995 continue ;
9096 }
97+ int is_executable = file_stat .st_mode & S_IXUSR ;
9198
9299 FILE * file_src = fopen (buffer_filename , "rb" );
93- write_file (file_id ++ , out , & outfile_nextdata_block , de -> d_name , file_src );
100+ write_file (file_id ++ , out , & outfile_nextdata_block , de -> d_name , file_src , is_executable );
94101 fclose (file_src );
95102 }
96103 while (file_id < FS_FFS_FILEENTRY_COUNT ) {
0 commit comments