Merge in and tidy up with mkisofs's iso9660.h. If that is correct

(and it probably is), there were erroneous field definitions.
This commit is contained in:
rocky
2003-09-01 02:08:59 +00:00
parent c3eae051f7
commit 0c7daa0e29
3 changed files with 155 additions and 89 deletions

View File

@@ -1,9 +1,14 @@
/* /*
$Id: iso9660.h,v 1.13 2003/08/31 14:26:06 rocky Exp $ $Id: iso9660.h,v 1.14 2003/09/01 02:08:59 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
See also iso9660.h by Eric Youngdale (1993).
Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (c) 1999,2000 J. Schilling
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
@@ -18,6 +23,11 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/*
* Header file iso9660.h - assorted structure definitions and typecasts.
specific to iso9660 filesystem.
*/
#ifndef __CDIO_ISO9660_H__ #ifndef __CDIO_ISO9660_H__
#define __CDIO_ISO9660_H__ #define __CDIO_ISO9660_H__
@@ -26,18 +36,42 @@
#include <cdio/xa.h> #include <cdio/xa.h>
#define MIN_TRACK_SIZE 4*75 #define MIN_TRACK_SIZE 4*75
#define MIN_ISO_SIZE MIN_TRACK_SIZE #define MIN_ISO_SIZE MIN_TRACK_SIZE
/*
A ISO filename is: "abcde.eee;1" -> <filename> '.' <ext> ';' <version #>
The maximum needed string length is:
30 chars (filename + ext)
+ 2 chars ('.' + ';')
+ strlen("32767")
+ null byte
================================
= 38 chars
*/
#define LEN_ISONAME 31 #define LEN_ISONAME 31
#define MAX_ISONAME 37 #define MAX_ISONAME 37
#define MAX_ISOPATHNAME 255 #define MAX_ISOPATHNAME 255
#define ISO_FILE 0 /*
* ISO 9660 directory flags.
*/
#define ISO_FILE 0 /* Not really a flag... */
#define ISO_EXISTENCE 1 /* Do not make existence known (hidden) */
#define ISO_DIRECTORY 2 /* This file is a directory */
#define ISO_ASSOCIATED 4 /* This file is an assiciated file */
#define ISO_RECORD 8 /* Record format in extended attr. != 0 */
#define ISO_PROTECTION 16 /* No read/execute perm. in ext. attr. */
#define ISO_DRESERVED1 32 /* Reserved bit 5 */
#define ISO_DRESERVED2 64 /* Reserved bit 6 */
#define ISO_MULTIEXTENT 128 /* Not final entry of a mult. ext. file */
/* Volume descriptor types */
#define ISO_VD_PRIMARY 1 #define ISO_VD_PRIMARY 1
#define ISO_DIRECTORY 2 #define ISO_VD_SUPPLEMENTARY 2 /* Used by Joliet */
#define ISO_VD_END 255
#define ISO_PVD_SECTOR 16 #define ISO_PVD_SECTOR 16
#define ISO_EVD_SECTOR 17 #define ISO_EVD_SECTOR 17
@@ -51,13 +85,11 @@ enum strncpy_pad_check {
ISO9660_DCHARS ISO9660_DCHARS
}; };
typedef struct iso9660_pvd iso9660_pvd_t;
typedef struct iso9660_dir iso9660_dir_t;
typedef struct iso9660_stat iso9660_stat_t;
PRAGMA_BEGIN_PACKED PRAGMA_BEGIN_PACKED
struct iso9660_pvd { /* ISO-9660 Primary Volume Descriptor.
*/
typedef struct iso9660_pvd {
uint8_t type; /* 711 */ uint8_t type; /* 711 */
char id[5]; char id[5];
uint8_t version; /* 711 */ uint8_t version; /* 711 */
@@ -91,12 +123,24 @@ struct iso9660_pvd {
char unused4[1]; char unused4[1];
char application_data[512]; char application_data[512];
char unused5[653]; char unused5[653];
} GNUC_PACKED; } iso9660_pvd_t GNUC_PACKED;
typedef struct iso9660_dir iso9660_dir_t;
#ifndef EMPTY_ARRAY_SIZE #ifndef EMPTY_ARRAY_SIZE
#define EMPTY_ARRAY_SIZE 0 #define EMPTY_ARRAY_SIZE 0
#endif #endif
/*
* XXX JS: The next structure may have an odd length!
* Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
* For this reason, we cannot use sizeof (struct iso_path_table) or
* sizeof (struct iso_directory_record) to compute on disk sizes.
* Instead, we use offsetof(..., name) and add the name size.
* See mkisofs.h
*/
/* Format of an ISO-9660 directory record */
struct iso9660_dir { struct iso9660_dir {
uint8_t length; /* 711 */ uint8_t length; /* 711 */
uint8_t ext_attr_length; /* 711 */ uint8_t ext_attr_length; /* 711 */
@@ -111,13 +155,13 @@ struct iso9660_dir {
char name[EMPTY_ARRAY_SIZE]; char name[EMPTY_ARRAY_SIZE];
} GNUC_PACKED; } GNUC_PACKED;
struct iso9660_stat { /* big endian!! */ typedef struct iso9660_stat { /* big endian!! */
enum { _STAT_FILE = 1, _STAT_DIR = 2 } type; enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
lsn_t lsn; /* start logical sector number */ lsn_t lsn; /* start logical sector number */
uint32_t size; /* total size in bytes */ uint32_t size; /* total size in bytes */
uint32_t secsize; /* number of sectors allocated */ uint32_t secsize; /* number of sectors allocated */
iso9660_xa_t xa; /* XA attributes */ iso9660_xa_t xa; /* XA attributes */
}; } iso9660_stat_t;
PRAGMA_END_PACKED PRAGMA_END_PACKED
@@ -141,18 +185,6 @@ iso9660_dirname_valid_p (const char pathname[]);
char * char *
iso9660_pathname_isofy (const char pathname[], uint16_t version); iso9660_pathname_isofy (const char pathname[], uint16_t version);
/* volume descriptors */
void
iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[],
const char publisher_id[], const char preparer_id[],
uint32_t iso_size, const void *root_dir,
uint32_t path_table_l_extent, uint32_t path_table_m_extent,
uint32_t path_table_size);
void
iso9660_set_evd (void *pd);
/* directory tree */ /* directory tree */
void void
@@ -225,6 +257,18 @@ uint16_t
iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent, iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent,
uint16_t parent); uint16_t parent);
/* volume descriptors */
void
iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[],
const char publisher_id[], const char preparer_id[],
uint32_t iso_size, const void *root_dir,
uint32_t path_table_l_extent, uint32_t path_table_m_extent,
uint32_t path_table_size);
void
iso9660_set_evd (void *pd);
#endif /* __CDIO_ISO9660_H__ */ #endif /* __CDIO_ISO9660_H__ */
/* /*

View File

@@ -1,9 +1,14 @@
/* /*
$Id: xa.h,v 1.3 2003/08/31 09:11:25 rocky Exp $ $Id: xa.h,v 1.4 2003/09/01 02:08:59 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
See also iso9660.h by Eric Youngdale (1993).
Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (c) 1999,2000 J. Schilling
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
@@ -22,21 +27,23 @@
#ifndef __CDIO_XA_H__ #ifndef __CDIO_XA_H__
#define __CDIO_XA_H__ #define __CDIO_XA_H__
#include <cdio/types.h>
#define ISO_XA_MARKER_STRING "CD-XA001" #define ISO_XA_MARKER_STRING "CD-XA001"
#define ISO_XA_MARKER_OFFSET 1024 #define ISO_XA_MARKER_OFFSET 1024
/* XA attribute definitions */ /* XA attribute definitions */
#define XA_ATTR_U_READ (1 << 0) #define XA_ATTR_G_READ 0x0001 /* System Group Read */
/* reserved */ #define XA_ATTR_G_EXEC 0x0004 /* System Group Execute */
#define XA_ATTR_U_EXEC (1 << 2)
/* reserved */ #define XA_ATTR_U_READ 0x0010 /* Owner Read */
#define XA_ATTR_G_READ (1 << 4) #define XA_ATTR_U_EXEC 0x0040 /* Owner Execute */
/* reserved */
#define XA_ATTR_G_EXEC (1 << 6) #define XA_ATTR_O_READ 0x0100 /* Group Read */
/* reserved */ #define XA_ATTR_O_EXEC 0x0400 /* Group Execute */
#define XA_ATTR_O_READ (1 << 8)
/* reserved */ #define XA_ATTR_W_READ 0x1000 /* World (other) Read */
#define XA_ATTR_O_EXEC (1 << 10) #define XA_ATTR_W_EXEC 0x4000 /* World (other) Execute */
#define XA_ATTR_MODE2FORM1 (1 << 11) #define XA_ATTR_MODE2FORM1 (1 << 11)
#define XA_ATTR_MODE2FORM2 (1 << 12) #define XA_ATTR_MODE2FORM2 (1 << 12)
@@ -53,17 +60,18 @@
#define XA_FORM1_FILE (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL) #define XA_FORM1_FILE (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL)
#define XA_FORM2_FILE (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL) #define XA_FORM2_FILE (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL)
typedef struct iso9660_xa iso9660_xa_t; /*
* Extended Attributes record according to Yellow Book.
struct iso9660_xa /* big endian!! */ */
typedef struct iso9660_xa /* big endian!! */
{ {
uint16_t user_id; /* 0 */
uint16_t group_id; /* 0 */ uint16_t group_id; /* 0 */
uint16_t user_id; /* 0 */
uint16_t attributes; /* XA_ATTR_ */ uint16_t attributes; /* XA_ATTR_ */
uint8_t signature[2]; /* { 'X', 'A' } */ uint8_t signature[2]; /* { 'X', 'A' } */
uint8_t filenum; /* file number, see also XA subheader */ uint8_t filenum; /* file number, see also XA subheader */
uint8_t reserved[5]; /* zero */ uint8_t reserved[5]; /* zero */
} GNUC_PACKED; } iso9660_xa_t GNUC_PACKED;
/*! /*!

View File

@@ -1,9 +1,14 @@
/* /*
$Id: iso9660_private.h,v 1.4 2003/08/31 05:00:44 rocky Exp $ $Id: iso9660_private.h,v 1.5 2003/09/01 02:08:59 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
See also iso9660.h by Eric Youngdale (1993).
Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (c) 1999,2000 J. Schilling
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
@@ -24,8 +29,6 @@
#include <cdio/types.h> #include <cdio/types.h>
#define ISO_VD_END 255
#define ISO_VERSION 1 #define ISO_VERSION 1
PRAGMA_BEGIN_PACKED PRAGMA_BEGIN_PACKED
@@ -41,6 +44,17 @@ struct iso_volume_descriptor {
#define struct_iso9660_pvd_SIZEOF ISO_BLOCKSIZE #define struct_iso9660_pvd_SIZEOF ISO_BLOCKSIZE
/*
* XXX JS: The next structure has an odd length!
* Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
* For this reason, we cannot use sizeof (struct iso_path_table) or
* sizeof (struct iso_directory_record) to compute on disk sizes.
* Instead, we use offsetof(..., name) and add the name size.
* See mkisofs.h
*/
/* We use this to help us look up the parent inode numbers. */
struct iso_path_table { struct iso_path_table {
uint8_t name_len; /* 711 */ uint8_t name_len; /* 711 */
uint8_t xa_len; /* 711 */ uint8_t xa_len; /* 711 */