wok-next diff busybox/stuff/busybox-1.17.0-ris.u @ rev 5776

busybox: update patches
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 07 20:55:53 2010 +0200 (2010-07-07)
parents 74d790665d71
children
line diff
     1.1 --- a/busybox/stuff/busybox-1.17.0-ris.u	Tue Jul 06 15:09:01 2010 +0200
     1.2 +++ b/busybox/stuff/busybox-1.17.0-ris.u	Wed Jul 07 20:55:53 2010 +0200
     1.3 @@ -1,3 +1,4 @@
     1.4 +Add support for the Windows Remote Installation Service
     1.5  --- busybox-1.17.0/networking/Config.src
     1.6  +++ busybox-1.17.0/networking/Config.src
     1.7  @@ -841,6 +841,15 @@
     1.8 @@ -9,7 +10,7 @@
     1.9  +	default y
    1.10  +	depends on TFTPD
    1.11  +	help
    1.12 -+	  Add support for the Remote Installation Service. This allows
    1.13 ++	  Add support for the Windows Remote Installation Service. This allows
    1.14  +	  a client to get files starting with \ without respecting case.
    1.15  +	  Each \ will be replaced by a /.
    1.16  +
    1.17 @@ -19,63 +20,59 @@
    1.18  
    1.19  --- busybox-1.17.0/networking/tftp.c
    1.20  +++ busybox-1.17.0/networking/tftp.c
    1.21 -@@ -656,6 +656,63 @@
    1.22 +@@ -656,6 +656,59 @@
    1.23   #undef remote_file
    1.24   }
    1.25   
    1.26  +#if ENABLE_FEATURE_TFTPD_RIS
    1.27  +#include <dirent.h>
    1.28  +
    1.29 -+int lookup_entry(const char *comp, char *dest);
    1.30 -+void lookup_file(char *filename);
    1.31 ++static int lookup_entry(const char *search, char *unixpath);
    1.32 ++static void unixfilename(char *filename);
    1.33  +
    1.34 -+int lookup_entry(const char *comp, char *dest)
    1.35 ++// lookup search and concat real filename to unixpath
    1.36 ++static int lookup_entry(const char *search, char *unixpath)
    1.37  +{
    1.38 -+	DIR *dirp;
    1.39 -+	struct dirent *dptr;
    1.40 -+	if (!dest) return 0;
    1.41 -+	dirp = opendir(dest[0] ? dest : ".");
    1.42 -+	while ((dptr = readdir(dirp))) {
    1.43 -+		if (!strcasecmp(dptr->d_name, comp)) {
    1.44 -+			if (dest[0]) strcat(dest, "/");
    1.45 -+			strcat(dest, dptr->d_name);
    1.46 -+			closedir(dirp);
    1.47 -+			return 1;
    1.48 ++ 	int status = 0;
    1.49 ++	DIR *dirp = opendir(unixpath[0] ? unixpath : ".");
    1.50 ++ 
    1.51 ++ 	if (dirp != NULL) {
    1.52 ++		struct dirent *entry;
    1.53 ++
    1.54 ++		while ((entry = readdir(dirp))) {
    1.55 ++			if (!strcasecmp(entry->d_name, search)) {
    1.56 ++				if (unixpath[0]) strcat(unixpath, "/");
    1.57 ++				strcat(unixpath, entry->d_name);
    1.58 ++				status++;
    1.59 ++				break;
    1.60 ++			}
    1.61  +		}
    1.62 -+	}
    1.63 -+	closedir(dirp);
    1.64 -+	return 0;
    1.65 ++		closedir(dirp);
    1.66 ++ 	}
    1.67 ++	return status;
    1.68  +}
    1.69  +
    1.70 -+void lookup_file(char *filename)
    1.71 ++// update filename with real file path found
    1.72 ++static void unixfilename(char *filename)
    1.73  +{
    1.74 -+	int found = 0;
    1.75 -+	int len = 0;
    1.76 -+	char dest[1024];
    1.77 -+	char comp[1024];
    1.78 -+	char *check = filename;
    1.79 -+	char *seek = NULL;
    1.80 ++	char unixpath[PATH_MAX];
    1.81 ++	char *s = unixpath + 1;
    1.82 ++	char *check = filename + 1;
    1.83 ++	int len;
    1.84  +
    1.85 -+	dest[0] = 0;
    1.86 -+	check++;
    1.87 -+	while (*check) {
    1.88 -+		seek = strchr(check, '\\');
    1.89 -+		if (!seek) {
    1.90 -+			if ((*check) && (lookup_entry(check, dest)))
    1.91 -+				found = 1;
    1.92 ++	for (unixpath[0] = 0; *check; len++, s += len, check += len) {
    1.93 ++		char *seek = strchr(check, '\\');
    1.94 ++
    1.95 ++		if (!seek) { // basename of filename
    1.96 ++			if (lookup_entry(check, unixpath))
    1.97 ++				strcpy(filename, unixpath); // found
    1.98  +			break;
    1.99  +		}
   1.100  +		len = seek - check;
   1.101 -+		memcpy(comp, check, len);
   1.102 -+		comp[len]=0;
   1.103 -+		if (!lookup_entry(comp, dest))
   1.104 -+			break;
   1.105 -+		check += len + 1;
   1.106 -+	}
   1.107 -+
   1.108 -+	if (found) {
   1.109 -+		filename[0] = 0;
   1.110 -+		strcat(filename, dest);
   1.111 ++		memcpy(s, check, len);
   1.112 ++		s[len] = '\0';
   1.113 ++		if (!lookup_entry(s, unixpath))
   1.114 ++			break; // path mismatch
   1.115  +	}
   1.116  +}
   1.117  +#endif
   1.118 @@ -83,14 +80,13 @@
   1.119   #if ENABLE_TFTP
   1.120   
   1.121   int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
   1.122 -@@ -785,6 +842,11 @@
   1.123 +@@ -785,6 +838,10 @@
   1.124   		goto err;
   1.125   	}
   1.126   	local_file = block_buf + 2;
   1.127  +#if ENABLE_FEATURE_TFTPD_RIS
   1.128 -+	if (local_file[0] == '\\') {
   1.129 -+		lookup_file(local_file);
   1.130 -+	}
   1.131 ++	if (local_file[0] == '\\')
   1.132 ++		unixfilename(local_file);
   1.133  +#endif
   1.134   	if (local_file[0] == '.' || strstr(local_file, "/.")) {
   1.135   		error_msg = "dot in file name";