Commit efc1f045 authored by Steven Murray's avatar Steven Murray
Browse files

bug #105122: RFE: Add -f option to taped

Fixed.
parent 3f1ef6a4
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
.SH NAME .SH NAME
taped \- starts the tape daemon taped \- starts the tape daemon
.SH SYNOPSIS .SH SYNOPSIS
.B /usr/bin/taped .B /usr/bin/taped [-f|-h]
.SH DESCRIPTION .SH DESCRIPTION
.LP .LP
The The
...@@ -188,6 +188,13 @@ connected to AIX or Linux platforms, fast tape positionning is used. ...@@ -188,6 +188,13 @@ connected to AIX or Linux platforms, fast tape positionning is used.
.RE .RE
.LP .LP
If a tape drive supports several densities, there must be one line per density. If a tape drive supports several densities, there must be one line per density.
.SH OPTIONS
.TP
.BI -f
Remain in the foreground.
.TP
.BI -h
Print the usage message.
.SH FILES .SH FILES
.TP 1.5i .TP 1.5i
.B /etc/castor/castor.conf .B /etc/castor/castor.conf
......
...@@ -459,14 +459,107 @@ int tpd_main() { ...@@ -459,14 +459,107 @@ int tpd_main() {
} }
} }
int main(int argc, /**
char **argv) * Determines whether or not the command line is valid.
{ *
(void)argc; * @return 1 if the command line is valid, else 0.
(void)argv; */
if ((maxfds = Cinitdaemon ("taped", wait4child)) < 0) int cmd_line_is_valid(const int argc, const char *const *const argv) {
exit (1); // If there are no command-line arguments
exit (tpd_main()); if(1 == argc) {
return 1; // The command line is valid
}
// If there is one command-line argument and it is "-f"
if(2 == argc && 0 == strcmp("-f", argv[1])) {
return 1; // The command line is valid
}
// If there is one command-line argument and it is "-h"
if(2 == argc && 0 == strcmp("-h", argv[1])) {
return 1; // The command line is valid
}
// Reaching here means the command line is not valid
return 0;
}
/**
* Determines whether or not the help/usage message of taped should be
* printed.
*
* @return 1 if the help/usage message should be printed, else 0.
*/
int help_should_be_printed(const int argc, const char *const *const argv) {
int i = 0;
// For each command-line argument
for(i = 1; i<argc; i++) {
// Return 1 if the argument is "-h"
if(0 == strcmp("-h", argv[i])) {
return 1;
}
}
// Return 0 indicating "-h" was not found
return 0;
}
/**
* Prints the command-line syntax of taped to the specified stream.
*
* @param stream The stream to be printed to.
*/
void print_help(FILE *stream) {
fprintf(stream, "Usage:\n");
fprintf(stream, "\ttaped [-f|-h]\n");
fprintf(stream, "\n");
fprintf(stream, "Where:\n");
fprintf(stream, "\t-f\tRemain in the foreground\n");
fprintf(stream, "\t-h\tPrint this usage message\n");
fprintf(stream, "\n");
}
/**
* Determine whether or not the taped daemon should remain in the foreground.
*
* @return 1 if taped daemon should run in the foreground, else 0.
*/
int taped_should_remain_in_the_foreground(const int argc,
const char *const *const argv) {
int i = 0;
// For each command-line argument
for(i = 1; i<argc; i++) {
// Return 1 if the argument is "-f"
if(0 == strcmp("-f", argv[i])) {
return 1;
}
}
// Return 0 indicating "-f" was not found
return 0;
}
int main(const int argc, const char *const *const argv) {
if(!cmd_line_is_valid(argc, argv)) {
fprintf(stderr, "Invalid command-line arguments\n\n");
print_help(stderr);
return 0;
}
if(help_should_be_printed(argc, argv)) {
print_help(stdout);
return 0;
}
if(!taped_should_remain_in_the_foreground(argc, argv)) {
if ((maxfds = Cinitdaemon ("taped", wait4child)) < 0) {
return 1;
}
}
return tpd_main();
} }
int chk_den(struct tptab *tunp, int chk_den(struct tptab *tunp,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment