Break out POSIX-like definitions to posix.h

Add ISO9660 routines to convert to mode_t
Record whether XA or not in iso9660_stat_t.
And other definition shifting around.
This commit is contained in:
rocky
2005-11-06 00:39:37 +00:00
parent 7c6b8742c3
commit 6e4743c734
15 changed files with 279 additions and 154 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.27 2005/10/30 07:35:36 rocky Exp $
# $Id: Makefile.am,v 1.28 2005/11/06 00:39:37 rocky Exp $
#
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
#
@@ -41,6 +41,7 @@ libcdioinclude_HEADERS = \
iso9660.h \
logging.h \
mmc.h \
posix.h \
read.h \
rock.h \
sector.h \

View File

@@ -211,12 +211,14 @@ extern const char VSD_STD_ID_CDW01[sizeof("CDW02")-1];
extern const char VSD_STD_ID_NSR03[sizeof("NSR03")-1];
extern const char VSD_STD_ID_TEA01[sizeof("TEA01")-1];
#define VSD_STD_ID_BEA01 "BEA01" /**< (2/9.2) */
#define VSD_STD_ID_BOOT2 "BOOT2" /**< (2/9.4) */
#define VSD_STD_ID_CD001 "CD001" /**< (ECMA-119) */
#define VSD_STD_ID_CDW02 "CDW02" /**< (ECMA-168) */
#define VSD_STD_ID_NSR03 "NSR03" /**< (3/9.1) */
#define VSD_STD_ID_TEA01 "TEA01" /**< (2/9.3) */
#define VSD_STD_ID_BEA01 "BEA01" /**< ECMA-167 2/9.2 */
#define VSD_STD_ID_BOOT2 "BOOT2" /**< ECMA-167 2/9.4 */
#define VSD_STD_ID_CD001 "CD001" /**< ECMA-119 */
#define VSD_STD_ID_CDW02 "CDW02" /**< ECMA-168 */
#define VSD_STD_ID_NSR02 "NSR02" /**< ECMA-167, 3/9.1
NOTE: ECMA-167, 2nd edition */
#define VSD_STD_ID_NSR03 "NSR03" /**< ECMA-167 3/9.1 */
#define VSD_STD_ID_TEA01 "TEA01" /**< ECMA-168 2/9.3 */
/** Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
struct beginning_extended_area_desc_s

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.h,v 1.77 2005/10/21 11:51:42 rocky Exp $
$Id: iso9660.h,v 1.78 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -41,6 +41,7 @@
#include <cdio/cdio.h>
#include <cdio/ds.h>
#include <cdio/posix.h>
/** \brief ISO 9660 Integer and Character types
@@ -225,11 +226,6 @@ typedef struct iso9660_ltime_s iso9660_ltime_t;
typedef struct iso9660_dir_s iso9660_dir_t;
typedef struct iso9660_stat_s iso9660_stat_t;
typedef uint32_t posix_mode_t;
typedef uint32_t posix_nlink_t;
typedef uint32_t posix_uid_t;
typedef uint32_t posix_gid_t;
#include <cdio/rock.h>
/*! \brief Format of an ISO-9660 directory record
@@ -503,6 +499,7 @@ struct iso9660_stat_s { /* big endian!! */
uint32_t secsize; /**< number of sectors allocated */
iso9660_xa_t xa; /**< XA attributes */
enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
bool b_xa;
char filename[EMPTY_ARRAY_SIZE]; /**< filename */
};
@@ -864,129 +861,132 @@ uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
#endif
/*!
Return the directory name stored in the iso9660_dir_t
A string is allocated: the caller must deallocate.
*/
char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
/*!
Return the directory name stored in the iso9660_dir_t
A string is allocated: the caller must deallocate.
*/
char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
/*!
Return a string containing the preparer id with trailing
blanks removed.
*/
char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
/*!
Returns a POSIX mode for a given p_udf_dirent.
*/
posix_mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
/*!
Return a string containing the preparer id with trailing
blanks removed.
*/
char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
/*!
Get the preparer ID. psz_preparer_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
/*out*/ char **p_psz_preparer_id);
/*!
Get the preparer ID. psz_preparer_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
/*out*/ char **p_psz_preparer_id);
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
/*!
Get the publisher ID. psz_publisher_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
/*out*/ char **p_psz_publisher_id);
uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
/*! Return the primary volume id version number (of pvd).
/*!
Return a string containing the PVD's publisher id with trailing
blanks removed.
*/
char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
/*!
Get the publisher ID. psz_publisher_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
/*out*/ char **p_psz_publisher_id);
uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
/*! Return the primary volume id version number (of pvd).
If there is an error 0 is returned.
*/
int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
/*!
Return a string containing the PVD's system id with trailing
blanks removed.
*/
char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
*/
int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
/*!
Get the system ID. psz_system_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
/*out*/ char **p_psz_system_id);
/*! Return the LSN of the root directory for pvd.
/*!
Return a string containing the PVD's system id with trailing
blanks removed.
*/
char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
/*!
Get the system ID. psz_system_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
/*out*/ char **p_psz_system_id);
/*! Return the LSN of the root directory for pvd.
If there is an error CDIO_INVALID_LSN is returned.
*/
lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
/*!
Return the PVD's volume ID.
*/
char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
/*!
Get the system ID. psz_system_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
/*out*/ char **p_psz_volume_id);
/*!
Return the PVD's volumeset ID.
NULL is returned if there is some problem in getting this.
*/
char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
/*!
Get the systemset ID. psz_systemset_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
/*out*/ char **p_psz_volumeset_id);
/* pathtable */
/*! Zero's out pathable. Do this first. */
void iso9660_pathtable_init (void *pt);
unsigned int iso9660_pathtable_get_size (const void *pt);
uint16_t
iso9660_pathtable_l_add_entry (void *pt, const char name[], uint32_t extent,
uint16_t parent);
uint16_t
iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent,
uint16_t parent);
*/
lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
/*!
Return the PVD's volume ID.
*/
char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
/*!
Get the system ID. psz_system_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
/*out*/ char **p_psz_volume_id);
/*!
Return the PVD's volumeset ID.
NULL is returned if there is some problem in getting this.
*/
char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
/*!
Get the systemset ID. psz_systemset_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
/*out*/ char **p_psz_volumeset_id);
/* pathtable */
/*! Zero's out pathable. Do this first. */
void iso9660_pathtable_init (void *pt);
unsigned int iso9660_pathtable_get_size (const void *pt);
uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[],
uint32_t extent, uint16_t parent);
uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[],
uint32_t extent, 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, const time_t *pvd_time);
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, const time_t *pvd_time);
void
iso9660_set_evd (void *pd);
void iso9660_set_evd (void *pd);
/*!
Return true if ISO 9660 image has extended attrributes (XA).
*/
bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
/*!
Return true if ISO 9660 image has extended attrributes (XA).
*/
bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
#ifdef __cplusplus

