wok rev 17156

syslinux: fix rockridge
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Sep 15 18:45:08 2014 +0200 (2014-09-15)
parents 9c4b8d987746
children 63ca4e6217bd
files dev86/stuff/com2exe syslinux/stuff/extra/iso9660.u
line diff
     1.1 --- a/dev86/stuff/com2exe	Sun Sep 14 09:47:19 2014 +0200
     1.2 +++ b/dev86/stuff/com2exe	Mon Sep 15 18:45:08 2014 +0200
     1.3 @@ -4,7 +4,7 @@
     1.4  S=$((32+$(stat -c %s $1)))
     1.5  P=$((($S+511)/512))
     1.6  E=$((4096-(32*$P)))
     1.7 -for i in 0x5A4D $(($S%512)) $P 0 2 $E $E $((${2:-0}-16)) -2 0 256 -16 28 0 0 0
     1.8 +for i in 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) -2 0 256 -16 28 0x6C53 0x5469 0x7A61
     1.9  do printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | xargs echo -en
    1.10  done
    1.11  cat $1
     2.1 --- a/syslinux/stuff/extra/iso9660.u	Sun Sep 14 09:47:19 2014 +0200
     2.2 +++ b/syslinux/stuff/extra/iso9660.u	Mon Sep 15 18:45:08 2014 +0200
     2.3 @@ -1,24 +1,41 @@
     2.4  --- core/fs/iso9660/iso9660.c
     2.5  +++ core/fs/iso9660/iso9660.c
     2.6 -@@ -132,6 +132,28 @@
     2.7 +@@ -89,6 +89,24 @@
     2.8 +     return true;
     2.9 + }
    2.10 + 
    2.11 ++#define __ROCKRIDGE
    2.12 ++#ifdef __ROCKRIDGE
    2.13 ++static size_t rockname(const struct iso_dir_entry *de, char **name)
    2.14 ++{
    2.15 ++	size_t len, delen, n = (de->name_len + 34) & -2;
    2.16 ++	char *data = (char *) de;
    2.17 ++	
    2.18 ++	for (delen = 0; n + 2 < de->length; n += len) {
    2.19 ++		len = data[n + 2];
    2.20 ++		if (* (short *) (data + n) == 0x4D4E) { /* NM */
    2.21 ++			*name = data + n + 5;
    2.22 ++			delen = len - 5;
    2.23 ++		}
    2.24 ++	}
    2.25 ++	return delen;
    2.26 ++}
    2.27 ++#endif
    2.28 ++
    2.29 + /*
    2.30 +  * Find a entry in the specified dir with name _dname_.
    2.31 +  */
    2.32 +@@ -132,6 +150,20 @@
    2.33   	
    2.34   	de_name_len = de->name_len;
    2.35   	de_name = de->name;
    2.36 -+#define __ROCKRIDGE
    2.37  +#ifdef __ROCKRIDGE
    2.38  +	{
    2.39 -+		char *name = NULL, *end;
    2.40 -+		int n = (offset - de_len + de->name_len + 34) & -2;
    2.41 -+		int len = data[n + 2];
    2.42 -+		do {
    2.43 -+			if (* (short *) (data + n) == 0x4D4E) { // NM
    2.44 -+				name = data + n + 5;
    2.45 -+				end = data + n + len;
    2.46 -+			}
    2.47 -+			n += len;
    2.48 -+		} while (n + 2 < offset);
    2.49 -+		if (name) {
    2.50 -+			*end = 0;
    2.51 ++		char *name;
    2.52 ++		size_t len = rockname(de, &name);
    2.53 ++
    2.54 ++		if (len) {
    2.55 ++			name[len] = 0;
    2.56  +			if (!strcmp(name, dname)) {
    2.57  +				dprintf("Found rockridge.\n");
    2.58  +				return de;
    2.59 @@ -29,28 +46,29 @@
    2.60   	if (iso_compare_name(de_name, de_name_len, dname)) {
    2.61   	    dprintf("Found.\n");
    2.62   	    return de;
    2.63 -@@ -211,6 +233,24 @@
    2.64 - 	    data = NULL;
    2.65 - 	    continue;
    2.66 - 	}
    2.67 -+#ifdef __ROCKRIDGE2
    2.68 +@@ -217,11 +249,22 @@
    2.69 +     dirent->d_ino = 0;           /* Inode number is invalid to ISO fs */
    2.70 +     dirent->d_off = file->offset;
    2.71 +     dirent->d_type = get_inode_mode(de->flags);
    2.72 +-    dirent->d_reclen = offsetof(struct dirent, d_name) + 1 +
    2.73 +-	iso_convert_name(dirent->d_name, de->name, de->name_len);
    2.74 ++    iso_convert_name(dirent->d_name, de->name, de->name_len);
    2.75 + 
    2.76 ++#ifdef __ROCKRIDGE
    2.77  +	{
    2.78 -+		char *name = NULL;
    2.79 -+		int n = (offset + de->name_len + 34) & -2;
    2.80 -+		int len = data[n + 2], delen;
    2.81 -+		do {
    2.82 -+			if (* (short *) (data + n) == 0x4D4E) { // NM
    2.83 -+				name = data + n + 5;
    2.84 -+				delen = len - 5;
    2.85 -+			}
    2.86 -+			n += len;
    2.87 -+		} while (n + 2 < offset + de->length);
    2.88 -+		if (name) {
    2.89 -+			de->name_len = delen;
    2.90 -+			strcpy(de->name, name, delen);
    2.91 ++		char *name;
    2.92 ++		size_t len = rockname(de, &name);
    2.93 ++
    2.94 ++		if (len) {
    2.95 ++			strcpy(dirent->d_name, name);
    2.96 ++			dirent->d_name[len] = 0;
    2.97  +		}
    2.98  +	}
    2.99  +#endif
   2.100 - 	break;
   2.101 -     }
   2.102 -     
   2.103 ++    dirent->d_reclen = offsetof(struct dirent, d_name) + 1 + strlen(dirent->d_name);
   2.104 +     file->offset += de->length;  /* Update for next reading */
   2.105 +-    
   2.106 ++
   2.107 +     return 0;
   2.108 + }
   2.109 +