@@ -36,7 +36,7 @@ static int64 blocks = 0;
3636static int64 badblocks = 0 ;
3737static ControlFileData * ControlFile ;
3838
39- static char * only_relfilenode = NULL ;
39+ static char * only_filenode = NULL ;
4040static bool do_sync = true;
4141static bool verbose = false;
4242static bool showprogress = false;
@@ -76,16 +76,16 @@ usage(void)
7676 printf (_ ("Usage:\n" ));
7777 printf (_ (" %s [OPTION]... [DATADIR]\n" ), progname );
7878 printf (_ ("\nOptions:\n" ));
79- printf (_ (" [-D, --pgdata=]DATADIR data directory\n" ));
80- printf (_ (" -c, --check check data checksums (default)\n" ));
81- printf (_ (" -d, --disable disable data checksums\n" ));
82- printf (_ (" -e, --enable enable data checksums\n" ));
83- printf (_ (" -N , --no-sync do not wait for changes to be written safely to disk \n" ));
84- printf (_ (" -P , --progress show progress information \n" ));
85- printf (_ (" -v , --verbose output verbose messages \n" ));
86- printf (_ (" -r RELFILENODE check only relation with specified relfilenode \n" ));
87- printf (_ (" -V, --version output version information, then exit\n" ));
88- printf (_ (" -?, --help show this help, then exit\n" ));
79+ printf (_ (" [-D, --pgdata=]DATADIR data directory\n" ));
80+ printf (_ (" -c, --check check data checksums (default)\n" ));
81+ printf (_ (" -d, --disable disable data checksums\n" ));
82+ printf (_ (" -e, --enable enable data checksums\n" ));
83+ printf (_ (" -f , --filenode=FILENODE check only relation with specified filenode \n" ));
84+ printf (_ (" -N , --no-sync do not wait for changes to be written safely to disk \n" ));
85+ printf (_ (" -P , --progress show progress information \n" ));
86+ printf (_ (" -v, --verbose output verbose messages \n" ));
87+ printf (_ (" -V, --version output version information, then exit\n" ));
88+ printf (_ (" -?, --help show this help, then exit\n" ));
8989 printf (_ ("\nIf no data directory (DATADIR) is specified, "
9090 "the environment variable PGDATA\nis used.\n\n" ));
9191 printf (_ ("Report bugs to <pgsql-bugs@lists.postgresql.org>.\n" ));
@@ -318,7 +318,7 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly)
318318 /*
319319 * Cut off at the segment boundary (".") to get the segment number
320320 * in order to mix it into the checksum. Then also cut off at the
321- * fork boundary, to get the relfilenode the file belongs to for
321+ * fork boundary, to get the filenode the file belongs to for
322322 * filtering.
323323 */
324324 strlcpy (fnonly , de -> d_name , sizeof (fnonly ));
@@ -339,8 +339,8 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly)
339339 if (forkpath != NULL )
340340 * forkpath ++ = '\0' ;
341341
342- if (only_relfilenode && strcmp (only_relfilenode , fnonly ) != 0 )
343- /* Relfilenode not to be included */
342+ if (only_filenode && strcmp (only_filenode , fnonly ) != 0 )
343+ /* filenode not to be included */
344344 continue ;
345345
346346 dirsize += st .st_size ;
@@ -371,6 +371,7 @@ main(int argc, char *argv[])
371371 {"pgdata" , required_argument , NULL , 'D' },
372372 {"disable" , no_argument , NULL , 'd' },
373373 {"enable" , no_argument , NULL , 'e' },
374+ {"filenode" , required_argument , NULL , 'f' },
374375 {"no-sync" , no_argument , NULL , 'N' },
375376 {"progress" , no_argument , NULL , 'P' },
376377 {"verbose" , no_argument , NULL , 'v' },
@@ -400,7 +401,7 @@ main(int argc, char *argv[])
400401 }
401402 }
402403
403- while ((c = getopt_long (argc , argv , "cD:deNPr :v" , long_options , & option_index )) != -1 )
404+ while ((c = getopt_long (argc , argv , "cD:deNPf :v" , long_options , & option_index )) != -1 )
404405 {
405406 switch (c )
406407 {
@@ -413,6 +414,14 @@ main(int argc, char *argv[])
413414 case 'e' :
414415 mode = PG_MODE_ENABLE ;
415416 break ;
417+ case 'f' :
418+ if (atoi (optarg ) == 0 )
419+ {
420+ pg_log_error ("invalid filenode specification, must be numeric: %s" , optarg );
421+ exit (1 );
422+ }
423+ only_filenode = pstrdup (optarg );
424+ break ;
416425 case 'N' :
417426 do_sync = false;
418427 break ;
@@ -422,14 +431,6 @@ main(int argc, char *argv[])
422431 case 'D' :
423432 DataDir = optarg ;
424433 break ;
425- case 'r' :
426- if (atoi (optarg ) == 0 )
427- {
428- pg_log_error ("invalid relfilenode specification, must be numeric: %s" , optarg );
429- exit (1 );
430- }
431- only_relfilenode = pstrdup (optarg );
432- break ;
433434 case 'P' :
434435 showprogress = true;
435436 break ;
@@ -465,10 +466,10 @@ main(int argc, char *argv[])
465466 exit (1 );
466467 }
467468
468- /* Relfilenode checking only works in --check mode */
469- if (mode != PG_MODE_CHECK && only_relfilenode )
469+ /* filenode checking only works in --check mode */
470+ if (mode != PG_MODE_CHECK && only_filenode )
470471 {
471- pg_log_error ("relfilenode option only possible with --check" );
472+ pg_log_error ("--filenode option only possible with --check" );
472473 fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ),
473474 progname );
474475 exit (1 );
0 commit comments