44
include/cdio/posix.h Normal file
View File

@@ -0,0 +1,44 @@
/*
$Id: posix.h,v 1.1 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
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
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!
* \file posix.h
*
* \brief various POSIX definitions.
*/
#ifndef __CDIO_POSIX_H__
#define __CDIO_POSIX_H__
typedef uint32_t posix_mode_t;
typedef uint32_t posix_nlink_t;
typedef uint32_t posix_uid_t;
typedef uint32_t posix_gid_t;
typedef uint16_t unicode16_t;
#endif /* __CDIO_POSIX_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

View File

@@ -1,5 +1,5 @@
/*
$Id: rock.h,v 1.11 2005/10/04 09:59:46 rocky Exp $
$Id: rock.h,v 1.12 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -330,7 +330,13 @@ PRAGMA_END_PACKED
int get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * retname,
/*out*/ iso9660_stat_t *p_stat);
int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat);
int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat);
/*!
Returns POSIX mode bitstring for a given file.
*/
posix_mode_t
iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr);
/*!
Returns a string which interpreting the POSIX mode st_mode.

View File

@@ -1,5 +1,5 @@
/*
$Id: types.h,v 1.32 2005/09/17 20:57:19 rocky Exp $
$Id: types.h,v 1.33 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -55,6 +55,8 @@ extern "C" {
/* fixme */
#endif /* HAVE_STDINT_H */
typedef uint8_t ubyte;
/* default HP/UX macros are broken */
#if defined(__hpux__)
# undef UINT16_C

View File

@@ -1,5 +1,5 @@
/*
$Id: udf.h,v 1.17 2005/11/01 13:07:01 rocky Exp $
$Id: udf.h,v 1.18 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
@@ -30,16 +30,10 @@
#include <cdio/cdio.h>
#include <cdio/ecma_167.h>
#include <sys/stat.h>
#include <cdio/posix.h>
typedef uint16_t partition_num_t;
/* FIXME: these probably don't go here. */
typedef uint16_t unicode16_t;
typedef uint8_t ubyte;
/** Opaque structures. */
typedef struct udf_s udf_t;
typedef struct udf_file_s udf_file_t;
@@ -165,7 +159,7 @@ extern "C" {
otherwise.
'T' if the file is sticky but not executable. */
char *udf_mode_string (mode_t i_mode, char *psz_str);
char *udf_mode_string (posix_mode_t i_mode, char *psz_str);
#ifdef __cplusplus
}

View File

@@ -1,5 +1,5 @@
/*
$Id: udf_file.h,v 1.5 2005/11/02 03:49:15 rocky Exp $
$Id: udf_file.h,v 1.6 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
@@ -61,13 +61,23 @@ extern "C" {
/*!
Returns a POSIX mode for a given p_udf_dirent.
*/
mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent);
posix_mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent);
/*!
Return the next subdirectory.
*/
udf_dirent_t *udf_opendir(const udf_dirent_t *p_udf_dirent);
/*!
Attempts to read up to count bytes from file descriptor fd into
the buffer starting at buf.
If count is zero, read() returns zero and has no other results. If
count is greater than SSIZE_MAX, the result is unspecified.
*/
driver_return_code_t udf_read_block(const udf_dirent_t *p_udf_dirent,
void * buf, size_t count);
/*!
Advances p_udf_direct to the the next directory entry in the
pointed to by p_udf_dir. It also returns this as the value. NULL

View File

@@ -1,5 +1,5 @@
/*
$Id: xa.h,v 1.16 2005/08/27 14:25:58 rocky Exp $
$Id: xa.h,v 1.17 2005/11/06 00:39:37 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -140,7 +140,12 @@ typedef struct iso9660_xa_s
uint8_t filenum; /**< file number, see also XA subheader */
uint8_t reserved[5]; /**< zero */
} GNUC_PACKED iso9660_xa_t;
/*!
Returns POSIX mode bitstring for a given file.
*/
posix_mode_t iso9660_get_posix_filemode_from_xa(uint16_t i_perms);
/*!
Returns a string interpreting the extended attribute xa_attr.