@@ -758,57 +758,22 @@ dir_check_file(pgFile *file, bool backup_logs)
758758return CHECK_FALSE ;
759759else if (isdigit (file -> name [0 ]))
760760{
761- char * fork_name ;
762- int len ;
763- char suffix [MAXPGPATH ];
761+ set_forkname (file );
764762
765- fork_name = strstr (file -> name ,"_" );
766- if (fork_name )
767- {
768- /* Auxiliary fork of the relfile */
769- if (strcmp (fork_name ,"_vm" )== 0 )
770- file -> forkName = vm ;
771-
772- else if (strcmp (fork_name ,"_fsm" )== 0 )
773- file -> forkName = fsm ;
774-
775- else if (strcmp (fork_name ,"_cfm" )== 0 )
776- file -> forkName = cfm ;
777-
778- else if (strcmp (fork_name ,"_ptrack" )== 0 )
779- file -> forkName = ptrack ;
780-
781- else if (strcmp (fork_name ,"_init" )== 0 )
782- file -> forkName = init ;
783-
784- // extract relOid for certain forks
785- if (file -> forkName == vm ||
786- file -> forkName == fsm ||
787- file -> forkName == init ||
788- file -> forkName == cfm )
789- {
790- // sanity
791- if (sscanf (file -> name ,"%u_*" ,& (file -> relOid ))!= 1 )
792- file -> relOid = 0 ;
793- }
763+ if (file -> forkName == ptrack )/* Compatibility with left-overs from ptrack1 */
764+ return CHECK_FALSE ;
765+ else if (file -> forkName != none )
766+ return CHECK_TRUE ;
794767
795- /* Do not backup ptrack files */
796- if (file -> forkName == ptrack )
797- return CHECK_FALSE ;
798- }
799- else
768+ /* Set is_datafile flag */
800769{
770+ char suffix [MAXFNAMELEN ];
801771
802- len = strlen (file -> name );
803- /* reloid.cfm */
804- if (len > 3 && strcmp (file -> name + len - 3 ,"cfm" )== 0 )
805- return CHECK_TRUE ;
806-
772+ /* check if file is datafile */
807773sscanf_res = sscanf (file -> name ,"%u.%d.%s" ,& (file -> relOid ),
808774& (file -> segno ),suffix );
809- if (sscanf_res == 0 )
810- elog (ERROR ,"Cannot parse file name \"%s\"" ,file -> name );
811- else if (sscanf_res == 1 || sscanf_res == 2 )
775+ Assert (sscanf_res > 0 );/* since first char is digit */
776+ if (sscanf_res == 1 || sscanf_res == 2 )
812777file -> is_datafile = true;
813778}
814779}
@@ -1954,3 +1919,35 @@ pfilearray_clear_locks(parray *file_list)
19541919pg_atomic_clear_flag (& file -> lock );
19551920}
19561921}
1922+
1923+ /* Set forkName if possible */
1924+ void
1925+ set_forkname (pgFile * file )
1926+ {
1927+ int name_len = strlen (file -> name );
1928+
1929+ /* Auxiliary fork of the relfile */
1930+ if (name_len > 3 && strcmp (file -> name + name_len - 3 ,"_vm" )== 0 )
1931+ file -> forkName = vm ;
1932+
1933+ else if (name_len > 4 && strcmp (file -> name + name_len - 4 ,"_fsm" )== 0 )
1934+ file -> forkName = fsm ;
1935+
1936+ else if (name_len > 4 && strcmp (file -> name + name_len - 4 ,".cfm" )== 0 )
1937+ file -> forkName = cfm ;
1938+
1939+ else if (name_len > 5 && strcmp (file -> name + name_len - 5 ,"_init" )== 0 )
1940+ file -> forkName = init ;
1941+
1942+ else if (name_len > 7 && strcmp (file -> name + name_len - 7 ,"_ptrack" )== 0 )
1943+ file -> forkName = ptrack ;
1944+
1945+ // extract relOid for certain forks
1946+
1947+ if ((file -> forkName == vm ||
1948+ file -> forkName == fsm ||
1949+ file -> forkName == init ||
1950+ file -> forkName == cfm )&&
1951+ (sscanf (file -> name ,"%u*" ,& (file -> relOid ))!= 1 ))
1952+ file -> relOid = 0 ;
1953+ }