wok-6.x diff busybox/stuff/busybox-1.22-ris.u @ rev 17188
Add simh
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Oct 03 18:49:40 2014 +0200 (2014-10-03) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/busybox/stuff/busybox-1.22-ris.u Fri Oct 03 18:49:40 2014 +0200 1.3 @@ -0,0 +1,93 @@ 1.4 +Add support for the Windows Remote Installation Service 1.5 +--- busybox-1.21.0/networking/Config.src 1.6 ++++ busybox-1.21.0/networking/Config.src 1.7 +@@ -820,6 +820,15 @@ 1.8 + comment "Common options for tftp/tftpd" 1.9 + depends on TFTP || TFTPD 1.10 + 1.11 ++config FEATURE_TFTPD_RIS 1.12 ++ bool "Enable \"RIS\" support" 1.13 ++ default y 1.14 ++ depends on TFTPD 1.15 ++ help 1.16 ++ Add support for the Windows Remote Installation Service. This allows 1.17 ++ a client to get files starting with \ without respecting case. 1.18 ++ Each \ will be replaced by a /. 1.19 ++ 1.20 + config FEATURE_TFTP_GET 1.21 + bool "Enable 'tftp get' and/or tftpd upload code" 1.22 + default y 1.23 + 1.24 +--- busybox-1.20.0/networking/tftp.c 1.25 ++++ busybox-1.20.0/networking/tftp.c 1.26 +@@ -671,6 +671,59 @@ 1.27 + #undef remote_file 1.28 + } 1.29 + 1.30 ++#if ENABLE_FEATURE_TFTPD_RIS 1.31 ++#include <dirent.h> 1.32 ++ 1.33 ++static int lookup_entry(const char *search, char *unixpath); 1.34 ++static void unixfilename(char *filename); 1.35 ++ 1.36 ++// lookup search and concat real filename to unixpath 1.37 ++static int lookup_entry(const char *search, char *unixpath) 1.38 ++{ 1.39 ++ int status = 0; 1.40 ++ DIR *dirp = opendir(unixpath[0] ? unixpath : "."); 1.41 ++ 1.42 ++ if (dirp != NULL) { 1.43 ++ struct dirent *entry; 1.44 ++ 1.45 ++ while ((entry = readdir(dirp))) { 1.46 ++ if (!strcasecmp(entry->d_name, search)) { 1.47 ++ if (unixpath[0]) strcat(unixpath, "/"); 1.48 ++ strcat(unixpath, entry->d_name); 1.49 ++ status++; 1.50 ++ break; 1.51 ++ } 1.52 ++ } 1.53 ++ closedir(dirp); 1.54 ++ } 1.55 ++ return status; 1.56 ++} 1.57 ++ 1.58 ++// update filename with real file path found 1.59 ++static void unixfilename(char *filename) 1.60 ++{ 1.61 ++ char unixpath[PATH_MAX]; 1.62 ++ char *s = unixpath + 1; 1.63 ++ char *check = filename + 1; 1.64 ++ int len; 1.65 ++ 1.66 ++ for (unixpath[0] = 0; *check; len++, s += len, check += len) { 1.67 ++ char *seek = strchr(check, '\\'); 1.68 ++ 1.69 ++ if (!seek) { // basename of filename 1.70 ++ if (lookup_entry(check, unixpath)) 1.71 ++ strcpy(filename, unixpath); // found 1.72 ++ break; 1.73 ++ } 1.74 ++ len = seek - check; 1.75 ++ memcpy(s, check, len); 1.76 ++ s[len] = '\0'; 1.77 ++ if (!lookup_entry(s, unixpath)) 1.78 ++ break; // path mismatch 1.79 ++ } 1.80 ++} 1.81 ++#endif 1.82 ++ 1.83 + #if ENABLE_TFTP 1.84 + 1.85 + int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1.86 +@@ -809,6 +862,10 @@ 1.87 + goto err; 1.88 + } 1.89 + local_file = G.block_buf + 2; 1.90 ++#if ENABLE_FEATURE_TFTPD_RIS 1.91 ++ if (local_file[0] == '\\') 1.92 ++ unixfilename(local_file); 1.93 ++#endif 1.94 + if (local_file[0] == '.' || strstr(local_file, "/.")) { 1.95 + error_msg = "dot in file name"; 1.96 + goto err;