@@ -392,7 +392,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
392392 pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
393393
394394 /* if the entry was a directory, create it in the backup */
395- if (S_ISDIR ( file -> mode ) )
395+ if (file -> kind == PIO_KIND_DIRECTORY )
396396 {
397397 char dirpath [MAXPGPATH ];
398398
@@ -569,7 +569,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
569569 pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
570570
571571 /* TODO: sync directory ? */
572- if (S_ISDIR ( file -> mode ) )
572+ if (file -> kind == PIO_KIND_DIRECTORY )
573573 continue ;
574574
575575 if (file -> write_size <= 0 )
@@ -1837,7 +1837,7 @@ pg_stop_backup_write_file_helper(const char *path, const char *filename, const c
18371837 file = pgFileNew (full_filename , filename , true, 0 ,
18381838 FIO_BACKUP_HOST );
18391839
1840- if (S_ISREG ( file -> mode ) )
1840+ if (file -> kind == PIO_KIND_REGULAR )
18411841 {
18421842 file -> crc = pgFileGetCRC32C (full_filename , false);
18431843
@@ -1991,7 +1991,7 @@ backup_files(void *arg)
19911991 pgFile * prev_file = NULL ;
19921992
19931993 /* We have already copied all directories */
1994- if (S_ISDIR ( file -> mode ) )
1994+ if (file -> kind == PIO_KIND_DIRECTORY )
19951995 continue ;
19961996
19971997 if (arguments -> thread_num == 1 )
@@ -2046,9 +2046,9 @@ backup_files(void *arg)
20462046 }
20472047
20482048 /* Encountered some strange beast */
2049- if (! S_ISREG ( file -> mode ) )
2050- elog (WARNING , "Unexpected type %d of file \"%s\", skipping" ,
2051- file -> mode , from_fullpath );
2049+ if (file -> kind != PIO_KIND_REGULAR )
2050+ elog (WARNING , "Unexpected type %s of file \"%s\", skipping" ,
2051+ pio_file_kind2str ( file -> kind , from_fullpath ) , from_fullpath );
20522052
20532053 /* Check that file exist in previous backup */
20542054 if (current .backup_mode != BACKUP_MODE_FULL )
@@ -2121,7 +2121,7 @@ parse_filelist_filenames(parray *files, const char *root)
21212121 pgFile * file = (pgFile * ) parray_get (files , i );
21222122 int sscanf_result ;
21232123
2124- if (S_ISREG ( file -> mode ) &&
2124+ if (file -> kind == PIO_KIND_REGULAR &&
21252125 path_is_prefix_of_path (PG_TBLSPC_DIR , file -> rel_path ))
21262126 {
21272127 /*
@@ -2148,7 +2148,7 @@ parse_filelist_filenames(parray *files, const char *root)
21482148 }
21492149 }
21502150
2151- if (S_ISREG ( file -> mode ) && file -> tblspcOid != 0 &&
2151+ if (file -> kind == PIO_KIND_REGULAR && file -> tblspcOid != 0 &&
21522152 file -> name && file -> name [0 ])
21532153 {
21542154 if (file -> forkName == init )
@@ -2218,7 +2218,7 @@ set_cfs_datafiles(parray *files, const char *root, char *relative, size_t i)
22182218
22192219 if (strstr (prev_file -> rel_path , cfs_tblspc_path ) != NULL )
22202220 {
2221- if (S_ISREG ( prev_file -> mode ) && prev_file -> is_datafile )
2221+ if (prev_file -> kind == PIO_KIND_REGULAR && prev_file -> is_datafile )
22222222 {
22232223 elog (LOG , "Setting 'is_cfs' on file %s, name %s" ,
22242224 prev_file -> rel_path , prev_file -> name );
@@ -2375,7 +2375,7 @@ calculate_datasize_of_filelist(parray *filelist)
23752375 if (file -> external_dir_num != 0 || file -> excluded )
23762376 continue ;
23772377
2378- if (S_ISDIR ( file -> mode ) )
2378+ if (file -> kind == PIO_KIND_DIRECTORY )
23792379 {
23802380 // TODO is a dir always 4K?
23812381 bytes += 4096 ;
0 commit comments