/*
* ISO 9660 filesystem backend for GRUB (GRand Unified Bootloader)
* including Rock Ridge Extensions support
*
* Copyright (C) 1998, 1999 Kousuke Takai <tak@kmc.kyoto-u.ac.jp>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* References:
* (all are written by Eric Youngdale)
*
* Modifications by:
* Leonid Lisovskiy <lly@pisem.net> 2003
*/
#ifdef FSYS_ISO9660
#include "shared.h"
#include "filesys.h"
#include "iso9660.h"
/* iso9660 super-block data in memory */
struct iso_sb_info {
unsigned long vol_sector;
};
/* iso fs inode data in memory */
struct iso_inode_info {
unsigned long file_start;
};
#define ISO_SUPER \
((struct iso_sb_info *)(FSYS_BUF))
#define INODE \
static inline unsigned long
{
asm volatile ("bsfl %1,%0"
: "=r" (word)
: "r" (word));
return word;
}
static int
{
/*
* We have to use own devread() function since BIOS return wrong geometry
*/
if (sector < 0)
{
return 0;
}
if (byte_len <= 0)
return 1;
asm volatile ("shl%L0 %1,%0"
: "=r"(sector)
"0"(sector));
#if !defined(STAGE1_5)
if (disk_read_hook && debug)
#endif /* !STAGE1_5 */
noisy_printf(".");
}
}
int
iso9660_mount (void)
{
unsigned int sector;
/*
* Because there is no defined slice type ID for ISO-9660 filesystem,
* this test will pass only either (1) if entire disk is used, or
* (2) if current partition is BSD style sub-partition whose ID is
* ISO-9660.
*/
if ((current_partition != 0xFFFFFF)
return 0;
/*
* Currently, only FIRST session of MultiSession disks are supported !!!
*/
{
break;
/* check ISO_VD_PRIMARY and ISO_STANDARD_ID */
{
INODE->file_start = 0;
return 1;
}
}
return 0;
}
int
{
unsigned int pathlen;
int size;
unsigned int extent;
unsigned char file_type;
unsigned int rr_len;
unsigned char rr_flag;
INODE->file_start = 0;
do
{
dirname++;
/* pathlen = strcspn(dirname, "/\n\t "); */
for (pathlen = 0 ;
pathlen++)
;
while (size > 0)
{
{
return 0;
}
extent++;
{
if (name_len == 1)
{
if ((name[0] == 0) || /* self */
continue;
}
{
name_len--; /* truncate trailing dot */
}
/*
* Parse Rock-Ridge extension
*/
- sizeof(struct iso_directory_record)
+ sizeof(struct iso_directory_record)
if (rr_ptr.i & 1)
while (rr_len >= 4)
{
{
#ifndef STAGE1_5
if (debug)
"Non-supported version (%d) RockRidge chunk "
#endif
}
else
{
{
break;
rr_flag &= ~RR_FLAG_NM;
break;
{
? ISO_DIRECTORY : ISO_OTHER));
rr_flag &= ~RR_FLAG_PX;
}
break;
break;
#if 0 // RockRidge symlinks are not supported yet
{
int slen;
struct SL_component *slp;
while (slen > 1)
{
rootflag = 0;
{
case 0:
break;
case 4:
*rpnt++ = '.';
/* fallthru */
case 2:
*rpnt++ = '.';
break;
case 8:
rootflag = 1;
*rpnt++ = '/';
break;
default:
printf("Symlink component flag not implemented (%d)\n",
slen = 0;
break;
}
if (slen < 2)
{
/*
* If there is another SL record, and this component
* record isn't continued, then add a slash.
*/
*rpnt++='/';
break;
}
/*
* If this component record isn't continued, then append a '/'.
*/
*rpnt++ = '/';
}
*rpnt++ = '\0';
}
rr_flag &= ~RR_FLAG_SL;
break;
#endif
default:
break;
}
}
if (!rr_flag)
/*
* There is no more extension we expects...
*/
break;
{
/* preserve name before loading new extent. */
if( RRCONT_BUF <= (unsigned char *)name
{
}
{
errnum = 0; /* this is not fatal. */
break;
}
}
} /* rr_len >= 4 */
{
{
/*
* DIRNAME is directory component of pathname,
* or we are to open a file.
*/
{
{
if (file_type != ISO_DIRECTORY)
{
return 0;
}
goto next_dir_level;
}
if (file_type != ISO_REGULAR)
{
return 0;
}
filepos = 0;
return 1;
}
}
else /* Completion */
{
#ifndef STAGE1_5
if (print_possibilities > 0)
#endif
}
}
} /* for */
size -= ISO_SECTOR_SIZE;
} /* size>0 */
{
return 0;
}
} while (*dirname == '/');
return 1;
}
int
{
if (INODE->file_start == 0)
return 0;
ret = 0;
while (len > 0)
{
return 0;
sector++;
blkoffset = 0;
}
return ret;
}
#endif /* FSYS_ISO9660 */