Craig Johnston
2006-Dec-11 20:29 UTC
[syslinux] Add option to TFTP client to ignore ':' in file name (re-submit)
Re-submitted for 0.44. b.t.w. I notice that the new 0.44 'R' option is not documented in the tftp man page. ----------------------------------------- I have encountered a situation where I would like to use tftp-hpa to retrieve a file that resides within an absolute path containing a ':' character. Ala, "tftp foobar -c get C:2/tftpdir/myfile". Since the tftp client automatically converts the host:file syntax, I get an error "tftp: C: Unknown host". I made a chage to the tftp client code to add a literal mode (-l), that prevents the special treatment of the ':' character. I've attached a patch set for main.c and tftp.1.in for your consideration. I'm not sure how many folks run into this, but it may be somewhat common for VxWorks and perhaps MSDOS users. Thanks, Craig Johnston *** tftp-hpa-0.44/tftp/main.c 2006-12-05 14:39:41.000000000 -0800 --- tftp-hpa-0.44x/tftp/main.c 2006-12-11 11:54:19.445313000 -0800 *************** *** 89,94 **** --- 89,95 ---- u_short port; int trace; int verbose; + int literal; int connected; const struct modes *mode; #ifdef WITH_READLINE *************** *** 119,124 **** --- 120,126 ---- void settrace (int, char **); void setverbose (int, char **); void status (int, char **); + void setliteral (int, char **); static void command (void); *************** *** 157,162 **** --- 159,167 ---- { "trace", "toggle packet tracing", settrace }, + { "literal", + "toggle literal mode, ignore ':' in file name", + setliteral }, { "status", "show current status", status }, *************** *** 190,196 **** static inline void usage(int errcode) { ! fprintf(stderr, "Usage: %s [-v][-m mode] [host [port]] [-c command]\n", program); exit(errcode); } --- 195,201 ---- static inline void usage(int errcode) { ! fprintf(stderr, "Usage: %s [-v][-l][-m mode] [host [port]] [-c command]\n", program); exit(errcode); } *************** *** 223,228 **** --- 228,236 ---- /* Print version and configuration to stdout and exit */ printf("%s\n", TFTP_CONFIG_STR); exit(0); + case 'l': + literal = 1; + break; case 'm': if ( ++arg >= argc ) usage(EX_USAGE); *************** *** 502,508 **** return; } targ = argv[argc - 1]; ! if (strchr(argv[argc - 1], ':')) { struct hostent *hp; for (n = 1; n < argc - 1; n++) --- 510,516 ---- return; } targ = argv[argc - 1]; ! if (!literal && strchr(argv[argc - 1], ':')) { struct hostent *hp; for (n = 1; n < argc - 1; n++) *************** *** 591,604 **** } if (!connected) { for (n = 1; n < argc ; n++) ! if (strchr(argv[n], ':') == 0) { getusage(argv[0]); return; } } for (n = 1; n < argc ; n++) { src = strchr(argv[n], ':'); ! if (src == NULL) src = argv[n]; else { struct hostent *hp; --- 599,612 ---- } if (!connected) { for (n = 1; n < argc ; n++) ! if (literal || strchr(argv[n], ':') == 0) { getusage(argv[0]); return; } } for (n = 1; n < argc ; n++) { src = strchr(argv[n], ':'); ! if (literal || src == NULL) src = argv[n]; else { struct hostent *hp; *************** *** 700,705 **** --- 708,721 ---- } void + setliteral(int argc, char *argv[]) + { + (void)argc; (void)argv; /* Quiet unused warning */ + literal = !literal; + printf("Literal mode %s.\n", literal ? "on" : "off"); + } + + void status(int argc, char *argv[]) { (void)argc; (void)argv; /* Quiet unused warning */ *************** *** 707,714 **** printf("Connected to %s.\n", hostname); else printf("Not connected.\n"); ! printf("Mode: %s Verbose: %s Tracing: %s\n", mode->m_mode, ! verbose ? "on" : "off", trace ? "on" : "off"); printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n", rexmtval, maxtimeout); } --- 723,730 ---- printf("Connected to %s.\n", hostname); else printf("Not connected.\n"); ! printf("Mode: %s Verbose: %s Tracing: %s Literal: %s\n", mode->m_mode, ! verbose ? "on" : "off", trace ? "on" : "off", literal ? "on" : "off"); printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n", rexmtval, maxtimeout); } *** tftp-hpa-0.44/tftp/tftp.1.in 2006-12-05 14:39:41.000000000 -0800 --- tftp-hpa-0.44x/tftp/tftp.1.in 2006-12-11 12:18:42.101067000 -0800 *************** *** 60,65 **** --- 60,68 ---- Execute \fIcommand\fP as if it had been entered on the tftp prompt. Must be specified last on the command line. .TP + .B \-l + Default to literal mode. Used to avoid special processing of ':' in a file name. + .TP \fB\-m\fP \fImode\fP Set the default transfer mode to \fImode\fP. This is usually used with \-c. .TP *************** *** 119,125 **** .I "host:filename" to specify both a host and filename at the same time. If the latter form is used, the last hostname specified becomes the default for ! future transfers. .TP \fBmode\fP \fItransfer-mode\fP Specify the mode for transfers; --- 122,133 ---- .I "host:filename" to specify both a host and filename at the same time. If the latter form is used, the last hostname specified becomes the default for ! future transfers. Enable ! .B literal ! mode to prevent special treatment of the ':' character (e.g. C:\\dir\\file). ! .TP ! .B literal ! Toggle literal mode. When set, this mode prevents special treatment of ':' in filenames. .TP \fBmode\fP \fItransfer-mode\fP Specify the mode for transfers; *************** *** 151,157 **** transfers. If the remote-directory form is used, the remote host is assumed to be a UNIX system or another system using .B / ! as directory separator. .TP .B quit Exit --- 159,167 ---- transfers. If the remote-directory form is used, the remote host is assumed to be a UNIX system or another system using .B / ! as directory separator. Enable ! .B literal ! mode to prevent special treatment of the ':' character (e.g. C:\\dir\\file). .TP .B quit Exit
Geert Stappers
2007-Jan-13 13:48 UTC
[syslinux] Add option to TFTP client to ignore ':' in file name (re-submit)
Op 11-12-2006 om 12:29 schreef Craig Johnston:> > I have encountered a situation where I would like to use tftp-hpa to > > retrieve a file that resides within an absolute path containing a ':' > > character. Ala, "tftp foobar -c get C:2/tftpdir/myfile". Since the > > tftp client automatically converts the host:file syntax, I get an > > error "tftp: C: Unknown host". > > > > I made a chage to the tftp client code to add a literal mode (-l), > > that prevents the special treatment of the ':' character. I've > > attached a patch set for main.c and tftp.1.in for your consideration. > > I'm not sure how many folks run into this, but it may be somewhat > > common for VxWorks and perhaps MSDOS users. > > > > Thanks, > > Craig Johnston > ----------------------------------------- > Re-submitted for 0.44.As there wasn't any follow-up yet, I suggest to send an unified diff ( using the flag -u with diff ) as another attemp to get feedback on the valid contribution[1].> b.t.w. I notice that the new 0.44 'R' option is not documented in the > tftp man page.I think we are all too busy with other stuff. Cheers Geert Stappers [1] A patch is IMHO the best compliment a program can get, because it says: "the program is used, reviewed and enhanced" The least thing that should be done, is providing comment on the patch.
H. Peter Anvin
2007-Jan-13 18:31 UTC
[syslinux] Add option to TFTP client to ignore ':' in file name (re-submit)
Craig Johnston wrote:> Re-submitted for 0.44. > b.t.w. I notice that the new 0.44 'R' option is not documented in the > tftp man page. > ----------------------------------------- > I have encountered a situation where I would like to use tftp-hpa to > retrieve a file that resides within an absolute path containing a ':' > character. Ala, "tftp foobar -c get C:2/tftpdir/myfile". Since the > tftp client automatically converts the host:file syntax, I get an > error "tftp: C: Unknown host". > > I made a chage to the tftp client code to add a literal mode (-l), > that prevents the special treatment of the ':' character. I've > attached a patch set for main.c and tftp.1.in for your consideration. > I'm not sure how many folks run into this, but it may be somewhat > common for VxWorks and perhaps MSDOS users. >I thought I commented on this already. This patch does not apply; it's either corrupted in transit or stale (or both.) Furthermore, it's not a unified diff (diff -u) which means a lot of the automated tools won't take it. Please resend as a unified diff against 0.46, as I do want to include this feature. -hpa