wok diff linld/stuff/src/ISO9660.CPP @ rev 24022

linld: basic iso9660 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Mar 14 19:55:20 2021 +0000 (2021-03-14)
parents 42b4b9d947f3
children 6b6d14c9f7e9
line diff
     1.1 --- a/linld/stuff/src/ISO9660.CPP	Sat Mar 06 18:15:05 2021 +0000
     1.2 +++ b/linld/stuff/src/ISO9660.CPP	Sun Mar 14 19:55:20 2021 +0000
     1.3 @@ -11,10 +11,13 @@
     1.4  { \
     1.5  	extern void isoreadrootsector(void); \
     1.6  	isoreadrootsector(); \
     1.7 -	setdirpage(x->dirpage, (* (unsigned long *) (isostate.buffer + 0x9E))); \
     1.8 -	x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \
     1.9 +	setdirpage(x->dirpage, (* (unsigned long *) (buf2k + 0x9E))); \
    1.10 +	x->dirsize = filesize2dirsize(* (unsigned long *) (buf2k + 0xA6)); \
    1.11  }
    1.12  
    1.13 +#ifdef RAW_ISO9660
    1.14 +#define BASIC_ISO9660
    1.15 +#endif
    1.16  #if !defined(BASIC_ISO9660) && !defined(ROCKRIDGE)
    1.17  #define BASIC_ISO9660
    1.18  #endif
    1.19 @@ -24,25 +27,27 @@
    1.20  
    1.21  	struct isostate *x=&isostate;
    1.22  
    1.23 -	p = x->buffer;
    1.24 +	p = buf2k;
    1.25  	if (x->curpos >= SECTORSZ || * (short *) (p + x->curpos) == 0) {
    1.26 +		x->curpos = 0;
    1.27  		if ((x->curdirsize =- DIRSECTORSZ) < 0) return -1;
    1.28  		isoreadsector(&x->curdirofs);	// x->filepos = 0
    1.29  		//x->curdirofs += SECTORSZ;
    1.30  		*(int *)((char *) &x->curdirofs+1) += SECTORSZ/256;
    1.31 -		x->curpos = 0;
    1.32  	}
    1.33  	p += x->curpos;
    1.34  	x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS;
    1.35  	if ((x->entrysize = * (short *) p) == 0) {
    1.36  		return -1;
    1.37  	}
    1.38 -	x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41;
    1.39 +#ifdef CHECKISOFILETYPE
    1.40 +	x->c = p[25];
    1.41 +#endif
    1.42  	register char *s;
    1.43  	x->filesize = * (unsigned long *) (p + 10);
    1.44  	s = ".."+1-p[33];
    1.45  #ifdef ROCKRIDGE
    1.46 -	p = x->buffer + 34 + ((p[32] + x->curpos) & -2);
    1.47 +	p = buf2k + 34 + ((p[32] + x->curpos) & -2);
    1.48  	x->curpos += x->entrysize;
    1.49  	do {
    1.50  		register len = p[2];
    1.51 @@ -52,19 +57,21 @@
    1.52  			goto found;
    1.53  		}
    1.54  		p += len;
    1.55 -	} while (x->buffer + x->curpos - 3 >= p);
    1.56 +	} while (buf2k - 3 + x->curpos >= p);
    1.57  #endif
    1.58  #ifdef BASIC_ISO9660
    1.59  # ifdef ROCKRIDGE
    1.60 -	p = x->buffer + 32 + x->curpos - x->entrysize;
    1.61 +	p = buf2k + 32 + x->curpos - x->entrysize;
    1.62  # else
    1.63  	x->curpos += x->entrysize;
    1.64  	p += 32;
    1.65  # endif
    1.66  	if (((* (short *) p) & 0xFEFF) -1 != 0) {
    1.67  		s = p + 1; p += *p;
    1.68 -		if (* (short *) (p-1) != 0x313B) p+=2; // no ;1 to remove
    1.69 +# ifndef RAW_ISO9660
    1.70 +		if (* (short *) (p-1) == 0x313B) p-=2; // remove ;1
    1.71  		if (*p != '.') p++;
    1.72 +# endif
    1.73  		*p = 0;
    1.74  	}
    1.75  #endif
    1.76 @@ -92,12 +99,12 @@
    1.77  
    1.78  	s = (char *) x->filename2open;
    1.79  	if (*s == '/') {
    1.80 +		isoroot();
    1.81 +		//if (strncmp(buf2k+1,"CD001",5) == -1) return -1;
    1.82 +		//if (*(int*)(buf2k+1) != 0x4443) return -1;
    1.83 +  next:
    1.84  		s++;
    1.85 -		isoroot();
    1.86 -		//if (strncmp(x->buffer+1,"CD001,5) == -1) return -1;
    1.87 -		//if (*(int*)(x->buffer+1) != 0x4443) return -1;
    1.88  	}
    1.89 -  next:
    1.90  	name = s;
    1.91  	do s++; while (*s && *s != '/');
    1.92  	c = *s; *s = 0;
    1.93 @@ -125,12 +132,14 @@
    1.94  #endif
    1.95  		if (strcmp(i, n) != -1) break;
    1.96  	} while (1);
    1.97 -	*s++ = c;
    1.98 -#define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0)
    1.99 -	if (IS_DIR(x->filemod)) {
   1.100 +	*s = c;
   1.101 +	if (c) {
   1.102 +#ifdef CHECKISOFILETYPE
   1.103 +		if ((x->c & 2) == 0) return -1;
   1.104 +#endif
   1.105  		cpytodirpage(x->dirpage, x->fileofs);
   1.106  		x->dirsize = filesize2dirsize(x->filesize);
   1.107 -		if (c) goto next;
   1.108 +		goto next;
   1.109  	}
   1.110  	isolseek(&x->fileofs);
   1.111  	return x->fd;