wok annotate busybox/stuff/busybox-1.17.4-ris.u @ rev 7361

Up: busybox to 1.17.4.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Nov 23 03:15:08 2010 +0000 (2010-11-23)
parents
children
rev   line source
slaxemulator@7361 1 Add support for the Windows Remote Installation Service
slaxemulator@7361 2 --- busybox-1.17.1/networking/Config.src
slaxemulator@7361 3 +++ busybox-1.17.1/networking/Config.src
slaxemulator@7361 4 @@ -841,6 +841,15 @@
slaxemulator@7361 5 comment "Common options for tftp/tftpd"
slaxemulator@7361 6 depends on TFTP || TFTPD
slaxemulator@7361 7
slaxemulator@7361 8 +config FEATURE_TFTPD_RIS
slaxemulator@7361 9 + bool "Enable \"RIS\" support"
slaxemulator@7361 10 + default y
slaxemulator@7361 11 + depends on TFTPD
slaxemulator@7361 12 + help
slaxemulator@7361 13 + Add support for the Windows Remote Installation Service. This allows
slaxemulator@7361 14 + a client to get files starting with \ without respecting case.
slaxemulator@7361 15 + Each \ will be replaced by a /.
slaxemulator@7361 16 +
slaxemulator@7361 17 config FEATURE_TFTP_GET
slaxemulator@7361 18 bool "Enable 'tftp get' and/or tftpd upload code"
slaxemulator@7361 19 default y
slaxemulator@7361 20
slaxemulator@7361 21 --- busybox-1.17.1/networking/tftp.c
slaxemulator@7361 22 +++ busybox-1.17.1/networking/tftp.c
slaxemulator@7361 23 @@ -656,6 +656,59 @@
slaxemulator@7361 24 #undef remote_file
slaxemulator@7361 25 }
slaxemulator@7361 26
slaxemulator@7361 27 +#if ENABLE_FEATURE_TFTPD_RIS
slaxemulator@7361 28 +#include <dirent.h>
slaxemulator@7361 29 +
slaxemulator@7361 30 +static int lookup_entry(const char *search, char *unixpath);
slaxemulator@7361 31 +static void unixfilename(char *filename);
slaxemulator@7361 32 +
slaxemulator@7361 33 +// lookup search and concat real filename to unixpath
slaxemulator@7361 34 +static int lookup_entry(const char *search, char *unixpath)
slaxemulator@7361 35 +{
slaxemulator@7361 36 + int status = 0;
slaxemulator@7361 37 + DIR *dirp = opendir(unixpath[0] ? unixpath : ".");
slaxemulator@7361 38 +
slaxemulator@7361 39 + if (dirp != NULL) {
slaxemulator@7361 40 + struct dirent *entry;
slaxemulator@7361 41 +
slaxemulator@7361 42 + while ((entry = readdir(dirp))) {
slaxemulator@7361 43 + if (!strcasecmp(entry->d_name, search)) {
slaxemulator@7361 44 + if (unixpath[0]) strcat(unixpath, "/");
slaxemulator@7361 45 + strcat(unixpath, entry->d_name);
slaxemulator@7361 46 + status++;
slaxemulator@7361 47 + break;
slaxemulator@7361 48 + }
slaxemulator@7361 49 + }
slaxemulator@7361 50 + closedir(dirp);
slaxemulator@7361 51 + }
slaxemulator@7361 52 + return status;
slaxemulator@7361 53 +}
slaxemulator@7361 54 +
slaxemulator@7361 55 +// update filename with real file path found
slaxemulator@7361 56 +static void unixfilename(char *filename)
slaxemulator@7361 57 +{
slaxemulator@7361 58 + char unixpath[PATH_MAX];
slaxemulator@7361 59 + char *s = unixpath + 1;
slaxemulator@7361 60 + char *check = filename + 1;
slaxemulator@7361 61 + int len;
slaxemulator@7361 62 +
slaxemulator@7361 63 + for (unixpath[0] = 0; *check; len++, s += len, check += len) {
slaxemulator@7361 64 + char *seek = strchr(check, '\\');
slaxemulator@7361 65 +
slaxemulator@7361 66 + if (!seek) { // basename of filename
slaxemulator@7361 67 + if (lookup_entry(check, unixpath))
slaxemulator@7361 68 + strcpy(filename, unixpath); // found
slaxemulator@7361 69 + break;
slaxemulator@7361 70 + }
slaxemulator@7361 71 + len = seek - check;
slaxemulator@7361 72 + memcpy(s, check, len);
slaxemulator@7361 73 + s[len] = '\0';
slaxemulator@7361 74 + if (!lookup_entry(s, unixpath))
slaxemulator@7361 75 + break; // path mismatch
slaxemulator@7361 76 + }
slaxemulator@7361 77 +}
slaxemulator@7361 78 +#endif
slaxemulator@7361 79 +
slaxemulator@7361 80 #if ENABLE_TFTP
slaxemulator@7361 81
slaxemulator@7361 82 int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
slaxemulator@7361 83 @@ -785,6 +838,10 @@
slaxemulator@7361 84 goto err;
slaxemulator@7361 85 }
slaxemulator@7361 86 local_file = block_buf + 2;
slaxemulator@7361 87 +#if ENABLE_FEATURE_TFTPD_RIS
slaxemulator@7361 88 + if (local_file[0] == '\\')
slaxemulator@7361 89 + unixfilename(local_file);
slaxemulator@7361 90 +#endif
slaxemulator@7361 91 if (local_file[0] == '.' || strstr(local_file, "/.")) {
slaxemulator@7361 92 error_msg = "dot in file name";
slaxemulator@7361 93 goto err;